mirror of
https://github.com/MariaDB/server.git
synced 2026-05-10 00:54:30 +02:00
MDEV-427/MDEV-5713 Add systemd script with notify functionality
After review/QA fixes.
This commit is contained in:
parent
20c2ae39db
commit
6346d1de2f
19 changed files with 164 additions and 113 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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=
|
||||
|
|
@ -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=
|
||||
|
|
|
|||
|
|
@ -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! $@"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,20 @@
|
|||
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 %{_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
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue