centos7 systemctl 管理 mysql
admin
2023-05-16 09:42:08
0

centos 7 开始使用systemctl 管理服务


服务脚本目录 /etc/systemd/system/mysql.service

脚本如下:




#

# Simple MySQL systemd service file

#

# systemd supports lots of fancy features, look here (and linked docs) for a full list: 

#  http://www.freedesktop.org/software/systemd/man/systemd.exec.html

#

# Note: this file ( /usr/lib/systemd/system/mysql.service )

# will be overwritten on package upgrade, please copy the file to 

#

#  /etc/systemd/system/mysql.service 

#  

# to make needed changes.

# systemd-delta can be used to check differences between the two mysql.service files.

#


[Unit]

Description=MySQL Community Server

After=network.target

After=syslog.target


[Install]

WantedBy=multi-user.target

Alias=mysql.service


[Service]

User=mysql

Group=mysql


# Execute pre and post scripts as root

PermissionsStartOnly=true


# Needed to create system tables etc.

#ExecStartPre=/usr/bin/mysql-systemd-start pre



# Start main service

ExecStart=/application/mysql/bin/mysqld_safe


# Don't signal startup success before a ping works

#ExecStartPost=/usr/bin/mysql-systemd-start post


# Give up if ping don't get an answer

TimeoutSec=600


Restart=always

PrivateTmp=false


---


 mysqld_pre_systemd (RPM platforms), mysql-system-start (Debian platforms): Support script for the unit file. This script assists in creating the error log file only if the log location matches a pattern (/var/log/mysql*.log for RPM platforms, /var/log/mysql/*.log for Debian platforms). In other cases, the error log directory must be writable or the error log must be present and writable for the user running the mysqld process.



如果 mysql error log 设置在 /var/log 下


以下是percona mysql 设置


[root@c52cbe15cfa3 system]# cat mysqld.service 

#

# Systemd service file for Percona Server

#

# # This service file is to start PS just with mysqld_safe

#


[Unit]

Description=MySQL Percona Server

After=network.target

After=syslog.target


[Install]

WantedBy=multi-user.target

Alias=mysql.service


[Service]



# Execute pre and post scripts as root

PermissionsStartOnly=true

# Needed to create system tables etc.

ExecStartPre=/usr/bin/mysql-systemd pre


# Start main service

ExecStart=/usr/bin/mysqld_safe


# Don't signal startup success before a ping works

ExecStartPost=/usr/bin/mysql-systemd post


# Give up if ping don't get an answer

TimeoutSec=600


Restart=always

PrivateTmp=false


[root@c52cbe15cfa3 system]# pw




相关内容

热门资讯

360余名老人养老“投资”上千... 有白纸黑字的保本高息合同,有实体运营的养老活动中心,有持续开展的康养服务。这场看似稳赚不赔的养老投资...
美国民众抵制政府在旧金山修建移... 据凤凰卫视报道,旧金山湾区一处地块可能被用于修建非法移民拘留设施。对此,当地官员和民权团体5月15日...
蜜雪冰城上线黄仁勋“大佬同款”... 极目新闻记者 郭奕5月15日,有网友拍到英伟达CEO黄仁勋出现在北京南锣鼓巷,品尝了各类小吃,还喝了...
“扫码入企”为企业松绑减负 本报记者 刘 亮□ “扫码入企”本质上是通过数字化手段进一步规范涉企行政检查,解决企业长期反映强烈的...
高三女生高考前确诊罕见病,母亲... 极目新闻记者 张裕5月15日,武汉市第三十九中学成人礼现场,高三学生杨乐乐在母亲搀扶下走过“成人门”...
台中队誓师大会登场,黄国昌:民... 海峡导报综合报道 台湾民众党“台中队”16日亮相,跨足山海屯、市区目前提名6名市议员参选人,白营党主...
“美国稀土联盟跑不起来:日本不... 【文/观察者网 王一】美国想拉盟友重建稀土供应链,却发现队伍不好带。美国彭博社5月15日发长文分析称...
大连爱碧克取得管口自动辊凸台装... 国家知识产权局信息显示,大连爱碧克空调配件有限公司取得一项名为“一种管口自动辊凸台装置”的专利,授权...
免费开放!机器人足球赛等趣味科... 5月16日至17日,中国科学院第22届公众科学日在全国一百余家高校科研院所举行,并面向社会免费开放。...
“智云上海,智惠全城”中国电信... 5月15日,2026年中国电信第六届科技节上海站正式启幕。活动主论坛以“智云上海,智惠全城”为主题,...