Skip to content

Commit 764a10a

Browse files
grooverdanhgxl64
authored andcommitted
MDEV-11670: mariadb@.service remove alias, clean up documentation/order
1 parent 6e5c246 commit 764a10a

File tree

1 file changed

+62
-36
lines changed

1 file changed

+62
-36
lines changed

support-files/mariadb@.service.in

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,36 @@
22
#
33
# Use this if you run multiple instances of MariaDB on a single server.
44
#
5+
# This systemd service is not suitable for Galera as specialised SST recovery
6+
# scripts are needed.
7+
#
8+
#
59
# Copyright notice:
610
#
711
# This file is free software; you can redistribute it and/or modify it
812
# under the terms of the GNU Lesser General Public License as published by
913
# the Free Software Foundation; either version 2.1 of the License, or
1014
# (at your option) any later version.
1115
#
16+
#
1217
# MULTI INSTANCES
1318
#
1419
# When multiple instances of MariaDB are running on a server they need to
1520
# ensure that they don't conflict with each other. This includes elements
16-
# like network ports, sockets and data directories. The systemd environment
17-
# variable MYSQLD_MULTI_INSTANCE controls each instance to ensure it is
18-
# run independently.
19-
#
20-
# This is not suitable for Galera as specialised SST recovery scripts are
21-
# needed.
22-
#
23-
# Suffix Mechanism (default):
24-
#
25-
# MYSQLD_MULTI_INSTANCE=--defaults-group-suffix=.%I --basedir=@prefix@
26-
#
27-
# With this option, the [mysqld.{instancename}] group is read from the default
28-
# configuration file.
29-
#
30-
# Command Line Mechanism:
31-
#
32-
# MYSQLD_MULTI_INSTANCE="--socket=/var/run/mysqld/%I.sock \
33-
# --datadir=/var/lib/mysqld-multi/%I \
34-
# --skip-networking"
35-
#
36-
# This is a good way run multiple instance where there is little difference
37-
# in configuration between instances.
21+
# like network ports, sockets and data directories listed under CONFLICTING
22+
# VARIABLES below. The systemd environment variable MYSQLD_MULTI_INSTANCE
23+
# controls each instance to ensure it is run independently. It is passed to
24+
# mysqld and mysql_install
3825
#
39-
# Configuration File Based Mechanism:
26+
# By default, a group suffix exists andw ithin the default configuration
27+
# files, a group [mysqld.{instancename}] is read for each service. Other
28+
# default groups, like [server.{instancename}] and [mariadb.{instancename}],
29+
# are also read. For each instance, one of the groups will need to contain
30+
# the conflicting variables listed below under CONFLICTING VARIABLES.
4031
#
41-
# MYSQLD_MULTI_INSTANCE=@sysconfdir@/my%I.cnf
32+
# The MYSQLD_MULTI_INSTANCE environment used is:
33+
# Environment='MYSQLD_MULTI_INSTANCE=--defaults-group-suffix=.%I --basedir=@prefix@'
4234
#
43-
# Here you need to create a file for each instance. Recommend the systemd
44-
# configuration "ConditionPathExists=@sysconf@/my%I.cnf" at the same time to
45-
# ensure the file exists for the instance before starting.
4635
#
4736
# APPLYING YOUR MULTI INSTANCE MECHANISM
4837
#
@@ -55,18 +44,53 @@
5544
# Include any other settings you which to override. Directives like Exec* are
5645
# lists and adding a directive will append to the list. You can clear the list
5746
# by starting with "Directive=" and no value. Follow this by the list that you
58-
# do want.
47+
# do want. See the systemd.unit(5) manual page for more information.
5948
#
6049
# Then run "systemctl daemon-reload".
6150
#
62-
# Multi User Based Mechanism
51+
#
52+
# EXAMPLE MYSQLD_MULTI_INSTANCE CONFIGURATIONS
53+
#
54+
# Configuration File Based Mechanism:
55+
#
56+
# This has a configuration file per instance.
57+
#
58+
# [Unit]
59+
# ConditionPathExists=@sysconfdir@/my.%I.cnf
60+
#
61+
# [Service]
62+
# Environment=MYSQLD_MULTI_INSTANCE=--defaults-file=@sysconfdir@/my.%I.cnf
63+
#
64+
# Here you need to create a configuration file @sysconfdir@/my.%I.cnf for each
65+
# instance, each containing the conflicting variables to separate instances.
66+
#
67+
#
68+
# Multi User Based Mechanism:
69+
#
70+
# Here each user (the instance name) has their own mysql instance.
6371
#
6472
# Create instances in users home directory with abstract socket:
6573
#
6674
# [Service]
6775
# User=%I
6876
# ProtectHome=false
69-
# Environment=MYSQLD_MULTI_INSTANCE="--defaults-file=/home/%I/my%I.cnf --datadir=/home/%I/mysqldatadir --skip-networking --socket=@mysql-%I"
77+
# ExecStartPre=
78+
# ExecStartPre=@scriptdir@/mysql_install_db $MYSQLD_MULTI_INSTANCE \
79+
# --auth-root-authentication-method=socket --auth-root-socket-user=%I
80+
# Environment=MYSQLD_MULTI_INSTANCE="--defaults-file=/home/%I/my%I.cnf \
81+
# --datadir=/home/%I/mysqldatadir --skip-networking --socket=@mysql-%I"
82+
#
83+
#
84+
# Command Line Mechanism:
85+
#
86+
# This is a good way run multiple instance where there is little difference
87+
# in configuration between instances.
88+
#
89+
# [Service]
90+
# Environment=MYSQLD_MULTI_INSTANCE="--socket=/var/run/mysqld/%I.sock \
91+
# --datadir=/var/lib/mysqld-multi/%I \
92+
# --skip-networking"
93+
#
7094
#
7195
# CONFLICTING VARIABLES
7296
#
@@ -76,6 +100,7 @@
76100
# * port
77101
# * datadir
78102
#
103+
#
79104
# PRE-10.3
80105
#
81106
# Before 10.3 MYSQLD_MULTI_INSTANCE was effectively --defaults-file=@sysconf2dir@/my%I.cnf
@@ -84,17 +109,20 @@
84109
# continue a file based multi-instance mysqld, recommend the Configuration File
85110
# Based Mechanism above and moving @sysconf2dir@/my%I.cnf files to @sysconfdir@/my%I.cnf.
86111
#
112+
#
87113
# SELINUX
88114
#
89115
# As basic selinux rules are written around a single instance of MariaDB you may need
90116
# to define labels for the files and network ports of all instances.
91117
#
92118
# See: https://mariadb.com/kb/en/library/what-to-do-if-mariadb-doesnt-start/#selinux
93119
#
120+
#
94121
# STARTING
95122
#
96123
# Start the instance: systemctl start mariadb@{instancename}.service
97124
#
125+
#
98126
# DOCUMENTATION:
99127
#
100128
# Read https://mariadb.com/kb/en/mariadb/systemd/ regarding customisation.
@@ -108,22 +136,20 @@ Documentation=man:mysqld(8)
108136
Documentation=https://mariadb.com/kb/en/library/systemd/
109137
After=network.target
110138

