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




相关内容

热门资讯

日本最新民调公布:76%民众支... 日本《琉球新报》2日报道,日本舆论调查协会8月1日公布的一项最新民意调查结果显示,76%的日本民众认...
疯狂降智的谷歌,彻底沦为“美国... 如果要问,现在谁家的AI能力最强?ChatGPT、Claude、DeepSeek各有千秋,吵上三天三...
公职人员婚内多次向他人转账52... 8月2日,安徽亳州市城市管理局发布情况通报:近日,有媒体报道我局下属园林建设管理服务中心主任白某某涉...
特朗普抨击“亲密盟友”:不知道... 【环球网报道 记者 索炎琦】在美国总统特朗普推动下,华盛顿林肯纪念堂前的倒影池6月初被改造为“蓝底”...
浙江做小程序浙江做小程序定制的... 在浙江地区,浙江做小程序浙江做小程序定制通常被企业视为连接线上业务与线下服务的技术手段。无论是零售商...
雷军说「晚安」被指营销,小米高... 7月30日晚,小米举办“澎程”技术发布会,推出全新“小米昆仑技术架构”及澎程系列增程双车。 发布会结...
雷军谈澎程全系“不挑油”,网友... 近日,小米创始人雷军在社交平台发文表示,小米澎程增程新车全系支持92号、95号、98号汽油,该内容发...
谷歌Gemini Spark智... IT之家 8 月 2 日消息,谷歌于 7 月 31 日宣布将 Gemini Spark 智能体开放给...
蓝牙耳机杀死了手机音质,这并非... 关于手机音质这事儿肯定得从苹果说起。 2016年iPhone 7发布会上,库克一脸这是勇气的表情,把...
顾客报警“大盘鸡怎么能有土豆,... 大盘鸡是不少人喜爱的大众美食,近日,上海市公安局宝山分局杨行派出所的90后社区民警陈嘉文,因为一次关...