This commit fixes two issues:
1. A Fedora downstream one, since 11.6
(https://jira.mariadb.org/browse/MDEV-19210), MariaDB upstream use
environment files in their systemd service files to load environment
variables and pass the arguments '--wsrep-new-cluster' and
'--wsrep_start_position' when starting the daemon. The Fedora downstream
service file has been missing the variable for '--wsrep_start_position' since
it was added into MariaDB upstream in 10.1.15
(a6816995ee).
And this Fedora downstream commit adds those missing environment
variables and their arguments into the service files. After I tested
it, the recovery of failed nodes works.
2. A MariaDB upstream one, where the temporary 'wsrep' files have
incorrect SELinux policies set ('mysqld-db-t' instead of
'mysqld-run-t') because of their parent directories. This occurs
because their location is tied to the location of 'mysql.sock' in the
CMake files. As RPMs get built to have 'mysql.sock' in
'/var/lib/mysql' as opposed to inside '/run' like Debian or Arch, the
temporary files for the service could not actually be read by the
service during start-up, resulting in failure as no primary node was
ever created. Discussion with the MariaDB upstream
(https://jira.mariadb.org/browse/MDEV-37726) resulted in a patch that
separates the location of the socket file and the temporary
environment files into two CMake flags and allows for more flexible
building of the package. We use this patch temporarily until we
update to a version with it included.
105 lines
3.8 KiB
SYSTEMD
105 lines
3.8 KiB
SYSTEMD
# Multi instance version of MariaDB. For if you run mutiple verions at once.
|
|
# Also used for @DAEMON_NAME@@bootstrap to bootstrap Galera.
|
|
#
|
|
# To use multi instance variant, use [mariadbd.INSTANCENAME] as sections in
|
|
# @sysconfdir@/@my.cnf to change per instance settings. A minimumal necessary
|
|
# configuration items to change to avoid conflicts between instances is:
|
|
#
|
|
# [mariadbd.instancename]
|
|
# # TCP port to make available for clients
|
|
# port=3306
|
|
# # Socket to make available for clients
|
|
# socket=/tmp/mariadb-instancename.sock
|
|
# # Where MariaDB should store all its data
|
|
# datadir=/usr/local/mariadb-instancename/data
|
|
#
|
|
# and start the service via:
|
|
#
|
|
# root> systemctl start @DAEMON_NAME@@{instancename}.server
|
|
#
|
|
# It's not recommended to modify this file in-place, because it will be
|
|
# overwritten during package upgrades. If you want to customize, for
|
|
# all instances, the best way is:
|
|
#
|
|
# root> systemctl edit @DAEMON_NAME@@.service
|
|
#
|
|
# Then add additonal directives under a section (probably [Service]).
|
|
#
|
|
# If you only want to change a specific instance:
|
|
#
|
|
# root> systemctl edit @DAEMON_NAME@@{instancename}.server
|
|
#
|
|
# For more info about custom unit files, see systemd.unit(5) or
|
|
# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
|
|
#
|
|
# For example, if you want to increase MariaDB's open-files-limit to 10000,
|
|
# you need to increase systemd's LimitNOFILE setting, use the contents below:
|
|
#
|
|
# [Service]
|
|
# LimitNOFILE=10000
|
|
|
|
[Unit]
|
|
Description=@NICE_PROJECT_NAME@ @MAJOR_VERSION@.@MINOR_VERSION@ database server
|
|
Documentation=man:mariadbd(8)
|
|
Documentation=https://mariadb.com/kb/en/library/systemd/
|
|
After=network.target
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
Alias=mysql.service
|
|
Alias=mysqld.service
|
|
|
|
[Service]
|
|
Type=notify
|
|
User=mysql
|
|
Group=mysql
|
|
|
|
# Use an environment file to pass variable _WSREP_NEW_CLUSTER
|
|
EnvironmentFile=-@INSTALL_RUNDATADIR@/wsrep-new-cluster
|
|
# Use an environment file to pass variable _WSREP_START_POSITION
|
|
EnvironmentFile=-@INSTALL_RUNDATADIR@/wsrep-start-position
|
|
|
|
ExecStartPre=@libexecdir@/mariadb-check-socket --defaults-group-suffix=.%I
|
|
ExecStartPre=@libexecdir@/mariadb-prepare-db-dir --defaults-group-suffix=.%I %n
|
|
|
|
# Perform automatic wsrep recovery. When server is started without wsrep,
|
|
# galera_recovery simply returns an empty string. In any case, however,
|
|
# the script is not expected to return with a non-zero status.
|
|
# It is always safe to remove @INSTALL_RUNDATADIR@/wsrep-start-position
|
|
# environment file.
|
|
# Do not panic if galera_recovery script is not available. (MDEV-10538)
|
|
ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \
|
|
VAR=`@bindir@/galera_recovery`; [ $? -eq 0 ] \
|
|
&& echo _WSREP_START_POSITION=$VAR > @INSTALL_RUNDATADIR@/wsrep-start-position || exit 1"
|
|
|
|
# MYSQLD_OPTS here is for users to set in /etc/systemd/system/@DAEMON_NAME@@.service.d/MY_SPECIAL.conf
|
|
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
|
|
# per bug #547485
|
|
ExecStart=@libexecdir@/mariadbd --defaults-group-suffix=.%I --basedir=@prefix@ $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION
|
|
ExecStartPost=@libexecdir@/mariadb-check-upgrade --defaults-group-suffix=.%I
|
|
|
|
# Unset _WSREP_START_POSITION environment variable.
|
|
ExecStartPost=/bin/rm -f @INSTALL_RUNDATADIR@/wsrep-start-position
|
|
|
|
# Setting this to true can break replication and the Type=notify settings
|
|
# See also bind-address MariaDB option.
|
|
PrivateNetwork=false
|
|
|
|
KillSignal=SIGTERM
|
|
|
|
# Don't want to see an automated SIGKILL ever
|
|
SendSIGKILL=no
|
|
|
|
# Restart crashed server only, on-failure would also restart, for example, when
|
|
# my.cnf contains unknown option
|
|
Restart=on-abort
|
|
RestartSec=5s
|
|
|
|
UMask=007
|
|
|
|
# Give a reasonable amount of time for the server to start up/shut down
|
|
TimeoutSec=300
|
|
|
|
# Place temp files in a secure directory, not /tmp
|
|
PrivateTmp=true
|