pull/123/head
midoks 3 years ago
parent 13d1e87cfe
commit bc445aa07d
  1. 14
      plugins/mysql-apt/index.py
  2. 81
      plugins/mysql-apt/init.d/mysql.service.tpl

@ -262,6 +262,7 @@ def initMysql57Data():
serverdir = getServerDir() serverdir = getServerDir()
myconf = serverdir + "/etc/my.cnf" myconf = serverdir + "/etc/my.cnf"
user = pGetDbUser() user = pGetDbUser()
cmd = 'mysqld --defaults-file=' + myconf + \ cmd = 'mysqld --defaults-file=' + myconf + \
' --initialize-insecure --explicit_defaults_for_timestamp' ' --initialize-insecure --explicit_defaults_for_timestamp'
mw.execShell(cmd) mw.execShell(cmd)
@ -270,12 +271,23 @@ def initMysql57Data():
def initMysql8Data(): def initMysql8Data():
'''
chmod 644 /www/server/mysql-apt/etc/my.cnf
try:
mysqld --basedir=/usr --datadir=/www/server/mysql-apt/data --initialize-insecure
mysqld --defaults-file=/www/server/mysql-apt/etc/my.cnf --initialize-insecure
mysqld --initialize-insecure
'''
datadir = getDataDir() datadir = getDataDir()
if not os.path.exists(datadir + '/mysql'): if not os.path.exists(datadir + '/mysql'):
serverdir = getServerDir() serverdir = getServerDir()
user = pGetDbUser() user = pGetDbUser()
cmd = 'mysqld --basedir=/usr --datadir=' + datadir + ' --initialize-insecure' cmd = 'mysqld --basedir=/usr --datadir=' + datadir + ' --initialize-insecure'
mw.execShell(cmd) data = mw.execShell(cmd)
if data[1].find('ERROR') != -1:
exit("Init MySQL{} Data Error".format(8))
mw.execShell('chown -R mysql mysql ' + getServerDir()) mw.execShell('chown -R mysql mysql ' + getServerDir())
return False return False
return True return True

@ -1,63 +1,50 @@
# It's not recommended to modify this file in-place, because it will be # Copyright (c) 2015, 2022, Oracle and/or its affiliates.
# overwritten during package upgrades. If you want to customize, the
# best way is to use systemctl edit:
# #
# $ systemctl edit mysqld.service # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
# #
# this will create file # This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
# #
# /etc/systemd/system/mysqld.service.d/override.conf # 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, version 2.0, for more details.
# #
# which be parsed after the file mysqld.service itself is parsed. # You should have received a copy of the GNU General Public License
# # along with this program; if not, write to the Free Software
# For example, if you want to increase mysql's open-files-limit to 20000 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# add following when editing with command above:
# # MySQL systemd service file
# [Service]
# LimitNOFILE=20000
#
# Or if you require to execute pre and post scripts in the unit file as root, set
# PermissionsStartOnly=true
#
# For more info about custom unit files, see systemd.unit(5) or
# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
#
# Don't forget to reload systemd daemon after you change unit configuration:
# root> systemctl --system daemon-reload
[Unit] [Unit]
Description=MySQL 8.0 database server Description=MySQL Community Server
After=syslog.target Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target After=network.target
[Install]
WantedBy=multi-user.target
[Service] [Service]
Type=notify
User=mysql User=mysql
Group=mysql Group=mysql
Type=notify
ExecStartPre=/usr/libexec/mysql-check-socket ExecStartPre=+/usr/share/mysql-8.0/mysql-systemd-start pre
ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n ExecStart=/usr/sbin/mysqld
# Note: we set --basedir to prevent probes that might trigger SELinux alarms, TimeoutSec=0
# per bug #547485 LimitNOFILE = 10000
ExecStart=/usr/libexec/mysqld --defaults-file={$SERVER_PATH}/mysql-ya/etc/my.cnf --basedir=/usr --user=mysql
ExecStartPost=/usr/libexec/mysql-check-upgrade
ExecStopPost=/usr/libexec/mysql-wait-stop
# 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=false
Restart=on-failure Restart=on-failure
RestartPreventExitStatus=1 RestartPreventExitStatus=1
# Sets open_files_limit # Always restart when mysqld exits with exit code of 16. This special exit code
LimitNOFILE = 10000 # is used by mysqld for RESTART SQL.
RestartForceExitStatus=16
# Set enviroment variable MYSQLD_PARENT_PID. This is required for SQL restart command. # Set enviroment variable MYSQLD_PARENT_PID. This is required for restart.
Environment=MYSQLD_PARENT_PID=1 Environment=MYSQLD_PARENT_PID=1
[Install]
WantedBy=multi-user.target

Loading…
Cancel
Save