From a94ae5fd7969b7b0cb456708739d9e46e159884d Mon Sep 17 00:00:00 2001 From: eulerstorage Date: Sun, 19 Jan 2020 18:01:16 +0800 Subject: [PATCH] add service files --- 6000-backport-mariadb-scripts.patch | 37 ++++++++ README.mysql-license | 9 ++ mariadb-server-galera.te | 23 +++++ mariadb.spec | 39 +++++++- mysql-check-socket.sh | 39 ++++++++ mysql-check-upgrade.sh | 39 ++++++++ mysql-prepare-db-dir.sh | 133 ++++++++++++++++++++++++++++ mysql-scripts-common.sh | 68 ++++++++++++++ mysql.service.in | 38 ++++++++ mysql.tmpfiles.d.in | 3 + mysql@.service.in | 43 +++++++++ 11 files changed, 469 insertions(+), 2 deletions(-) create mode 100644 6000-backport-mariadb-scripts.patch create mode 100644 README.mysql-license create mode 100644 mariadb-server-galera.te create mode 100644 mysql-check-socket.sh create mode 100644 mysql-check-upgrade.sh create mode 100644 mysql-prepare-db-dir.sh create mode 100644 mysql-scripts-common.sh create mode 100644 mysql.service.in create mode 100644 mysql.tmpfiles.d.in create mode 100644 mysql@.service.in diff --git a/6000-backport-mariadb-scripts.patch b/6000-backport-mariadb-scripts.patch new file mode 100644 index 0000000..a065432 --- /dev/null +++ b/6000-backport-mariadb-scripts.patch @@ -0,0 +1,37 @@ +We have some downstream patches and other scripts that include variables to +be expanded by cmake. Cmake needs to know about them, so adding them manually. + +--- mariadb-10.3.8/scripts/CMakeLists.txt 2018-07-02 09:34:11.000000000 +0200 ++++ mariadb-10.3.8/scripts/CMakeLists.txt_patched 2018-07-03 10:58:15.954670153 +0200 +@@ -361,6 +361,31 @@ ELSE() + COMPONENT ${${file}_COMPONENT} + ) + ENDFOREACH() ++ ++ # files for systemd ++ SET(SYSTEMD_SCRIPTS ++ mysql.tmpfiles.d ++ mysql.service ++ mysql@.service ++ mysql-prepare-db-dir ++ mysql-check-socket ++ mysql-check-upgrade ++ mysql-scripts-common ++ galera_new_cluster ++ ) ++ FOREACH(file ${SYSTEMD_SCRIPTS}) ++ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh) ++ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh ++ ${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY) ++ ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.in) ++ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.in ++ ${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY) ++ ELSE() ++ MESSAGE(FATAL_ERROR "Can not find ${file}.sh or ${file}.in in " ++ "${CMAKE_CURRENT_SOURCE_DIR}" ) ++ ENDIF() ++ ENDFOREACH() ++ + ENDIF() + + # Install libgcc as mylibgcc.a diff --git a/README.mysql-license b/README.mysql-license new file mode 100644 index 0000000..ceabbcf --- /dev/null +++ b/README.mysql-license @@ -0,0 +1,9 @@ +MySQL is distributed under GPL v2, but there are some licensing exceptions +that allow the client libraries to be linked with a non-GPL application, +so long as the application is under a license approved by Oracle. +For details see + +http://www.mysql.com/about/legal/licensing/foss-exception/ + +Some innobase code from Percona and Google is under BSD license. +Some code related to test-suite is under LGPLv2. diff --git a/mariadb-server-galera.te b/mariadb-server-galera.te new file mode 100644 index 0000000..bdce127 --- /dev/null +++ b/mariadb-server-galera.te @@ -0,0 +1,23 @@ + +module mariadb-server-galera 1.0; + +require { + type mysqld_t; + type rsync_exec_t; + type anon_inodefs_t; + type proc_net_t; + type kerberos_port_t; + class file { read execute execute_no_trans getattr open }; + class tcp_socket { name_bind name_connect }; + class process { setpgid siginh rlimitinh noatsecure }; +} + +# allow mysqld to run rsyncd +allow mysqld_t self:process setpgid; +allow mysqld_t rsync_exec_t:file { read execute execute_no_trans getattr open }; +allow mysqld_t anon_inodefs_t:file getattr; +allow mysqld_t proc_net_t:file { read open }; + +# allow rsyncd to listen on port 4444 +allow mysqld_t kerberos_port_t:tcp_socket { name_bind name_connect }; + diff --git a/mariadb.spec b/mariadb.spec index 251ad9e..1b23a54 100644 --- a/mariadb.spec +++ b/mariadb.spec @@ -2,14 +2,24 @@ Name: mariadb Version: 10.3.9 -Release: 6 +Release: 7 Epoch: 3 Summary: One of the most popular database servers License: GPLv2 with exceptions and LGPLv2 and BSD URL: http://mariadb.org Source0: https://downloads.mariadb.org/interstitial/mariadb-%{version}/source/mariadb-%{version}.tar.gz - +Source1: mysql.tmpfiles.d.in +Source2: mysql.service.in +Source3: mysql-prepare-db-dir.sh +Source4: mysql-check-socket.sh +Source5: mysql-scripts-common.sh +Source6: mysql-check-upgrade.sh +Source7: mysql@.service.in +Source8: mariadb-server-galera.te +Source9: README.mysql-license + +Patch6000: 6000-backport-mariadb-scripts.patch Patch9000: 9000-disable-some-unstable-testcases.patch BuildRequires: selinux-policy-devel, cmake, gcc-c++ @@ -191,6 +201,11 @@ This contains test suitte for the developing of MariaDB. %autosetup -n %{name}-%{version} -p1 find . -name "*.jar" -type f -exec rm --verbose -f {} \; +cp %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} %{SOURCE6} %{SOURCE7} scripts + +mkdir selinux +sed 's/mariadb-server-galera/%{name}-server-galera/' %{SOURCE8} > selinux/%{name}-server-galera.te + pcre_maj=`grep '^m4_define(pcre_major' pcre/configure.ac | sed -r 's/^m4_define\(pcre_major, \[([0-9]+)\]\)/\1/'` pcre_min=`grep '^m4_define(pcre_minor' pcre/configure.ac | sed -r 's/^m4_define\(pcre_minor, \[([0-9]+)\]\)/\1/'` @@ -278,6 +293,7 @@ cmake -L %make_build VERBOSE=1 +make -C selinux -f /usr/share/selinux/devel/Makefile %{name}-server-galera.pp %install %make_install @@ -301,9 +317,20 @@ install -p -m 0755 -d %{buildroot}%{_localstatedir}/lib/mysql mv %{buildroot}%{_sysconfdir}/my.cnf.d/server.cnf %{buildroot}%{_sysconfdir}/my.cnf.d/%{name}-server.cnf mv %{buildroot}%{_sysusersdir}/sysusers.conf %{buildroot}%{_sysusersdir}/%{name}.conf +install -D -p -m 644 scripts/mysql.service %{buildroot}%{_unitdir}/%{name}.service +install -D -p -m 644 scripts/mysql@.service %{buildroot}%{_unitdir}/%{name}@.service +install -p -m 755 scripts/mysql-prepare-db-dir %{buildroot}%{_libexecdir}/mysql-prepare-db-dir +install -p -m 755 scripts/mysql-check-socket %{buildroot}%{_libexecdir}/mysql-check-socket +install -p -m 755 scripts/mysql-check-upgrade %{buildroot}%{_libexecdir}/mysql-check-upgrade +install -p -m 644 scripts/mysql-scripts-common %{buildroot}%{_libexecdir}/mysql-scripts-common + +install -p -m 644 -D selinux/%{name}-server-galera.pp %{buildroot}%{_datadir}/selinux/packages/%{name}/%{name}-server-galera.pp + rm %{buildroot}%{_sysconfdir}/init.d/mysql rm %{buildroot}%{_libexecdir}/rcmysql rm %{buildroot}%{_tmpfilesdir}/tmpfiles.conf + +install -D -p -m 0644 scripts/mysql.tmpfiles.d %{buildroot}%{_tmpfilesdir}/%{name}.conf echo "d %{_rundir}/%{name} 0755 mysql mysql -" >>%{buildroot}%{_tmpfilesdir}/%{name}.conf mv %{buildroot}%{_datadir}/mysql-test/lib/My/SafeProcess/my_safe_process %{buildroot}%{_bindir} @@ -321,6 +348,8 @@ mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d mv %{buildroot}%{_datadir}/%{name}/mysql-log-rotate %{buildroot}%{_sysconfdir}/logrotate.d/%{name} chmod 644 %{buildroot}%{_sysconfdir}/logrotate.d/%{name} +install -p -m 0644 %{SOURCE9} README.mysql-license +install -p -m 0644 %{SOURCE6} mysql-check-upgrade.sh sed -i -r 's|^wsrep_provider=none|wsrep_provider=%{_libdir}/galera/libgalera_smm.so|' support-files/wsrep.cnf install -p -m 0644 support-files/wsrep.cnf %{buildroot}%{_sysconfdir}/my.cnf.d/galera.cnf @@ -395,6 +424,7 @@ export MTR_BUILD_THREAD=%{__isa_bits} semanage port -a -t mysqld_port_t -p tcp 4568 &> /dev/null || : semanage port -a -t mysqld_port_t -p tcp 4567 &> /dev/null || : semanage port -a -t mysqld_port_t -p udp 4567 &> /dev/null || : +semodule -i %{_datadir}/selinux/packages/%{name}/%{name}-server-galera.pp &> /dev/null || : %post server %systemd_post %{name}.service @@ -527,6 +557,7 @@ fi %{_datadir}/%{name}/systemd/*.service %{_unitdir}/%{name}* +%{_libexecdir}/mysql-* %attr(0755,mysql,mysql) %dir %{_rundir}/%{name} %attr(0755,mysql,mysql) %dir %{_localstatedir}/lib/mysql @@ -542,6 +573,7 @@ fi %{_bindir}/galera_new_cluster %{_bindir}/galera_recovery %{_datadir}/%{name}/systemd/use_galera_new_cluster.conf +%{_datadir}/selinux/packages/%{name}/%{name}-server-galera.pp %files gssapi-server %config(noreplace) %{_sysconfdir}/my.cnf.d/auth_gssapi.cnf @@ -596,6 +628,9 @@ fi %changelog +* Sun Jan 19 2020 openEuler Buildteam - 3:10.3.9-7 +- Add config files for service + * Wed Jan 15 2020 openEuler Buildteam - 3:10.3.9-6 - Add my.cnf file diff --git a/mysql-check-socket.sh b/mysql-check-socket.sh new file mode 100644 index 0000000..5e13108 --- /dev/null +++ b/mysql-check-socket.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# We check if there is already a process using the socket file, +# since otherwise the systemd service file could report false +# positive result when starting and mysqld_safe could remove +# a socket file, which is actually being used by a different daemon. + +source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common" + +if test -e "$socketfile" ; then + echo "Socket file $socketfile exists." >&2 + + # no write permissions + if ! test -w "$socketfile" ; then + echo "Not enough permission to write to the socket file $socketfile, which is suspicious." >&2 + echo "Please, remove $socketfile manually to start the service." >&2 + exit 1 + fi + + # not a socket file + if ! test -S "$socketfile" ; then + echo "The file $socketfile is not a socket file, which is suspicious." >&2 + echo "Please, remove $socketfile manually to start the service." >&2 + exit 1 + fi + + # some process uses the socket file + response=`@bindir@/mysqladmin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER --connect-timeout="${CHECKSOCKETTIMEOUT:-10}" ping 2>&1` + if [ $? -qe 0 ] || echo "$response" | grep -q "Access denied for user" ; then + echo "Is another MySQL daemon already running with the same unix socket?" >&2 + echo "Please, stop the process using the socket $socketfile or remove the file manually to start the service." >&2 + exit 1 + fi + + # socket file is a garbage + echo "No process is using $socketfile, which means it is a garbage, so it will be removed automatically." >&2 +fi + +exit 0 diff --git a/mysql-check-upgrade.sh b/mysql-check-upgrade.sh new file mode 100644 index 0000000..1bfd3bc --- /dev/null +++ b/mysql-check-upgrade.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common" + +upgrade_info_file="$datadir/mysql_upgrade_info" +version=0 +# get version as integer from mysql_upgrade_info file +if [ -f "$upgrade_info_file" ] && [ -r "$upgrade_info_file" ] ; then + version_major=$(cat "$upgrade_info_file" | head -n 1 | sed -e 's/\([0-9]*\)\.\([0-9]*\)\..*$/\1/') + version_minor=$(cat "$upgrade_info_file" | head -n 1 | sed -e 's/\([0-9]*\)\.\([0-9]*\)\..*$/\2/') + if [[ $version_major =~ ^[0-9]+$ ]] && [[ $version_minor =~ ^[0-9]+$ ]] ; then + version=$((version_major*100+version_minor)) + fi +fi + +# compute current version as integer +thisversion=$((@MAJOR_VERSION@*100+@MINOR_VERSION@)) + +# provide warning in cases we should run mysql_upgrade +if [ $version -ne $thisversion ] ; then + + # give extra warning if some version seems to be skipped + if [ $version -gt 0 ] && [ $version -lt 505 ] ; then + echo "The datadir located at $datadir seems to be older than of a version 5.5. Please, mind that as a general rule, to upgrade from one release series to another, go to the next series rather than skipping a series." >&2 + fi + + cat <&2 +The datadir located at $datadir needs to be upgraded using 'mysql_upgrade' tool. This can be done using the following steps: + + 1. Back-up your data before with 'mysql_upgrade' + 2. Start the database daemon using 'service @DAEMON_NAME@ start' + 3. Run 'mysql_upgrade' with a database user that has sufficient privileges + +Read more about 'mysql_upgrade' usage at: +https://mariadb.com/kb/en/mariadb/documentation/sql-commands/table-commands/mysql_upgrade/ +EOF +fi + +exit 0 diff --git a/mysql-prepare-db-dir.sh b/mysql-prepare-db-dir.sh new file mode 100644 index 0000000..922151a --- /dev/null +++ b/mysql-prepare-db-dir.sh @@ -0,0 +1,133 @@ +#!/bin/sh + +# This script creates the mysql data directory during first service start. +# In subsequent starts, it does nothing much. + +source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common" + +export LC_ALL=C + +# Returns content of the specified directory +# If listing files fails, fake-file is returned so which means +# we'll behave like there was some data initialized +# Some files or directories are fine to be there, so those are +# explicitly removed from the listing +# @param datadir +list_datadir () +{ + ( ls -1A "$1" 2>/dev/null || echo "fake-file" ) | grep -v \ + -e '^lost+found$' \ + -e '\.err$' \ + -e '^.bash_history$' +} + +# Checks whether datadir should be initialized +# @param datadir +should_initialize () +{ + test -z "$(list_datadir "$1")" +} + +# If two args given first is user, second is group +# otherwise the arg is the systemd service file +if [ "$#" -eq 2 ] +then + myuser="$1" + mygroup="$2" +else + # Absorb configuration settings from the specified systemd service file, + # or the default service if not specified + SERVICE_NAME="$1" + if [ x"$SERVICE_NAME" = x ] + then + SERVICE_NAME=@DAEMON_NAME@.service + fi + + myuser=`systemctl show -p User "${SERVICE_NAME}" | + sed 's/^User=//'` + if [ x"$myuser" = x ] + then + myuser=mysql + fi + + mygroup=`systemctl show -p Group "${SERVICE_NAME}" | + sed 's/^Group=//'` + if [ x"$mygroup" = x ] + then + mygroup=mysql + fi +fi + +# Set up the errlogfile with appropriate permissions +if [ ! -e "$errlogfile" -a ! -h "$errlogfile" -a x$(dirname "$errlogfile") = "x/var/log" ]; then + case $(basename "$errlogfile") in + mysql*.log|mariadb*.log) install /dev/null -m0640 -o$myuser -g$mygroup "$errlogfile" ;; + *) ;; + esac +else + # Provide some advice if the log file cannot be created by this script + errlogdir=$(dirname "$errlogfile") + if ! [ -d "$errlogdir" ] ; then + echo "The directory $errlogdir does not exist." >&2 + exit 1 + elif [ -e "$errlogfile" -a ! -w "$errlogfile" ] ; then + echo "The log file $errlogfile cannot be written, please, fix its permissions." >&2 + echo "The daemon will be run under $myuser:$mygroup" >&2 + exit 1 + fi +fi + +# Make the data directory if doesn't exist or empty +if should_initialize "$datadir" ; then + # First, make sure $datadir is there with correct permissions + # (note: if it's not, and we're not root, this'll fail ...) + if [ ! -e "$datadir" -a ! -h "$datadir" ] + then + mkdir -p "$datadir" || exit 1 + fi + chown "$myuser:$mygroup" "$datadir" + chmod 0755 "$datadir" + [ -x /sbin/restorecon ] && /sbin/restorecon "$datadir" + + # Now create the database + echo "Initializing @NICE_PROJECT_NAME@ database" >&2 + INITDB_TIMESTAMP=`LANG=C date -u` + sleep 1 + @bindir@/mysql_install_db --rpm --datadir="$datadir" --user="$myuser" --skip-test-db >&2 + ret=$? + if [ $ret -ne 0 ] ; then + echo "Initialization of @NICE_PROJECT_NAME@ database failed." >&2 + echo "Perhaps @sysconfdir@/my.cnf is misconfigured or there is some problem with permissions of $datadir." >&2 + # Clean up any partially-created database files + if [ ! -e "$datadir/mysql/user.frm" ] && [ -d "$datadir" ] ; then + echo "Initialization of @NICE_PROJECT_NAME@ database was not finished successfully." >&2 + echo "Files created so far will be removed." >&2 + find "$datadir" -mindepth 1 -maxdepth 1 -newermt "$INITDB_TIMESTAMP" \ + -not -name "lost+found" -exec rm -rf {} + + if [ $? -ne 0 ] ; then + echo "Removing of created files was not successfull." >&2 + echo "Please, clean directory $datadir manually." >&2 + fi + else + echo "However, part of data has been initialized and those will not be removed." >&2 + echo "Please, clean directory $datadir manually." >&2 + fi + exit $ret + fi + # upgrade does not need to be run on a fresh datadir + echo "@VERSION@-MariaDB" >"$datadir/mysql_upgrade_info" +else + if [ -d "$datadir/mysql/" ] ; then + # mysql dir exists, it seems data are initialized properly + echo "Database @NICE_PROJECT_NAME@ is probably initialized in $datadir already, nothing is done." + echo "If this is not the case, make sure the $datadir is empty before running `basename $0`." + else + # if the directory is not empty but mysql/ directory is missing, then + # print error and let user to initialize manually or empty the directory + echo "Database @NICE_PROJECT_NAME@ is not initialized, but the directory $datadir is not empty, so initialization cannot be done." >&2 + echo "Make sure the $datadir is empty before running `basename $0`." >&2 + exit 1 + fi +fi + +exit 0 diff --git a/mysql-scripts-common.sh b/mysql-scripts-common.sh new file mode 100644 index 0000000..e270433 --- /dev/null +++ b/mysql-scripts-common.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +# Some useful functions used in other MySQL helper scripts +# This scripts defines variables datadir, errlogfile, socketfile + +export LC_ALL=C + +# extract value of a MySQL option from config files +# Usage: get_mysql_option VARNAME DEFAULT SECTION [ SECTION, ... ] +# result is returned in $result +# We use my_print_defaults which prints all options from multiple files, +# with the more specific ones later; hence take the last match. +get_mysql_option(){ + if [ $# -ne 3 ] ; then + echo "get_mysql_option requires 3 arguments: section option default_value" + return + fi + sections="$1" + option_name="$2" + default_value="$3" + result=`@bindir@/my_print_defaults $my_print_defaults_extra_args $sections | sed -n "s/^--${option_name}=//p" | tail -n 1` + if [ -z "$result" ]; then + # not found, use default + result="${default_value}" + fi +} + +# For the case of running more instances via systemd, scrits that source +# this file can get --default-group-suffix or similar option as the first +# argument. The utility my_print_defaults needs to use it as well, so the +# scripts sourcing this file work with the same options as the daemon. +my_print_defaults_extra_args='' +while echo "$1" | grep -q '^--defaults' ; do + my_print_defaults_extra_args="${my_print_defaults_extra_args} $1" + shift +done + +# Defaults here had better match what mysqld_safe will default to +# The option values are generally defined on three important places +# on the default installation: +# 1) default values are hardcoded in the code of mysqld daemon or +# mysqld_safe script +# 2) configurable values are defined in @sysconfdir@/my.cnf +# 3) default values for helper scripts are specified bellow +# So, in case values are defined in my.cnf, we need to get that value. +# In case they are not defined in my.cnf, we need to get the same value +# in the daemon, as in the helper scripts. Thus, default values here +# must correspond with values defined in mysqld_safe script and source +# code itself. + +server_sections="mysqld_safe mysqld server mysqld-@MAJOR_VERSION@.@MINOR_VERSION@ mariadb mariadb-@MAJOR_VERSION@.@MINOR_VERSION@ client-server" + +get_mysql_option "$server_sections" datadir "@MYSQL_DATADIR@" +datadir="$result" + +# if there is log_error in the my.cnf, my_print_defaults still +# returns log-error +# log-error might be defined in mysqld_safe and mysqld sections, +# the former has bigger priority +get_mysql_option "$server_sections" log-error "$datadir/`uname -n`.err" +errlogfile="$result" + +get_mysql_option "$server_sections" socket "@MYSQL_UNIX_ADDR@" +socketfile="$result" + +get_mysql_option "$server_sections" pid-file "$datadir/`uname -n`.pid" +pidfile="$result" + diff --git a/mysql.service.in b/mysql.service.in new file mode 100644 index 0000000..271bcd9 --- /dev/null +++ b/mysql.service.in @@ -0,0 +1,38 @@ +[Unit] +Description=MariaDB 10.3.9 database server +Documentation=man:mysqld(8) +Documentation=https://mariadb.com/kb/en/library/systemd/ +After=network.target + +[Install] +WantedBy=multi-user.target +Alias=mysql.service +Alias=mysqld.service + +[Service] +Type=notify +User=mysql +Group=mysql + +ExecStartPre=@libexecdir@/mysql-check-socket +ExecStartPre=@libexecdir@/mysql-prepare-db-dir %n +ExecStart=@libexecdir@/mysqld --basedir=@prefix@ +ExecStartPost=/usr/libexec/mysql-check-upgrade + +KillSignal=SIGTERM + +# Don't want to see an automated SIGKILL ever +SendSIGKILL=no + +# Restart crashed server only, on-failure would also restart, for example, when +# my.cnf contains unknown option +Restart=on-abort +RestartSec=5s + +UMask=007 + +# Give a reasonable amount of time for the server to start up/shut down +TimeoutSec=300 + +# Place temp files in a secure directory, not /tmp +PrivateTmp=true diff --git a/mysql.tmpfiles.d.in b/mysql.tmpfiles.d.in new file mode 100644 index 0000000..9e6b6e8 --- /dev/null +++ b/mysql.tmpfiles.d.in @@ -0,0 +1,3 @@ +# Do not edit this file. +# To override this, put /etc/tmpfiles.d/mariadb.conf instead. +d @PID_FILE_DIR@ 0755 mysql mysql - diff --git a/mysql@.service.in b/mysql@.service.in new file mode 100644 index 0000000..d237607 --- /dev/null +++ b/mysql@.service.in @@ -0,0 +1,43 @@ +[Unit] +Description=MariaDB 10.3.9 database server (multi-instance) +Documentation=man:mysqld(8) +Documentation=https://mariadb.com/kb/en/library/systemd/ +After=network.target + +[Install] +WantedBy=multi-user.target +Alias=mysql.service +Alias=mysqld.service + +[Service] +Type=notify +User=mysql +Group=mysql + +ExecStartPre=@libexecdir@/mysql-check-socket --defaults-group-suffix=.%I +ExecStartPre=@libexecdir@/mysql-prepare-db-dir --defaults-group-suffix=.%I %n +ExecStart=@libexecdir@/mysqld --defaults-group-suffix=.%I --basedir=@prefix@ +ExecStartPost=@libexecdir@/mysql-check-upgrade --defaults-group-suffix=.%I + +# Setting this to true can break replication and the Type=notify settings +# See also bind-address mysqld option. +PrivateNetwork=false + +KillMode=process +KillSignal=SIGTERM + +# Don't want to see an automated SIGKILL ever +SendSIGKILL=no + +# Restart crashed server only, on-failure would also restart, for example, when +# my.cnf contains unknown option +Restart=on-abort +RestartSec=5s + +UMask=007 + +# Give a reasonable amount of time for the server to start up/shut down +TimeoutSec=300 + +# Place temp files in a secure directory, not /tmp +PrivateTmp=true -- Gitee