MDEV-427/MDEV-5713 Add systemd script with notify functionality

This commit is contained in:
Daniel Black 2015-09-17 22:16:19 +10:00 committed by Sergey Vojtovich
commit 20c2ae39db
23 changed files with 551 additions and 15 deletions

View file

@ -76,7 +76,23 @@ 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
)
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

View file

@ -0,0 +1,16 @@
#
# Install as /etc/systemd/system/mariadb@bootstrap.service.d/wsrep-new-cluster.conf
#
# This uses the multi instance version as a base.
#
[Unit]
ConditionPathExists=
[Service]
# Override the multi instance service for a bootstrap start instance
ExecStart=
ExecStart=/usr/sbin/mysqld $EXTRA_ARGS --wsrep-new-cluster

View file

@ -0,0 +1,120 @@
#
# /etc/systemd/system/mariadb.service
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Thanks to:
# Daniel Black
# Erkan Yanar
# David Strauss
# and probably others
[Unit]
Description=MariaDB database server
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=mysql.service
Alias=mysqld.service
[Service]
##############################################################################
## Core requirements
##
Type=notify
# Setting this to true can break replication and the Type=notify settings
PrivateNetwork=false
##############################################################################
## Package maintainers
##
User=mysql
# Execute pre and post scripts as root, otherwise it does it as User=
# PermissionsStartOnly=true
# Needed to create system tables etc.
# 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=...".
# This isn't a replacement for my.cnf.
ExecStart=/usr/sbin/mysqld $EXTRA_ARGS
KillMode=process
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
RestartSec=5s
PrivateDevices=true
UMask=077
##############################################################################
## USERs can override
##
##
## by creating a file in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf
## and adding/setting the following will override this file's settings.
# Useful options not previously available in [mysqld_safe]
# Kernels like killing mysqld when out of memory because its big.
# Lets temper that preference a little.
OOMScoreAdjust=-600
# Explicitly start with high IO priority
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.
PrivateTmp=false
##
## Options previously available to be set via [mysqld_safe]
## that now needs to be set by systemd config files as mysqld_safe
## isn't executed.
##
# Number of files limit. previously [mysqld_safe] open-file-limit
LimitNOFILE=16364
# Maximium core size. previously [mysqld_safe] core-file-size
# LimitCore=
# Nice priority. previously [mysqld_safe] nice
# Nice=-5
# Timezone. previously [mysqld_safe] timezone
# Environment="TZ=UTC"
# Library substitutions. previously [mysqld_safe] malloc-lib with explict paths
# (in LD_LIBRARY_PATH) and library name (in LD_PRELOAD).
# Environment="LD_LIBRARY_PATH=/path1 /path2" "LD_PRELOAD=
# Flush caches. previously [mysqld_safe] flush-caches=1
# ExecStartPre=sync
# ExecStartPre=sysctl -q -w vm.drop_caches=3
# numa-interleave=1 equalivant
# Change ExecStart=numactl --interleave=all /usr/sbin/mysqld......
# crash-script equalivent
# FailureAction=

View file

@ -0,0 +1,133 @@
# Multi instance version of mariadb. For if you run mutiple verions at once.
# Also used for mariadb@bootstrap to bootstrap Galera.
#
# create config file @INSTALL_SYSCONF2DIR@/my{instancename}.cnf
#
# start as systemctl start mariadb@{instancename}.server
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Thanks to:
# Daniel Black
# Erkan Yanar
# David Strauss
# and probably others
# Inspired from https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mysql-init-scripts/files/mysqld_at.service
[Unit]
Description=MariaDB database server
After=network.target
After=syslog.target
ConditionPathExists=@INSTALL_SYSCONF2DIR@/my%I.cnf
[Install]
WantedBy=multi-user.target
Alias=mysql.service
Alias=mysqld.service
[Service]
##############################################################################
## Core requirements
##
Type=notify
# Setting this to true can break replication and the Type=notify settings
PrivateNetwork=false
##############################################################################
## Package maintainers
##
User=mysql
# Execute pre and post scripts as root, otherwise it does it as User=
# PermissionsStartOnly=true
# Needed to create system tables etc.
# 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=...".
# This isn't a replacement for my.cnf.
ExecStart=
ExecStart=/usr/sbin/mysqld $EXTRA_ARGS --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
KillMode=process
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
RestartSec=5s
PrivateDevices=true
UMask=077
##############################################################################
## USERs can override
##
##
## by creating a file in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf
## and adding/setting the following will override this file's settings.
# Useful options not previously available in [mysqld_safe]
# Kernels like killing mysqld when out of memory because its big.
# Lets temper that preference a little.
OOMScoreAdjust=-600
# Explicitly start with high IO priority
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.
PrivateTmp=false
##
## Options previously available to be set via [mysqld_safe]
## that now needs to be set by systemd config files as mysqld_safe
## isn't executed.
##
# Number of files limit. previously [mysqld_safe] open-file-limit
LimitNOFILE=16364
# Maximium core size. previously [mysqld_safe] core-file-size
# LimitCore=
# Nice priority. previously [mysqld_safe] nice
# Nice=-5
# Timezone. previously [mysqld_safe] timezone
# Environment="TZ=UTC"
# Library substitutions. previously [mysqld_safe] malloc-lib with explict paths
# (in LD_LIBRARY_PATH) and library name (in LD_PRELOAD).
# Environment="LD_LIBRARY_PATH=/path1 /path2" "LD_PRELOAD=
# Flush caches. previously [mysqld_safe] flush-caches=1
# ExecStartPre=sync
# ExecStartPre=sysctl -q -w vm.drop_caches=3
# numa-interleave=1 equalivant
# Change ExecStart=numactl --interleave=all /usr/sbin/mysqld......
# crash-script equalivent
# FailureAction=

View file

@ -1,6 +1,12 @@
# Make MySQL start/shutdown automatically when the machine does it.
if [ $1 = 1 ] ; 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}"
fi
if [ -x /usr/bin/systemctl ] ; then
/usr/bin/systemctl daemon-reload >/dev/null 2>&1
fi