Skip to content

Commit 91f1694

Browse files
grooverdanhgxl64
authored andcommitted
systemd: multi-instance not for Galera, User/Group flexible
By removing Galera functionality, we remove PermissionsStartOnly=true and hence make this service more flexible for running multiple instances each on a different user.
1 parent 3a0a570 commit 91f1694

File tree

1 file changed

+26
-33
lines changed

1 file changed

+26
-33
lines changed

support-files/mariadb@.service.in

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
# variable MYSQLD_MULTI_INSTANCE controls each instance to ensure it is
1818
# run independently.
1919
#
20+
# This is not suitable for Galera as specialised SST recovery scripts are
21+
# needed.
22+
#
2023
# Suffix Mechanism (default):
2124
#
22-
# MYSQLD_MULTI_INSTANCE=--defaults-group-suffix=.%I
25+
# MYSQLD_MULTI_INSTANCE=--defaults-group-suffix=.%I --basedir=@prefix@
2326
#
2427
# With this option, the [mysqld.{instancename}] group is read from the default
2528
# configuration file.
@@ -56,6 +59,15 @@
5659
#
5760
# Then run "systemctl daemon-reload".
5861
#
62+
# Multi User Based Mechanism
63+
#
64+
# Create instances in users home directory with abstract socket:
65+
#
66+
# [Service]
67+
# User=%I
68+
# ProtectHome=false
69+
# Environment=MYSQLD_MULTI_INSTANCE="--defaults-file=/home/%I/my%I.cnf --datadir=/home/%I/mysqldatadir --skip-networking --socket=@mysql-%I"
70+
#
5971
# CONFLICTING VARIABLES
6072
#
6173
# A number of MariaDB system variables may conflict. The main ones that need to
@@ -64,11 +76,6 @@
6476
# * port
6577
# * datadir
6678
#
67-
# Galera will require:
68-
# * wsrep_node_address
69-
# * wsrep_cluster_address
70-
# * ensure SST mechanisms don't conflict on network ports or temporary locations
71-
#
7279
# PRE-10.3
7380
#
7481
# Before 10.3 MYSQLD_MULTI_INSTANCE was effectively --defaults-file=@sysconf2dir@/my%I.cnf
@@ -131,9 +138,6 @@ PrivateNetwork=false
131138
## Package maintainers
132139
##
133140

134-
User=mysql
135-
Group=mysql
136-
137141
# To allow memlock to be used as non-root user if set in configuration
138142
CapabilityBoundingSet=CAP_IPC_LOCK
139143

@@ -149,37 +153,16 @@ PrivateDevices=true
149153
# Prevent accessing /home, /root and /run/user
150154
ProtectHome=true
151155

152-
# Execute pre and post scripts as root, otherwise it does it as User=
153-
PermissionsStartOnly=true
154-
155-
# Perform automatic wsrep recovery. When server is started without wsrep,
156-
# galera_recovery simply returns an empty string. In any case, however,
157-
# the script is not expected to return with a non-zero status.
158-
# It is always safe to unset _WSREP_START_POSITION%I environment variable.
159-
# Do not panic if galera_recovery script is not available. (MDEV-10538)
160-
ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION%I"
161-
162-
ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \
163-
VAR=`@bindir@/galera_recovery $MYSQLD_MULTI_INSTANCE`; [ $? -eq 0 ] \
164-
&& systemctl set-environment _WSREP_START_POSITION%I=$VAR || exit 1"
165-
166156
# Needed to create system tables etc.
167-
ExecStartPre=@scriptdir@/mysql_install_db $MYSQLD_MULTI_INSTANCE --user=mysql
157+
ExecStartPre=@scriptdir@/mysql_install_db $MYSQLD_MULTI_INSTANCE
168158

169159
# Start main service
170160
# A few variables are here:
171161
# * MYSQLD_MULTI_INSTANCE - control how multiple instances are distinguisable
172-
# * _WSREP_NEW_CLUSTER - for the exclusive use of the script galera_new_cluster
173162
# * MYSQLD_OPTS - user definable extras - not a replacement for my.cnf
174163
#
175164
# Note 1: Place $MYSQLD_OPTS at the very end for its options to take precedence.
176-
# Note 2: we set --basedir to prevent probes that might trigger SELinux alarms,
177-
# per bug https://bugzilla.redhat.com/show_bug.cgi?id=547485
178-
ExecStart=@sbindir@/mysqld $MYSQLD_MULTI_INSTANCE --basedir=@prefix@ \
179-
$_WSREP_NEW_CLUSTER $_WSREP_START_POSITION%I $MYSQLD_OPTS
180-
181-
# Unset _WSREP_START_POSITION environment variable.
182-
ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION%I"
165+
ExecStart=@sbindir@/mysqld $MYSQLD_MULTI_INSTANCE $MYSQLD_OPTS
183166

184167
KillSignal=SIGTERM
185168

@@ -215,7 +198,17 @@ UMask=007
215198
PrivateTmp=false
216199

217200
# Controlling how multiple instances are separated. See top of this file.
218-
Environment=MYSQLD_MULTI_INSTANCE=--defaults-group-suffix=.%I
201+
# Note 1: This service isn't User=mysql be default so we need to be explicit.
202+
# Note 2: we set --basedir to prevent probes that might trigger SELinux alarms,
203+
# per bug https://bugzilla.redhat.com/show_bug.cgi?id=547485. Its as an option
204+
# here as a user may want to use the MYSQLD_MULTI_INSTANCE to run multiple
205+
# versions.
206+
Environment=MYSQLD_MULTI_INSTANCE=--defaults-group-suffix=.%I --basedir=@prefix@
207+
208+
# While you can override these, you shouldn't leave them empty as that
209+
# will default to root.
210+
User=mysql
211+
Group=mysql
219212

220213
##
221214
## Options previously available to be set via [mysqld_safe]

0 commit comments

Comments
 (0)