summaryrefslogtreecommitdiff
path: root/support-files
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2015-09-28 15:08:09 +0400
committerSergey Vojtovich <svoj@mariadb.org>2015-10-12 17:51:49 +0200
commit6346d1de2fdaa8a8359082871eac49402cb0e472 (patch)
tree62a057a2b8ab0b24bc242461522017e333fe741f /support-files
parent20c2ae39db3dd0ec4c337a9b0bd2bf4481b61e49 (diff)
downloadmariadb-git-6346d1de2fdaa8a8359082871eac49402cb0e472.tar.gz
MDEV-427/MDEV-5713 Add systemd script with notify functionality
After review/QA fixes.
Diffstat (limited to 'support-files')
-rw-r--r--support-files/CMakeLists.txt40
-rw-r--r--support-files/mariadb.service.in (renamed from support-files/mariadb.service)26
-rw-r--r--support-files/mariadb@.service.in26
-rw-r--r--support-files/mysql.server.sh5
-rw-r--r--support-files/rpm/server-postin.sh20
-rw-r--r--support-files/wsrep-new-cluster.conf (renamed from support-files/mariadb-bootstrap.conf)2
6 files changed, 73 insertions, 46 deletions
diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt
index 88fdf13bc3b..c357528954f 100644
--- a/support-files/CMakeLists.txt
+++ b/support-files/CMakeLists.txt
@@ -76,23 +76,35 @@ IF(UNIX)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mysql.server
DESTINATION ${inst_location} COMPONENT SupportFiles)
- IF(SYSTEMD_SYSTEM_UNITDIR)
- CONFIGURE_FILE(mariadb@.service.in ${CMAKE_CURRENT_BINARY_DIR}/mariadb@.service @ONLY)
- # @ in directory name broken between CMake version 2.8.12.2 and 3.3
- # http://public.kitware.com/Bug/view.php?id=14782
- INSTALL(FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/mariadb-bootstrap.conf
- DESTINATION "${SYSTEMD_SYSTEM_UNITDIR}/mariadb@bootstrap.service.d" COMPONENT Server
- )
- INSTALL(FILES
- ${CMAKE_CURRENT_BINARY_DIR}/mariadb@.service
- ${CMAKE_CURRENT_SOURCE_DIR}/mariadb.service
- DESTINATION ${SYSTEMD_SYSTEM_UNITDIR} COMPONENT Server
- )
+ IF(HAVE_SYSTEMD)
+ CONFIGURE_FILE(mariadb.service.in
+ ${CMAKE_CURRENT_BINARY_DIR}/mariadb.service @ONLY)
+ IF(NOT RPM)
+ CONFIGURE_FILE(mariadb@.service.in
+ ${CMAKE_CURRENT_BINARY_DIR}/mariadb@.service @ONLY)
+ INSTALL(FILES wsrep-new-cluster.conf
+ ${CMAKE_CURRENT_BINARY_DIR}/mariadb.service
+ ${CMAKE_CURRENT_BINARY_DIR}/mariadb@.service
+ DESTINATION ${inst_location}/systemd COMPONENT SupportFiles)
+ ENDIF()
+ IF(INSTALL_SYSTEMD_UNITDIR)
+ # @ in directory name broken between CMake version 2.8.12.2 and 3.3
+ # http://public.kitware.com/Bug/view.php?id=14782
+ IF(NOT RPM)
+ INSTALL(FILES wsrep-new-cluster.conf
+ DESTINATION
+ "${INSTALL_SYSTEMD_UNITDIR}/mariadb@bootstrap.service.d"
+ COMPONENT Server)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb@.service
+ DESTINATION ${INSTALL_SYSTEMD_UNITDIR} COMPONENT Server)
+ ENDIF()
+
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.service
+ DESTINATION ${INSTALL_SYSTEMD_UNITDIR} COMPONENT Server)
+ ENDIF()
ENDIF()
IF (INSTALL_SYSCONFDIR)
-
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-rotate DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d
RENAME mysql COMPONENT SupportFiles)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mysql.server
diff --git a/support-files/mariadb.service b/support-files/mariadb.service.in
index 071d4bab745..a40b3e18e27 100644
--- a/support-files/mariadb.service
+++ b/support-files/mariadb.service.in
@@ -32,6 +32,7 @@ Alias=mysqld.service
Type=notify
# Setting this to true can break replication and the Type=notify settings
+# See also bind-address mysqld option.
PrivateNetwork=false
##############################################################################
@@ -39,6 +40,7 @@ PrivateNetwork=false
##
User=mysql
+Group=mysql
# Execute pre and post scripts as root, otherwise it does it as User=
# PermissionsStartOnly=true
@@ -47,10 +49,12 @@ User=mysql
# ExecStartPre=/usr/bin/mysql_install_db
# Start main service
-# EXTRA_ARGS here is for users to set in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf
-# Use the [service] section and Environment="EXTRA_ARGS=...".
+# MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf
+# Use the [service] section and Environment="MYSQLD_OPTS=...".
# This isn't a replacement for my.cnf.
-ExecStart=/usr/sbin/mysqld $EXTRA_ARGS
+@SYSTEMD_EXECSTARTPRE@
+ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS
+@SYSTEMD_EXECSTARTPOST@
KillMode=process
KillSignal=SIGTERM
@@ -58,14 +62,12 @@ KillSignal=SIGTERM
# Don't want to see an automated SIGKILL ever
SendSIGKILL=no
-# Exit status 1 is a fatal config error. Restarting won't help.
-RestartPreventExitStatus=1
-Restart=on-failure
+# Restart crashed server only, on-failure would also restart, for example, when
+# my.cnf contains unknown option
+Restart=on-abort
RestartSec=5s
-PrivateDevices=true
-
-UMask=077
+UMask=007
##############################################################################
## USERs can override
@@ -78,10 +80,10 @@ UMask=077
# Kernels like killing mysqld when out of memory because its big.
# Lets temper that preference a little.
-OOMScoreAdjust=-600
+# OOMScoreAdjust=-600
# Explicitly start with high IO priority
-BlockIOWeight=1000
+# BlockIOWeight=1000
# If you don't use the /tmp directory for SELECT ... OUTFILE and
# LOAD DATA INFILE you can enable PrivateTmp=true for a little more security.
@@ -94,7 +96,7 @@ PrivateTmp=false
##
# Number of files limit. previously [mysqld_safe] open-file-limit
-LimitNOFILE=16364
+# LimitNOFILE=16364
# Maximium core size. previously [mysqld_safe] core-file-size
# LimitCore=
diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in
index bfcc71a8d40..b8ef969cf32 100644
--- a/support-files/mariadb@.service.in
+++ b/support-files/mariadb@.service.in
@@ -39,6 +39,7 @@ Alias=mysqld.service
Type=notify
# Setting this to true can break replication and the Type=notify settings
+# See also bind-address mysqld option.
PrivateNetwork=false
##############################################################################
@@ -46,6 +47,7 @@ PrivateNetwork=false
##
User=mysql
+Group=mysql
# Execute pre and post scripts as root, otherwise it does it as User=
# PermissionsStartOnly=true
@@ -54,16 +56,16 @@ User=mysql
# ExecStartPre=/usr/bin/mysql_install_db
# Start main service
-# EXTRA_ARGS here is for users to set in /etc/systemd/system/mariadb@.service.d/MY_SPECIAL.conf
-# Use the [service] section and Environment="EXTRA_ARGS=...".
+# MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb@.service.d/MY_SPECIAL.conf
+# Use the [service] section and Environment="MYSQLD_OPTS=...".
# This isn't a replacement for my.cnf.
ExecStart=
-ExecStart=/usr/sbin/mysqld $EXTRA_ARGS --defaults-file=@INSTALL_SYSCONF2DIR@/my%I.cnf
+ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS --defaults-file=@INSTALL_SYSCONF2DIR@/my%I.cnf
# Alternate: (remove ConditionPathExists above)
# use [mysqld.INSTANCENAME] as sections in my.cnf
#
-# ExecStart=/usr/sbin/mysqld $EXTRA_ARGS --defaults-group-suffix=%I
+# ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS --defaults-group-suffix=%I
KillMode=process
KillSignal=SIGTERM
@@ -71,14 +73,12 @@ KillSignal=SIGTERM
# Don't want to see an automated SIGKILL ever
SendSIGKILL=no
-# Exit status 1 is a fatal config error. Restarting won't help.
-RestartPreventExitStatus=1
-Restart=on-failure
+# Restart crashed server only, on-failure would also restart, for example, when
+# my.cnf contains unknown option
+Restart=on-abort
RestartSec=5s
-PrivateDevices=true
-
-UMask=077
+UMask=007
##############################################################################
## USERs can override
@@ -91,10 +91,10 @@ UMask=077
# Kernels like killing mysqld when out of memory because its big.
# Lets temper that preference a little.
-OOMScoreAdjust=-600
+# OOMScoreAdjust=-600
# Explicitly start with high IO priority
-BlockIOWeight=1000
+# BlockIOWeight=1000
# If you don't use the /tmp directory for SELECT ... OUTFILE and
# LOAD DATA INFILE you can enable PrivateTmp=true for a little more security.
@@ -107,7 +107,7 @@ PrivateTmp=false
##
# Number of files limit. previously [mysqld_safe] open-file-limit
-LimitNOFILE=16364
+# LimitNOFILE=16364
# Maximium core size. previously [mysqld_safe] core-file-size
# LimitCore=
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index c6a1db11935..385feaf75a5 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -97,6 +97,11 @@ lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
. $lsb_functions
else
+ # Include non-LSB RedHat init functions to make systemctl redirect work
+ init_functions="/etc/init.d/functions"
+ if test -f $init_functions; then
+ . $init_functions
+ fi
log_success_msg()
{
echo " SUCCESS! $@"
diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh
index 253350512ae..5b95b751212 100644
--- a/support-files/rpm/server-postin.sh
+++ b/support-files/rpm/server-postin.sh
@@ -1,12 +1,20 @@
-
-# Make MySQL start/shutdown automatically when the machine does it.
-if [ $1 = 1 ] ; then
+if [ -f /usr/lib/systemd/system/mariadb.service -a -x /usr/bin/systemctl ]; then
systemd_conf=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
- if [ -x /usr/bin/mariadb-service-convert -a ! -f "${systemd_conf}" ]; then
- mkdir -p /etc/systemd/system/mariadb.service.d
- /usr/bin/mariadb-service-convert > "${systemd_conf}"
+ if [ -x %{_bindir}/mariadb-service-convert -a ! -f "${systemd_conf}" ]; then
+ # Either fresh install or upgrade non-systemd -> systemd
+ mkdir -p /etc/systemd/system/mariadb.service.d
+ %{_bindir}/mariadb-service-convert > "${systemd_conf}"
+ # Make sure old possibly non-systemd instance is down
+ if [ $1 = 2 ]; then
+ SYSTEMCTL_SKIP_REDIRECT=1 %{_sysconfdir}/init.d/mysql stop >/dev/null 2>&1 || :
+ systemctl start mariadb >/dev/null 2>&1 || :
+ fi
+ systemctl enable mariadb.service >/dev/null 2>&1 || :
fi
+fi
+# Make MySQL start/shutdown automatically when the machine does it.
+if [ $1 = 1 ] ; then
if [ -x /usr/bin/systemctl ] ; then
/usr/bin/systemctl daemon-reload >/dev/null 2>&1
fi
diff --git a/support-files/mariadb-bootstrap.conf b/support-files/wsrep-new-cluster.conf
index 2ee42b477ba..a71b26ae788 100644
--- a/support-files/mariadb-bootstrap.conf
+++ b/support-files/wsrep-new-cluster.conf
@@ -12,5 +12,5 @@ ConditionPathExists=
# Override the multi instance service for a bootstrap start instance
ExecStart=
-ExecStart=/usr/sbin/mysqld $EXTRA_ARGS --wsrep-new-cluster
+ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS --wsrep-new-cluster