Aegis documentation

#MariaDB

The MariaDB cube owns the server, its data directory and the databases created through it. It renders aegis-my.cnf (mode 0600) under mariadb.config_dir (/aegis/config/mariadb), keeps the data directory in mariadb.data_dir, the socket, pid and error log in mariadb.run_dir and mariadb.log_dir, and runs mariadb-install-db once when the data directory is empty. configure also creates the platform superuser from aegis.user / aegis.password.

The server runs as the keeper service aegis-mariadb under the mariadb.user account (default mysql). Administrative statements run as root over the Unix socket.

#Common commands

Cube operations share one wrapper: ✔ mariadb: <detail> on success, ✖ <message> on failure (exit 1), and {"ok": true, "cube": "mariadb", "result": "<detail>"} with global --json.

expose is the only verb that prints a block instead of that line.

VerbEffect
configurecreate the service account, render the config, initialise the data directory if empty, start, ensure the platform role
validaterun mariadb-admin ping over the socket
reloadrun mariadb-admin reload: grants and tables are re-read
statusread run/mariadb/mysqld.pid: running (pid N) or stopped
startstart mariadbd through the keeper
stopSIGTERM, then SIGKILL after 15 seconds
restartstop, then start
exposeprint paths, port and socket, then publish the MariaDB tools
helpprint the command list with examples

#configure

bash
aegis cubes mariadb configureaegis --json cubes mariadb configure
text
✔ mariadb: configuration written, server answers ping{"ok": true, "cube": "mariadb", "result": "configuration written, server answers ping"}

#validate

bash
aegis cubes mariadb validateaegis --json cubes mariadb validate
text
✔ mariadb: server answers ping{"ok": true, "cube": "mariadb", "result": "server answers ping"}

#reload

bash
aegis cubes mariadb reloadaegis --json cubes mariadb reload

Reloads the grant tables and flushes tables; it does not re-read the server configuration file. Use restart for a configuration change.

text
✔ mariadb: privileges reloaded{"ok": true, "cube": "mariadb", "result": "privileges reloaded"}

#status

bash
aegis cubes mariadb statusaegis --json cubes mariadb status
text
✔ mariadb: running (pid 1701){"ok": true, "cube": "mariadb", "result": "running (pid 1701)"}

#start

bash
aegis cubes mariadb startaegis --json cubes mariadb start
text
✔ mariadb: started (pid 1701){"ok": true, "cube": "mariadb", "result": "started (pid 1701)"}

#stop

bash
aegis cubes mariadb stopaegis --json cubes mariadb stop
text
✔ mariadb: stopped (pid 1701){"ok": true, "cube": "mariadb", "result": "stopped (pid 1701)"}

#restart

bash
aegis cubes mariadb restartaegis --json cubes mariadb restart
text
✔ mariadb: stopped (pid 1701), started (pid 1738){"ok": true, "cube": "mariadb", "result": "stopped (pid 1701), started (pid 1738)"}

#expose

bash
aegis cubes mariadb exposeaegis --json cubes mariadb expose
text
cube           mariadbinstalled      /aegis/apps/data/mariadb/13.0configuration  /aegis/config/mariadbstate          running (pid 1701)pid            1701log            /aegis/logs/mariadb/error.logconfig         /aegis/config/mariadb/aegis-my.cnfdata           /aegis/data/mariadbport           3306socket         /aegis/run/mariadb/mysqld.sockpublished      /aegis/bin/mariadb, /aegis/bin/mariadb-admin, /aegis/bin/mariadb-dump, /aegis/bin/mariadb-install-db, /aegis/bin/mariadbd
text
{"ok": true, "cube": "mariadb", "installed": "/aegis/apps/data/mariadb/13.0", "configuration": "/aegis/config/mariadb", "state": "running (pid 1701)", "pid": "1701", "log": "/aegis/logs/mariadb/error.log", "config": "/aegis/config/mariadb/aegis-my.cnf", "data": "/aegis/data/mariadb", "port": "3306", "socket": "/aegis/run/mariadb/mysqld.sock", "published": "/aegis/bin/mariadb, /aegis/bin/mariadb-admin, /aegis/bin/mariadb-dump, /aegis/bin/mariadb-install-db, /aegis/bin/mariadbd"}

#help

bash
aegis cubes mariadb helpaegis cubes help mariadb
text
ℹ Mariadb — MariaDB server, its data directory and databasesCommands  validate   Check the configuration  reload     Reload the running daemon  configure  Prepare the data dir and write config  start      Start the server  stop       Stop the server  status     Show whether the server runs  restart    Restart the server  expose     Show where it is installed and how it runs  databases  Manage databases

The list continues with users, tables and help, then the examples.

#Databases

#databases list

bash
aegis cubes mariadb databases listaegis --json cubes mariadb databases list

The system schemas (mysql, information_schema, performance_schema, sys) are excluded.

text
✔ mariadb: aegis, shop{"ok": true, "cube": "mariadb", "result": "aegis, shop"}

#databases create

bash
aegis cubes mariadb databases create shopaegis --json cubes mariadb databases create analytics
ArgumentMeaning
namedatabase name: letters, digits, _, . and -

Created with utf8mb4 / utf8mb4_unicode_ci, and aegis.user is granted all privileges on it for both localhost and 127.0.0.1.

text
✔ mariadb: created shop (owner aegis){"ok": true, "cube": "mariadb", "result": "created analytics (owner aegis)"}

#databases drop

Destructive. Drops the database and every table in it. The system schemas are refused explicitly.

bash
aegis cubes mariadb databases drop shopaegis --json cubes mariadb databases drop analytics
ArgumentMeaning
namethe database to drop
text
✔ mariadb: dropped shop{"ok": true, "cube": "mariadb", "result": "dropped analytics"}

#Users

A user is created on both local hosts, localhost and 127.0.0.1, because MariaDB treats them as separate accounts. Grants are always per database; the cube never hands out global privileges.

#users list

bash
aegis cubes mariadb users listaegis --json cubes mariadb users list
text
✔ mariadb: shop@localhost, shop@127.0.0.1{"ok": true, "cube": "mariadb", "result": "shop@localhost, shop@127.0.0.1"}

#users add

bash
aegis cubes mariadb users add shop --database shopaegis cubes mariadb users add app --database shop --database analytics
OptionMeaning
nameaccount name: letters, digits, _, ., -
--passwordpassword; generated and printed when omitted
--databasedatabase to grant; repeatable
text
✔ mariadb: user shop created; shop granted on shop{"ok": true, "cube": "mariadb", "result": "user app created; app granted on shop, app granted on analytics"}

#users remove

Destructive. Drops the account on both hosts. Objects it created inside a database are not removed, but they become inaccessible through that account.

bash
aegis cubes mariadb users remove shopaegis --json cubes mariadb users remove app
ArgumentMeaning
namethe account to drop
text
✔ mariadb: user shop dropped{"ok": true, "cube": "mariadb", "result": "user app dropped"}

#users password

bash
aegis cubes mariadb users password shop --password 'new-secret'aegis --json cubes mariadb users password shop --password 'new-secret'
OptionMeaning
namethe account
--passwordrequired new password
text
✔ mariadb: password changed for shop{"ok": true, "cube": "mariadb", "result": "password changed for shop"}

#users grant

bash
aegis cubes mariadb users grant shop shopaegis --json cubes mariadb users grant app analytics
ArgumentMeaning
namethe account
databasethe database to grant
text
✔ mariadb: shop granted on shop{"ok": true, "cube": "mariadb", "result": "app granted on analytics"}

#users revoke

Destructive. Revokes all privileges on that database; the account itself stays.

bash
aegis cubes mariadb users revoke shop shopaegis --json cubes mariadb users revoke app analytics
text
✔ mariadb: shop revoked on shop{"ok": true, "cube": "mariadb", "result": "app revoked on analytics"}

#Tables

#tables list

bash
aegis cubes mariadb tables list shopaegis --json cubes mariadb tables list shop
ArgumentMeaning
databasethe database to inspect

Row estimates and data_length + index_length in megabytes.

text
✔ mariadb: orders (120 rows, 0.2 MB); sessions (12 rows, 0.0 MB){"ok": true, "cube": "mariadb", "result": "orders (120 rows, 0.2 MB); sessions (12 rows, 0.0 MB)"}

#tables check

bash
aegis cubes mariadb tables check shopaegis cubes mariadb tables check shop orders sessions
ArgumentMeaning
databasethe database
tableoptional table names; all tables when omitted

Runs CHECK TABLE once per table and names the failing table in the error.

text
✔ mariadb: check done on 5 tables in shop{"ok": true, "cube": "mariadb", "result": "check done on 2 tables in shop"}

#tables repair

Destructive. REPAIR TABLE rewrites the table and can drop rows it cannot read. It is for crash damage, not routine maintenance.

bash
aegis cubes mariadb tables repair shopaegis cubes mariadb tables repair shop orders

Options are the same as tables check.

text
✔ mariadb: repair done on 1 tables in shop{"ok": true, "cube": "mariadb", "result": "repair done on 1 tables in shop"}

#tables optimize

bash
aegis cubes mariadb tables optimize shopaegis cubes mariadb tables optimize shop orders

OPTIMIZE TABLE rewrites the table and reclaims space; it takes an exclusive lock on each table for the duration.

text
✔ mariadb: optimize done on 5 tables in shop{"ok": true, "cube": "mariadb", "result": "optimize done on 1 tables in shop"}

#tables analyze

bash
aegis cubes mariadb tables analyze shopaegis --json cubes mariadb tables analyze shop

Refreshes index statistics without rewriting data.

text
✔ mariadb: analyze done on 5 tables in shop{"ok": true, "cube": "mariadb", "result": "analyze done on 5 tables in shop"}