2
2
#
3
3
# Use this if you run multiple instances of MariaDB on a single server.
4
4
#
5
+ # This systemd service is not suitable for Galera as specialised SST recovery
6
+ # scripts are needed.
7
+ #
8
+ #
5
9
# Copyright notice:
6
10
#
7
11
# This file is free software; you can redistribute it and/or modify it
8
12
# under the terms of the GNU Lesser General Public License as published by
9
13
# the Free Software Foundation; either version 2.1 of the License, or
10
14
# (at your option) any later version.
11
15
#
16
+ #
12
17
# MULTI INSTANCES
13
18
#
14
19
# When multiple instances of MariaDB are running on a server they need to
15
20
# 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
38
25
#
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.
40
31
#
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@'
42
34
#
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.
46
35
#
47
36
# APPLYING YOUR MULTI INSTANCE MECHANISM
48
37
#
55
44
# Include any other settings you which to override. Directives like Exec* are
56
45
# lists and adding a directive will append to the list. You can clear the list
57
46
# 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.
59
48
#
60
49
# Then run "systemctl daemon-reload".
61
50
#
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.
63
71
#
64
72
# Create instances in users home directory with abstract socket:
65
73
#
66
74
# [Service]
67
75
# User=%I
68
76
# 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
+ #
70
94
#
71
95
# CONFLICTING VARIABLES
72
96
#
76
100
# * port
77
101
# * datadir
78
102
#
103
+ #
79
104
# PRE-10.3
80
105
#
81
106
# Before 10.3 MYSQLD_MULTI_INSTANCE was effectively --defaults-file=@sysconf2dir@/my%I.cnf
84
109
# continue a file based multi-instance mysqld, recommend the Configuration File
85
110
# Based Mechanism above and moving @sysconf2dir@/my%I.cnf files to @sysconfdir@/my%I.cnf.
86
111
#
112
+ #
87
113
# SELINUX
88
114
#
89
115
# As basic selinux rules are written around a single instance of MariaDB you may need
90
116
# to define labels for the files and network ports of all instances.
91
117
#
92
118
# See: https://mariadb.com/kb/en/library/what-to-do-if-mariadb-doesnt-start/#selinux
93
119
#
120
+ #
94
121
# STARTING
95
122
#
96
123
# Start the instance: systemctl start mariadb@{instancename}.service
97
124
#
125
+ #
98
126
# DOCUMENTATION:
99
127
#
100
128
# Read https://mariadb.com/kb/en/mariadb/systemd/ regarding customisation.
@@ -108,22 +136,20 @@ Documentation=man:mysqld(8)
108
136
Documentation=https://mariadb.com/kb/en/library/systemd/
109
137
After=network.target
110
138
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
112
140
# as the configuration difference for multiple instances. This condition here
113
141
# to prevent an accidental change during an upgrade in the case the user
114
142
# created these file(s).
115
143
#
116
144
## See Environment=MYSQLD_MULTI_INSTANCE below for current recommended options.
117
145
ConditionPathExists=!@sysconf2dir@/my%I.cnf
118
146
147
+
119
148
[Install]
120
149
WantedBy=multi-user.target
121
- Alias=mysql.service
122
- Alias=mysqld.service
123
150
124
151
125
152
[Service]
126
-
127
153
##############################################################################
128
154
## Core requirements
129
155
##
@@ -198,12 +224,12 @@ UMask=007
198
224
PrivateTmp=false
199
225
200
226
# 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.
202
228
# Note 2: we set --basedir to prevent probes that might trigger SELinux alarms,
203
229
# per bug https://bugzilla.redhat.com/show_bug.cgi?id=547485. Its as an option
204
230
# here as a user may want to use the MYSQLD_MULTI_INSTANCE to run multiple
205
231
# versions.
206
- Environment=MYSQLD_MULTI_INSTANCE=--defaults-group-suffix=.%I --basedir=@prefix@
232
+ Environment=' MYSQLD_MULTI_INSTANCE=--defaults-group-suffix=.%I --basedir=@prefix@'
207
233
208
234
# While you can override these, you shouldn't leave them empty as that
209
235
# will default to root.
0 commit comments