说明: 前面的数据库文章中提到数据库初始化主主
所以这里就直接接着上文写了
写一个mysql.service
vim mysql.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(5.7)
After=network.target
After=syslog.target
Before=shutdown.target # 关机前操作
[Install]
WantedBy=multi-user.target
Alias=mysql.service
[Service]
User=mysql
Group=mysql
Type=forking
PIDFile=/var/lib/mysql/Devops-mysql-master.pid
#Disable service start and stop timeout logic of systemd for mysqld service.
TimeoutSec=0
#Execute pre and post scripts as root
PermissionsStartOnly=true
#Needed to create system tables
ExecStartPre=/usr/bin/mysqld_pre_systemd
#Start|Stop main service
ExecStart=/etc/init.d/mysqld start
ExecStop=/etc/init.d/mysqld stop
#Sets open_files_limit
LimitNOFILE = 5000
Restart=on-failure
RestartPreventExitStatus=1
PrivateTmp=false
配置了mysql.service直接推送到/usr/lib/systemd/system目录中
#添加了mysql.service后,需要daemon-reload
systemctl daemon-reload
查看数据库状态
#直接查看启动
systemctl status mysqld
systemctl start mysqld
原文地址:https://blog.51cto.com/linux1991/2421628
时间: 2024-10-10 13:34:05