mysql中reload作用_【mysql笔记】mysql启动脚本中的reload实现原理(kill -HUP pid)

kill -HUP pid

pid 是进程标识。

如果想要更改配置而不需停止并重新启动服务,请使用该命令。在对配置文件作必要的更改后,发出该命令以动态更新服务配置。

根据约定,当您发送一个挂起信号(信号 1 或 HUP)时,大多数服务器进程(所有常用的进程)都会进行复位操作并重新加载它们的配置文件。

【案例】

在 不重启sshd服务的情况下,动态把sshd监听的端口号由220 改为22.

[root@test01 mysql]# netstat -nltp | grep ssh | grep -v grep

tcp        0      0 0.0.0.0:220                 0.0.0.0:*                   LISTEN      22634/sshd

tcp        0      0 :::220                      :::*                        LISTEN      22634/sshd

[root@test01 mysql]# grep 220 /etc/ssh/sshd_config

Port 220

[root@test01 mysql]# sed -i 's/^Port 220/Port 22/g' /etc/ssh/sshd_config

[root@test01 mysql]# egrep '^Port' /etc/ssh/sshd_config

Port 22

[root@test01 mysql]# ps -ef|grep sshd|grep -v grep|grep usr|awk '{print $2}'|xargs kill -HUP

[root@test01 mysql]# netstat -nltp | grep ssh | grep -v grep

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      22653/sshd

tcp        0      0 :::22                       :::*                        LISTEN      22653/sshd

[root@test01 mysql]#

【案例】

Mysql服务启动脚本中的reload、force-reload 参数。

[root@test01 mysql]# /etc/init.d/mysql

Usage: mysql  {start|stop|restart|reload|force-reload|status}  [ MySQL (Percona Server) options ]

来自/etc/init.d/mysql:

'reload'|'force-reload')

if test -s "$mysqld_pid_file_path" ; then

read mysqld_pid

kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL (Percona Server)"

touch "$mysqld_pid_file_path"

else

log_failure_msg "MySQL (Percona Server) PID file could not be found!"

exit 1

fi

;;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值