mysqlctld

mysqlctld is a gRPC server that can be used instead of the mysqlctl client tool. If the target directories are empty when it is invoked, it automatically performs initialization operations to bootstrap the mysqld instance before starting it. The mysqlctld process can subsequently receive gRPC commands from a vttablet to perform housekeeping operations like shutting down and restarting the mysqld instance as needed.

mysqld_safe is not used so the mysqld process will not be automatically restarted in case of a failure.

To enable communication with a vttablet, the server must be configured to receive gRPC messages on a unix domain socket. For example:

export VTDATAROOT=/tmp
mysqlctld \
  --log_dir=${VTDATAROOT}/logs \
  --tablet_uid=100 \
  --mysql_port=17100 \
  --socket_file=/path/to/socket_file

Options #

The following global parameters apply to mysqlctld:

NameTypeDefinition
--alsologtostderrbooleanlog to standard error as well as files
--app_idle_timeoutdurationIdle timeout for app connections (default 1m0s)
--app_pool_sizeintSize of the connection pool for app connections (default 40)
--catch-sigpipebooleancatch and ignore SIGPIPE on stdout and stderr if specified
--db-credentials-filestringdb credentials file; send SIGHUP to reload this file
--db-credentials-serverstringdb credentials server type (use 'file' for the file implementation) (default "file")
--db-credentials-vault-addrstringURL to Vault server
--db-credentials-vault-pathstringVault path to credentials JSON blob, e.g.: secret/data/prod/dbcreds
--db-credentials-vault-role-mountpointstringVault AppRole mountpoint; can also be passed using VAULT_MOUNTPOINT environment variable (default "approle")
--db-credentials-vault-role-secretidfilestringPath to file containing Vault AppRole secret_id; can also be passed using VAULT_SECRETID environment variable
--db-credentials-vault-roleidstringVault AppRole id; can also be passed using VAULT_ROLEID environment variable
--db-credentials-vault-timeoutdurationTimeout for vault API operations (default 10s)
--db-credentials-vault-tls-castringPath to CA PEM for validating Vault server certificate
--db-credentials-vault-tokenfilestringPath to file containing Vault auth token; token can also be passed using VAULT_TOKEN environment variable
--db-credentials-vault-ttldurationHow long to cache DB credentials from the Vault server (default 30m0s)
--db_charsetstringCharacter set. Only utf8 or latin1 based character sets are supported.
--db_conn_query_infobooleanenable parsing and processing of QUERY_OK info fields
--db_connect_timeout_msintconnection timeout to mysqld in milliseconds (0 for no timeout)
--db_dba_passwordstringdb dba password
--db_dba_use_sslbooleanSet this flag to false to make the dba connection to not use ssl (default true)
--db_dba_userstringdb dba user userKey (default "vt_dba")
--db_flagsuintFlag values as defined by MySQL.
--db_flavorstringFlavor overrid. Valid value is FilePos.
--db_hoststringThe host name for the tcp connection.
--db_portinttcp port
--db_server_namestringserver name of the DB we are connecting to.
--db_socketstringThe unix socket to connect on. If this is specified, host and port will not be used.
--db_ssl_castringconnection ssl ca
--db_ssl_ca_pathstringconnection ssl ca path
--db_ssl_certstringconnection ssl certificate
--db_ssl_keystringconnection ssl key
--db_ssl_modestringSSL mode to connect with. One of disabled, preferred, required, verify_ca & verify_identity.
--db_tls_min_versionstringConfigures the minimal TLS version negotiated when SSL is enabled. Defaults to TLSv1.2. Options: TLSv1.0, TLSv1.1, TLSv1.2, TLSv1.3.
--dba_idle_timeoutdurationIdle timeout for dba connections (default 1m0s)
--dba_pool_sizeintSize of the connection pool for dba connections (default 20)
--grpc_auth_modestringWhich auth plugin implementation to use (eg: static)
--grpc_auth_mtls_allowed_substringsstringList of substrings of at least one of the client certificate names (separated by colon).
--grpc_auth_static_client_credsstringWhen using grpc_static_auth in the server, this file provides the credentials to use to authenticate with server.
--grpc_auth_static_password_filestringJSON File to read the users/passwords from.
--grpc_castringserver CA to use for gRPC connections, requires TLS, and enforces client certificate check
--grpc_certstringserver certificate to use for gRPC connections, requires grpc_key, enables TLS
--grpc_compressionstringWhich protocol to use for compressing gRPC. Default: nothing. Supported: snappy
--grpc_crlstringpath to a certificate revocation list in PEM format, client certificates will be further verified against this file during TLS handshake
--grpc_enable_optional_tlsbooleanenable optional TLS mode when a server accepts both TLS and plain-text connections on the same port
--grpc_initial_conn_window_sizeintgRPC initial connection window size
--grpc_initial_window_sizeintgRPC initial window size
--grpc_keepalive_timedurationAfter a duration of this time, if the client doesn't see any activity, it pings the server to see if the transport is still alive. (default 10s)
--grpc_keepalive_timeoutdurationAfter having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that the connection is closed. (default 10s)
--grpc_keystringserver private key to use for gRPC connections, requires grpc_cert, enables TLS
--grpc_max_connection_agedurationMaximum age of a client connection before GoAway is sent. (default 2562047h47m16.854775807s)
--grpc_max_connection_age_gracedurationAdditional grace period after grpc_max_connection_age, after which connections are forcibly closed. (default 2562047h47m16.854775807s)
--grpc_portintPort to listen on for gRPC calls. If zero, do not listen.
--grpc_server_castringpath to server CA in PEM format, which will be combine with server cert, return full certificate chain to clients
--grpc_server_initial_conn_window_sizeintgRPC server initial connection window size
--grpc_server_initial_window_sizeintgRPC server initial window size
--grpc_server_keepalive_enforcement_policy_min_timedurationgRPC server minimum keepalive time (default 10s)
--grpc_server_keepalive_enforcement_policy_permit_without_streambooleangRPC server permit client keepalive pings even when there are no active streams (RPCs)
-h, --helpdisplay usage and exit
--init_db_sql_filestringPath to .sql file to run after mysqld initialization
--keep_logsdurationkeep logs for this long (using ctime) (zero to keep forever)
--keep_logs_by_mtimedurationkeep logs for this long (using mtime) (zero to keep forever)
--lameduck-perioddurationkeep running at least this long after SIGTERM before stopping (default 50ms)
--log_backtrace_atvaluewhen logging hits line file:N, emit a stack trace
--log_dirstringIf non-empty, write log files in this directory
--log_err_stacksbooleanlog stack traces for errors
--log_rotate_max_sizeuintsize in bytes at which logs are rotated (glog.MaxSize) (default 1887436800)
--logtostderrbooleanlog to standard error instead of files
--max-stack-sizeintconfigure the maximum stack size in bytes (default 67108864)
--mysql_portintmysql port (default 3306)
--mysql_server_versionstringMySQL server version to advertise.
--mysql_server_flush_delaydurationDelay after which buffered response will be flushed to the client. (default 100ms)
--mysql_socketstringpath to the mysql socket
--mysqlctl_mycnf_templatestringtemplate file to use for generating the my.cnf file during server init
--mysqlctl_socketstringsocket file to use for remote mysqlctl actions (empty for local actions)
--mysqlctl_client_protocolstringthe protocol to use to talk to the mysqlctl server (default "grpc")
--mysqlctl_mycnf_templatestringtemplate file to use for generating the my.cnf file during server init
--mysqlctl_socketstringsocket file to use for remote mysqlctl actions (empty for local actions)
--onclose_timeoutdurationwait no more than this for OnClose handlers before stopping (default 10s)
--onterm_timeoutdurationwait no more than this for OnTermSync handlers before stopping (default 10s)
--pid_filestringIf set, the process will write its pid to the named file, and delete it on graceful shutdown.
--pool_hostname_resolve_intervaldurationif set force an update to all hostnames and reconnect if changed, defaults to 0 (disabled)
--portintvttablet port (default 6612)
--pprofstringsenable profiling
--purge_logs_intervaldurationhow often try to remove old logs (default 1h0m0s)
--replication_connect_retrydurationhow long to wait in between replica reconnect attempts. Only precise to the second. (default 10s)
--security_policystringthe name of a registered security policy to use for controlling access to URLs - empty means allow all for anyone (built-in policies: deny-all, read-only)
--service_mapvaluecomma separated list of services to enable (or disable if prefixed with '-') Example: grpc-queryservice
--socket_filestringLocal unix socket file to listen on
--stderrthresholdvaluelogs at or above this threshold go to stderr (default 1)
--tablet_dirstringThe directory within the vtdataroot to store vttablet/mysql files. Defaults to being generated by the tablet uid.
--tablet_uiduintTablet UID (default 41983)
--vvaluelog level for V logs
-v, --versionbooleanprint binary version
--vmodulestringcomma-separated list of pattern=N settings for file-filtered logging
--wait_timedurationHow long to wait for mysqld startup or shutdown (default 5m0s)

mysqlctld