committed by
Sergey Vojtovich
23 changed files with 551 additions and 15 deletions
-
1.gitignore
-
3CMakeLists.txt
-
76cmake/systemd.cmake
-
1config.h.cmake
-
1debian/control
-
1debian/mariadb-server-10.1.files.in
-
6debian/mariadb-server-10.1.postinst
-
9debian/rules
-
17include/my_systemd.h
-
1scripts/CMakeLists.txt
-
86scripts/mariadb-service-convert
-
11scripts/mysqld_safe.sh
-
3sql/CMakeLists.txt
-
10sql/mysqld.cc
-
4storage/innobase/handler/ha_innodb.cc
-
20storage/innobase/log/log0recv.cc
-
5storage/xtradb/handler/ha_innodb.cc
-
20storage/xtradb/log/log0recv.cc
-
16support-files/CMakeLists.txt
-
16support-files/mariadb-bootstrap.conf
-
120support-files/mariadb.service
-
133support-files/mariadb@.service.in
-
6support-files/rpm/server-postin.sh
@ -0,0 +1,76 @@ |
|||
# 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 St, Fifth Floor, Boston, MA 02110-1301 USA |
|||
|
|||
INCLUDE(FindPkgConfig) |
|||
# http://www.cmake.org/cmake/help/v3.0/module/FindPkgConfig.html |
|||
|
|||
MACRO(CHECK_SYSTEMD) |
|||
IF(UNIX) |
|||
SET(WITH_SYSTEMD "auto" CACHE STRING "Compile with systemd socket activation and notification") |
|||
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) |
|||
ELSE() |
|||
pkg_check_modules(LIBSYSTEMD libsystemd) |
|||
ENDIF() |
|||
IF(HAVE_DLOPEN) |
|||
SET(LIBSYSTEMD ${LIBSYSTEMD_LIBRARIES}) |
|||
#SET(CMAKE_REQUIRED_FLAGS ${LIBSYSTEMD_CFLAGS}) |
|||
SET(MYSQLD_LINK_FLAGS "${MYSQLD_LINK_FLAGS} ${LIBSYSTEMD_LDFLAGS}") |
|||
ELSE() |
|||
SET(LIBSYSTEMD ${LIBSYSTEMD_STATIC_LIBRARIES}) |
|||
#SET(CMAKE_REQUIRED_FLAGS ${LIBSYSTEMD_STATIC_CFLAGS}) |
|||
SET(MYSQLD_LINK_FLAGS "${MYSQLD_LINK_FLAGS} ${LIBSYSTEMD_STATIC_LDFLAGS}") |
|||
ENDIF() |
|||
ELSE() |
|||
SET(LIBSYSTEMD systemd) |
|||
ENDIF() |
|||
SET(CMAKE_REQUIRED_LIBRARIES ${LIBSYSTEMD}) |
|||
CHECK_C_SOURCE_COMPILES( |
|||
" |
|||
#include <systemd/sd-daemon.h> |
|||
int main() |
|||
{ |
|||
sd_listen_fds(0); |
|||
}" |
|||
HAVE_SYSTEMD) |
|||
CHECK_INCLUDE_FILES(systemd/sd-daemon.h HAVE_SYSTEMD_SD_DAEMON_H) |
|||
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) |
|||
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/) |
|||
MESSAGE(STATUS "Systemd features enabled") |
|||
ELSE() |
|||
UNSET(LIBSYSTEMD) |
|||
UNSET(HAVE_SYSTEMD_SD_DAEMON_H) |
|||
UNSET(HAVE_SYSTEMD_SD_LISTEN_FDS) |
|||
UNSET(HAVE_SYSTEMD_SD_NOTIFY) |
|||
UNSET(HAVE_SYSTEMD_SD_NOTIFYF) |
|||
MESSAGE(STATUS "Systemd features not enabled") |
|||
IF(WITH_SYSTEMD STREQUAL "yes") |
|||
MESSAGE(FATAL_ERROR "Requested WITH_SYSTEMD=YES however no dependencies installed/found") |
|||
ENDIF() |
|||
ENDIF() |
|||
ENDIF() |
|||
ENDIF() |
|||
ENDMACRO() |
@ -0,0 +1,17 @@ |
|||
|
|||
#ifndef MY_SYSTEMD_INCLUDED |
|||
#define MY_SYSTEMD_INCLUDED |
|||
|
|||
#if defined(HAVE_SYSTEMD) && !defined(EMBEDDED_LIBRARY) |
|||
#include <systemd/sd-daemon.h> |
|||
|
|||
#else |
|||
|
|||
|
|||
|
|||
#define sd_notify(X, Y) |
|||
#define sd_notifyf(E, F, ...) |
|||
|
|||
#endif |
|||
|
|||
#endif /* MY_SYSTEMD_INCLUDED */ |
@ -0,0 +1,86 @@ |
|||
#!/bin/bash |
|||
# 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 St, Fifth Floor, Boston, MA 02110-1301 USA |
|||
# |
|||
# PURPOSE: |
|||
# |
|||
# Used to generate a mariadb.service file based on the curent mysql/maridb settings |
|||
# |
|||
# This is to assist distro maintainers in migrating to systemd service definations from |
|||
# a user mysqld_safe settings in the my.cnf files. |
|||
# |
|||
# Redirect output to user directory like /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf |
|||
|
|||
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 |
|||
|
|||
echo "# converted using $0" |
|||
echo "#" |
|||
echo |
|||
|
|||
echo '[Service]' |
|||
|
|||
echo |
|||
|
|||
|
|||
if [[ ( "$user" != "root" && "$user" != "mysql" ) || "${SET_USER}" == 1 ]]; then |
|||
echo User=$user |
|||
fi |
|||
|
|||
|
|||
[ -n "${open_files}" ] && echo LimitNOFILE=$open_files |
|||
[ -n "${core_file_size}" ] && echo LimitCore=$core_file_size |
|||
[[ "${niceness}" -gt 0 ]] && echo Nice=$niceness |
|||
[ "${TZ}" != "${tz_old}" ] && echo Environment=\"TZ=${TZ}\" |
|||
|
|||
if [ -n "$mysqld_ld_preload" ]; then |
|||
new_text="$mysqld_ld_preload" |
|||
[ -n "$LD_PRELOAD" ] && new_text="$new_text $LD_PRELOAD" |
|||
echo Environment=\"LD_PRELOAD=`shell_quote_string "$new_text"`\" |
|||
fi |
|||
|
|||
if [ -n "$mysqld_ld_library_path" ]; then |
|||
new_text="$mysqld_ld_library_path" |
|||
[ -n "$LD_LIBRARY_PATH" ] && new_text="$new_text:$LD_LIBRARY_PATH" |
|||
echo Environment=\"LD_LIBRARY_PATH=`shell_quote_string "$new_text"`\" |
|||
fi |
|||
|
|||
if [[ $want_syslog -eq 1 ]]; then |
|||
echo StandardError=syslog |
|||
echo SyslogFacility=daemon |
|||
echo SyslogLevel=error |
|||
echo SyslogLevelPrefix=${syslog_tag_mysqld} |
|||
fi |
|||
|
|||
if [[ "${flush_caches}" -gt 0 ]]; then |
|||
echo ExecStartPre=sync |
|||
echo ExecStartPre=sysctl -q -w vm.drop_caches=3 |
|||
fi |
|||
|
|||
if [[ "${numa_interleave}" -gt 0 ]]; then |
|||
echo |
|||
echo ExecStart=numactl --interleave=all ${cmd} '${OPTIONS}' |
|||
echo |
|||
fi |
|||
|
|||
[ -n "${CRASH_SCRIPT}" ] && echo FailureAction=${CRASH_SCRIPT} |
@ -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 |
|||
|
@ -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= |
@ -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= |
Write
Preview
Loading…
Cancel
Save
Reference in new issue