111-
# Negated condition here is because 10.2 had @sysconf2dir@/my%I.cnf
139+
# Negated condition here is because 10.3 and before had @sysconf2dir@/my%I.cnf
112140
# as the configuration difference for multiple instances. This condition here
113141
# to prevent an accidental change during an upgrade in the case the user
114142
# created these file(s).
115143
#
116144
## See Environment=MYSQLD_MULTI_INSTANCE below for current recommended options.
117145
ConditionPathExists=!@sysconf2dir@/my%I.cnf
118146

147+
119148
[Install]
120149
WantedBy=multi-user.target
121-
Alias=mysql.service
122-
Alias=mysqld.service
123150

124151

125152
[Service]
126-
127153
##############################################################################
128154
## Core requirements
129155
##
@@ -198,12 +224,12 @@ UMask=007
198224
PrivateTmp=false
199225

200226
# Controlling how multiple instances are separated. See top of this file.
201-
# Note 1: This service isn't User=mysql be default so we need to be explicit.
227+
# Note 1: This service isn't User=mysql by default so we need to be explicit.
202228
# Note 2: we set --basedir to prevent probes that might trigger SELinux alarms,
203229
# per bug https://bugzilla.redhat.com/show_bug.cgi?id=547485. Its as an option
204230
# here as a user may want to use the MYSQLD_MULTI_INSTANCE to run multiple
205231
# versions.
206-
Environment=MYSQLD_MULTI_INSTANCE=--defaults-group-suffix=.%I --basedir=@prefix@
232+
Environment='MYSQLD_MULTI_INSTANCE=--defaults-group-suffix=.%I --basedir=@prefix@'
207233

208234
# While you can override these, you shouldn't leave them empty as that
209235
# will default to root.

0 commit comments

Comments
 (0)