Commit 6346d1de authored by Sergey Vojtovich's avatar Sergey Vojtovich

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

After review/QA fixes.
parent 20c2ae39
......@@ -161,6 +161,7 @@ SET(INSTALL_SUPPORTFILESDIR_RPM "share/mysql")
SET(INSTALL_MYSQLDATADIR_RPM "/var/lib/mysql")
SET(INSTALL_UNIX_ADDRDIR_RPM "${INSTALL_MYSQLDATADIR_RPM}/mysql.sock")
SET(INSTALL_SYSTEMD_UNITDIR_RPM "/usr/lib/systemd/system")
#
# DEB layout
......@@ -189,6 +190,8 @@ SET(INSTALL_SUPPORTFILESDIR_DEB "share/mysql")
SET(INSTALL_MYSQLDATADIR_DEB "/var/lib/mysql")
SET(INSTALL_UNIX_ADDRDIR_DEB "/var/run/mysqld/mysqld.sock")
SET(INSTALL_SYSTEMD_UNITDIR_DEB "/lib/systemd/system")
#
# SVR4 layout
#
......@@ -228,7 +231,8 @@ SET(OLD_INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE INTERNAL "")
# will be defined as ${INSTALL_BINDIR_STANDALONE} by default if STANDALONE
# layout is chosen)
FOREACH(var BIN SBIN LIB MYSQLSHARE SHARE PLUGIN INCLUDE SCRIPT DOC MAN SYSCONF SYSCONF2
INFO MYSQLTEST SQLBENCH DOCREADME SUPPORTFILES MYSQLDATA UNIX_ADDR)
INFO MYSQLTEST SQLBENCH DOCREADME SUPPORTFILES MYSQLDATA UNIX_ADDR
SYSTEMD_UNIT)
SET(INSTALL_${var}DIR ${INSTALL_${var}DIR_${INSTALL_LAYOUT}}
CACHE STRING "${var} installation directory" ${FORCE})
MARK_AS_ADVANCED(INSTALL_${var}DIR)
......
......@@ -22,9 +22,9 @@ MACRO(CHECK_SYSTEMD)
IF(WITH_SYSTEMD STREQUAL "yes" OR WITH_SYSTEMD STREQUAL "auto")
IF(PKG_CONFIG_FOUND)
IF(WITH_SYSTEMD STREQUAL "yes")
pkg_check_modules(LIBSYSTEMD REQUIRED libsystemd)
pkg_search_module(LIBSYSTEMD REQUIRED libsystemd libsystemd-daemon)
ELSE()
pkg_check_modules(LIBSYSTEMD libsystemd)
pkg_search_module(LIBSYSTEMD libsystemd libsystemd-daemon)
ENDIF()
IF(HAVE_DLOPEN)
SET(LIBSYSTEMD ${LIBSYSTEMD_LIBRARIES})
......@@ -51,17 +51,23 @@ MACRO(CHECK_SYSTEMD)
CHECK_FUNCTION_EXISTS(sd_listen_fds HAVE_SYSTEMD_SD_LISTEN_FDS)
CHECK_FUNCTION_EXISTS(sd_notify HAVE_SYSTEMD_SD_NOTIFY)
CHECK_FUNCTION_EXISTS(sd_notifyf HAVE_SYSTEMD_SD_NOTIFYF)
SET(CMAKE_REQUIRED_LIBRARIES)
IF(HAVE_SYSTEMD AND HAVE_SYSTEMD_SD_DAEMON_H AND HAVE_SYSTEMD_SD_LISTEN_FDS
AND HAVE_SYSTEMD_SD_NOTIFY AND HAVE_SYSTEMD_SD_NOTIFYF)
ADD_DEFINITIONS(-DHAVE_SYSTEMD)
# should be from pkg-config --variable=systemdsystemconfdir systemd
# Missing CMake macro: http://public.kitware.com/Bug/view.php?id=15634
SET(SYSTEMD_SYSTEM_CONFDIR /etc/systemd/system)
# should be from pkg-config --variable=systemdsystemunitdir systemd
SET(SYSTEMD_SYSTEM_UNITDIR /usr/lib/systemd/system/)
SET(SYSTEMD_SCRIPTS mariadb-service-convert)
SET(SYSTEMD_DEB_FILES "usr/bin/mariadb-service-convert
${INSTALL_SYSTEMD_UNITDIR}/mariadb.service
${INSTALL_SYSTEMD_UNITDIR}/mariadb@.service
${INSTALL_SYSTEMD_UNITDIR}/mariadb@bootstrap.service.d/wsrep-new-cluster.conf")
IF(DEB)
SET(SYSTEMD_EXECSTARTPRE "PermissionsStartOnly=true\nExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld")
SET(SYSTEMD_EXECSTARTPOST "ExecStartPost=/etc/mysql/debian-start")
ENDIF()
MESSAGE(STATUS "Systemd features enabled")
ELSE()
UNSET(LIBSYSTEMD)
UNSET(HAVE_SYSTEMD)
UNSET(HAVE_SYSTEMD_SD_DAEMON_H)
UNSET(HAVE_SYSTEMD_SD_LISTEN_FDS)
UNSET(HAVE_SYSTEMD_SD_NOTIFY)
......
......@@ -23,7 +23,6 @@ Build-Depends: bison,
zlib1g-dev (>= 1:1.1.3-5~),
${MAYBE_LIBCRACK}
libjemalloc-dev (>= 3.0.0~) [linux-any]
libsystemd-daemon-dev | libsystemd-dev, dh-systemd
Standards-Version: 3.8.2
Homepage: http://mariadb.org/
Vcs-Git: https://github.com/MariaDB/server.git
......
......@@ -55,7 +55,6 @@ usr/bin/wsrep_sst_mysqldump
usr/bin/wsrep_sst_rsync
usr/bin/wsrep_sst_xtrabackup
usr/bin/wsrep_sst_xtrabackup-v2
usr/bin/mariadb-system-convert
usr/share/doc/mariadb-server-10.1/mysqld.sym.gz
usr/share/doc/mariadb-server-10.1/INFO_SRC
usr/share/doc/mariadb-server-10.1/INFO_BIN
......@@ -94,3 +93,4 @@ usr/share/mysql/wsrep_notify
@CASSANDRA_DEB_FILES@
@SPIDER_DEB_FILES@
@TOKUDB_DEB_FILES@
@SYSTEMD_DEB_FILES@
......@@ -286,6 +286,12 @@ fi
db_stop # in case invoke failes
# dh_systemd_start doesn't emit anything since we still ship /etc/init.d/mysql.
# Thus MariaDB server is started via init.d script, which in turn redirects to
# systemctl. If we upgrade from MySQL mysql.service may be masked, which also
# means init.d script is disabled. Unmask mysql service explicitely.
deb-systemd-helper unmask mysql.service >/dev/null || true
#DEBHELPER#
exit 0
......@@ -180,12 +180,6 @@ install: build
install -m 0644 $(builddir)/Docs/INFO_SRC $(TMP)/usr/share/doc/mariadb-server-10.1/INFO_SRC
install -m 0644 $(builddir)/Docs/INFO_BIN $(TMP)/usr/share/doc/mariadb-server-10.1/INFO_BIN
# systemd helpers
install -m 0755 scripts/mariadb-service-convert $(TMP)/usr/bin/
install -d $(TMP)/etc/systemd/system/mariadb@bootstrap.service.d/
install -m 0644 $(BUILDDIR)/support-files/mariadb-bootstrap.conf \
$(TMP)/etc/systemd/system/mariadb@bootstrap.service.d/wsrep-new-cluster.conf
# mariadb-test
mv $(TMP)/usr/mysql-test $(TMP)/usr/share/mysql
......@@ -221,10 +215,7 @@ binary-indep: build install
dh_installexamples -i
dh_installmenu -i
dh_installlogrotate -i
dh_systemd_enable -i support-files/mariadb.service
dh_systemd_enable --no-enable support-files/mariadb@.service
dh_installinit -i
dh_systemd_start -i --restart-after-upgrade mariadb.service
dh_installcron -i
dh_installman -i
dh_installinfo -i
......@@ -250,9 +241,12 @@ binary-arch: build install
dh_installexamples -a
dh_installmenu -a
dh_installlogrotate -a --name mysql-server
if [ -x /usr/bin/dh_systemd_enable -a -f debian/mariadb-server-10.1/lib/systemd/system/mariadb.service ]; then dh_systemd_enable -pmariadb-server-10.1 mariadb.service; fi
if [ -x /usr/bin/dh_systemd_enable -a -f debian/mariadb-server-10.1/lib/systemd/system/mariadb@.service ]; then dh_systemd_enable --no-enable -pmariadb-server-10.1 mariadb@.service; fi
# Start mysql in runlevel 19 before 20 where apache, proftpd etc gets
# started which might depend on a running database server.
dh_installinit -a --name=mysql -- defaults 19 21
if [ -x /usr/bin/dh_systemd_start -a -f debian/mariadb-server-10.1/lib/systemd/system/mariadb.service ]; then dh_systemd_start -pmariadb-server-10.1 --restart-after-upgrade mariadb.service; fi
dh_installcron -a --name mysql-server
dh_installman -a
dh_installinfo -a
......
/*
Copyright (c) 2015 Daniel Black. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef MY_SYSTEMD_INCLUDED
#define MY_SYSTEMD_INCLUDED
#if defined(HAVE_SYSTEMD) && !defined(EMBEDDED_LIBRARY)
/*
sd-daemon.h may include inttypes.h. Explicitly request format macros before
the first inclusion of inttypes.h.
*/
#define __STDC_FORMAT_MACROS
#include <systemd/sd-daemon.h>
#else
#define sd_notify(X, Y)
#define sd_notifyf(E, F, ...)
#endif
#endif /* MY_SYSTEMD_INCLUDED */
......@@ -300,7 +300,7 @@ ELSE()
mysqld_multi
mysqld_safe
${WSREP_BINARIES}
mariadb-service-convert
${SYSTEMD_SCRIPTS}
)
FOREACH(file ${BIN_SCRIPTS})
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
......
......@@ -25,14 +25,7 @@
tz_old=$TZ
get_params()
{
# does a return so needs to be wrapped in a function
# . /usr/bin/mysqld_safe --simulate
. scripts/mysqld_safe --simulate
}
get_params
. /usr/bin/mysqld_safe --dry-run
echo "# converted using $0"
echo "#"
......@@ -66,10 +59,11 @@ if [ -n "$mysqld_ld_library_path" ]; then
fi
if [[ $want_syslog -eq 1 ]]; then
echo StandardOutput=syslog
echo StandardError=syslog
echo SyslogFacility=daemon
echo SyslogLevel=error
echo SyslogLevelPrefix=${syslog_tag_mysqld}
echo SyslogLevel=err
echo SyslogIdentifier=${syslog_tag_mysqld}
fi
if [[ "${flush_caches}" -gt 0 ]]; then
......@@ -83,4 +77,6 @@ if [[ "${numa_interleave}" -gt 0 ]]; then
echo
fi
[ -n "${CRASH_SCRIPT}" ] && echo FailureAction=${CRASH_SCRIPT}
if [ -n "${CRASH_SCRIPT}" ]; then
echo FailureAction=${CRASH_SCRIPT}
fi
......@@ -21,7 +21,7 @@ mysqld_ld_library_path=
flush_caches=0
numa_interleave=0
wsrep_on=0
simulate=0
dry_run=0
# Initial logging status: error log is not open, and not using syslog
logging=init
......@@ -82,7 +82,7 @@ Usage: $0 [OPTIONS]
--malloc-lib=LIB Preload shared library LIB if available
--mysqld=FILE Use the specified file as mysqld
--mysqld-version=VERSION Use "mysqld-VERSION" as mysqld
--simulate Simulate the start to detect errors but don't start
--dry-run Simulate the start to detect errors but don't start
--nice=NICE Set the scheduling priority of mysqld
--no-auto-restart Exit after starting mysqld
--nowatch Exit after starting mysqld
......@@ -133,7 +133,7 @@ my_which ()
}
log_generic () {
[ $simulate -eq 1 ] && return
[ $dry_run -eq 1 ] && return
priority="$1"
shift
......@@ -321,7 +321,7 @@ parse_arguments() {
MYSQLD="mysqld"
fi
;;
--simulate) simulate=1 ;;
--dry[-_]run) dry_run=1 ;;
--nice=*) niceness="$val" ;;
--nowatch|--no[-_]watch|--no[-_]auto[-_]restart) nowatch=1 ;;
--open[-_]files[-_]limit=*) open_files="$val" ;;
......@@ -866,7 +866,7 @@ fi
#
# If there exists an old pid file, check if the daemon is already running
# Note: The switches to 'ps' may depend on your operating system
if test -f "$pid_file" && [ $simulate -eq 0 ]
if test -f "$pid_file" && [ $dry_run -eq 0 ]
then
PID=`cat "$pid_file"`
if @CHECK_PID@
......@@ -941,9 +941,8 @@ fi
# ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems
#fi
cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS"
[ $simulate -eq 0 ] && cmd=''
[ $dry_run -eq 1 ] && cmd=''
#
# Set mysqld's memory interleave policy.
......@@ -963,7 +962,7 @@ then
fi
# Launch mysqld with numactl.
[ $simulate -eq 0 ] && cmd="$cmd numactl --interleave=all"
[ $dry_run -eq 0 ] && cmd="$cmd numactl --interleave=all"
elif test $numa_interleave -eq 1
then
log_error "--numa-interleave is not supported on this platform"
......@@ -976,8 +975,8 @@ do
cmd="$cmd "`shell_quote_string "$i"`
done
cmd="$cmd $args"
[ $dry_run -eq 1 ] && return
# Avoid 'nohup: ignoring input' warning
[ $simulate -eq 0 ] && cmd='true'
test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null"
log_notice "Starting $MYSQLD daemon with databases from $DATADIR"
......
......@@ -1893,8 +1893,6 @@ static void __cdecl kill_server(int sig_ptr)
else
sql_print_error(ER_DEFAULT(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
sd_notify(0, "STOPPING=1");
#ifdef HAVE_SMEM
/*
Send event to smem_event_connect_request for aborting
......@@ -2001,6 +1999,7 @@ void unireg_end(void)
{
clean_up(1);
my_thread_end();
sd_notify(0, "STATUS=MariaDB server is down");
#if defined(SIGNALS_DONT_BREAK_READ)
exit(0);
#else
......@@ -2066,6 +2065,7 @@ static void mysqld_exit(int exit_code)
shutdown_performance_schema(); // we do it as late as possible
#endif
DBUG_LEAVE;
sd_notify(0, "STATUS=MariaDB server is down");
exit(exit_code); /* purecov: inspected */
}
......@@ -6547,10 +6547,8 @@ void handle_connections_sockets()
socket_flags=fcntl(mysql_socket_getfd(unix_sock), F_GETFL, 0);
#endif
#ifdef HAVE_SYSTEMD
sd_notify(0, "READY=1\n"
"STATUS=Taking your SQL requests now...");
#endif
DBUG_PRINT("general",("Waiting for connections."));
MAYBE_BROKEN_SYSCALL;
......@@ -6766,7 +6764,8 @@ void handle_connections_sockets()
create_new_thread(thd);
set_current_thd(0);
}
sd_notify(0, "STOPPING=1");
sd_notify(0, "STOPPING=1\n"
"STATUS=Shutdown in progress");
DBUG_VOID_RETURN;
}
......
......@@ -1874,15 +1874,16 @@ recv_apply_hashed_log_recs(
}
}
progress=(ulong) (i * 100) / hash_get_n_cells(recv_sys->addr_hash);
progress = (ulong) (i * 100)
/ hash_get_n_cells(recv_sys->addr_hash);
if (has_printed
&& progress != ((i + 1) * 100)
/ hash_get_n_cells(recv_sys->addr_hash)) {
&& progress
!= ((i + 1) * 100)
/ hash_get_n_cells(recv_sys->addr_hash)) {
fprintf(stderr, "%lu ", progress);
sd_notifyf(0, "STATUS=Applying batch of log records for Innodb: "
"Progress %lu", progress);
sd_notifyf(0, "STATUS=Applying batch of log records for"
" InnoDB: Progress %lu", progress);
}
}
......@@ -2094,8 +2095,9 @@ recv_apply_log_recs_for_backup(void)
fprintf(stderr, "%lu ",
(ulong) ((100 * i) / n_hash_cells));
fflush(stderr);
sd_notifyf(0, "STATUS=Applying batch of log records for backup Innodb: "
"Progress %lu", (ulong) (100 * i) / n_hash_cells);
sd_notifyf(0, "STATUS=Applying batch of log records for"
" backup InnoDB: Progress %lu",
(ulong) (100 * i) / n_hash_cells);
}
}
sd_notify(0, "STATUS=InnoDB: Apply batch for backup completed");
......
......@@ -1942,15 +1942,16 @@ recv_apply_hashed_log_recs(
}
}
progress=(ulong) (i * 100) / hash_get_n_cells(recv_sys->addr_hash);
progress = (ulong) (i * 100)
/ hash_get_n_cells(recv_sys->addr_hash);
if (has_printed
&& progress != ((i + 1) * 100)
/ hash_get_n_cells(recv_sys->addr_hash)) {
fprintf(stderr, "%lu ", progress);
sd_notifyf(0, "STATUS=Applying batch of log records for Innodb: "
"Progress %lu", progress);
&& progress
!= ((i + 1) * 100)
/ hash_get_n_cells(recv_sys->addr_hash)) {
fprintf(stderr, "%lu ", progress);
sd_notifyf(0, "STATUS=Applying batch of log records for"
" InnoDB: Progress %lu", progress);
}
}
......@@ -2164,8 +2165,9 @@ recv_apply_log_recs_for_backup(void)
fprintf(stderr, "%lu ",
(ulong) ((100 * i) / n_hash_cells));
fflush(stderr);
sd_notifyf(0, "STATUS=Applying batch of log records for backup Innodb: "
"Progress %lu", (ulong) (100 * i) / n_hash_cells);
sd_notifyf(0, "STATUS=Applying batch of log records for"
" backup InnoDB: Progress %lu",
(ulong) (100 * i) / n_hash_cells);
}
}
sd_notify(0, "STATUS=InnoDB: Apply batch for backup completed");
......
......@@ -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! $@"
......
# 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
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment