Getting started

raftdb-mysql settings

Every setting of the MySQL and MariaDB front-end program, with defaults, the one-process and two-process modes, and an example file.

raftdb-mysql reads a key = value file (# starts a comment, also after a value) given with --config FILE, and the same keys as --key value arguments (a dash and an underscore are the same). Unknown keys are an error.

Syntax#

# mysql.conf
listen = 0.0.0.0:3306
embed = /etc/raftdb/raftdb.conf
raftdb_user = connector
raftdb_password = ...
user = app:secret
dialect = mysql
# raftdb.conf, the server's own settings file, read by `embed`
dir = /var/lib/raftdb
addr = 127.0.0.1:7480
shards = 4
user = connector:...:admin

Options#

KeyMeaningDefault
listenWhere MySQL and MariaDB clients connect (HOST:PORT).127.0.0.1:3307
dialectmysql or mariadb: which server the process answers as (identification, default authentication plugin, system variable defaults, character sets). One process answers as one dialect; run a second process on another port for the other one.mysql
isolationtable or none: whether a session that writes a table inside a transaction holds it until the end so that other sessions wait (no dirty reads, no lost updates; error 1205 after innodb_lock_wait_timeout, 1213 for a deadlock). none gives the earlier behaviour: other sessions see uncommitted writes.table
identityneutral (the only value): @@version_comment says Raft DB. The old value vendor was removed and is refused at start. The numeric VERSION() (8.0.36-Raft DB, 11.4.13-MariaDB-Raft DB) keeps its numbers; the -MariaDB part of the MariaDB one is what connectors read to choose the MariaDB dialect, so it stays.neutral
userA MySQL user: NAME:PASSWORD, repeatable. Only the first colon splits, so a password may contain colons. These are the bootstrap administrators: every privilege, not changeable with SQL. At least one is required.none
embedPath of a raftdb.conf: the server of that file runs inside this process (one process). Then raftdb is not used.none (two processes)
raftdbHOST:PORT of the Raft DB server in two-process mode.127.0.0.1:7480
raftdb_userThe Raft DB account the front-end acts as. Required. With embed it must be an account of that raftdb.conf. Give it the role the MySQL users need (admin if they create databases and tables).none
raftdb_passwordIts password.none
raftdb_password_fileA file holding the password (one trailing newline is removed). It is read when the settings are read.none
max_connectionsThe most client connections at once; one more gets error 1040.500
alloc_cacheon or off: keep freed memory blocks per thread.on
spin_usThe most microseconds a busy connection looks for its next message before it sleeps. 0 is never. Between 0 and 1000.150
raftdb_connectionsTwo processes: how many long-lived connections to the server all sessions share (0 to 64). 0 shares nothing. Not used with embed.1
raftdb_shareWhat travels on the shared connections: reads (reads by key) or all (every row request). Use all with 2 or more connections for a front-end on another machine or with hundreds of sessions.reads

Remarks#

  • The MySQL users are the front-end's own. They are not accounts of raftdb-server. A MySQL password cannot be checked against Raft DB's accounts, because both MySQL password plugins prove knowledge of a password without sending it and Raft DB keeps only a slow hash. The front-end derives the check values from the configured password. All other MySQL accounts are made with CREATE USER and stored in a hidden database; see MySQL accounts.
  • One process or two. With embed, a row read costs no network round trip. Use two processes only to put the front-end on another machine than the data. See Architecture.
  • Command line and file together. With --config FILE the file is read first, and then only these keys given on the command line are applied over it: listen, raftdb, raftdb_user, raftdb_password, user (added to the file's), alloc_cache, spin_us, raftdb_connections, raftdb_share all, identity. dialect, max_connections and embed must therefore be set in the file when a file is used. Put every setting in the file and you avoid the question.
  • The first start with embed. If the raftdb.conf has no user and no token, the embedded server creates the admin account and writes its password to <dir>/admin.password. That file does not exist yet when raftdb-mysql reads raftdb_password_file, so for the first start name an explicit account in raftdb.conf (user = connector:PASSWORD:admin) and use the same password in raftdb_password.
  • A # starts a comment anywhere in a line of the file, also inside a value: a password that contains # is cut at it. Choose passwords without # for the file, or give the password with --user on the command line (where it shows in the process list), or use raftdb_password_file, which is read whole.
  • TLS. ssl_cert and ssl_key (PEM files), ssl_mode (off, preferred, required) and ssl = auto (a self-signed certificate made at start) turn it on; without them the front-end does not offer the SSL capability and a client that insists on TLS fails. See TLS and encryption.
  • Authentication plugin. The MySQL dialect offers caching_sha2_password first and switches a client that does not use it to mysql_native_password; the MariaDB dialect offers mysql_native_password. caching_sha2_password always succeeds on the fast path, so no RSA exchange is needed.

Examples#

One process, MariaDB dialect, on port 3308:

# mariadb.conf
listen = 127.0.0.1:3308
dialect = mariadb
embed = /etc/raftdb/raftdb.conf
raftdb_user = connector
raftdb_password = ...
user = app:secret

Two processes, the front-end on the application's machine:

listen = 127.0.0.1:3306
raftdb = db1.internal:7480
raftdb_user = connector
raftdb_password_file = /etc/raftdb/mysql.pw
raftdb_connections = 2
raftdb_share = all
user = app:secret

(The link to db1.internal is clear text: use a tunnel.)

See also#