[2]supervisor的使用管理:實現對異常中斷的子進程的自動重啟(以redis為例)
阿新 • • 發佈:2018-06-22
program usr AI turn red 重新啟動 自動 t權限 可執行文件 1:下載
wget http://download.redis.io/releases/redis-3.2.8.tar.gz1
下載指定版本,可以登錄https://redis.io/download查看
2:安裝
tar zxvf redis-3.2.8.tar.gzcd redis-3.2.8makesudo make install1234
這時Redis 的可執行文件被放到了/usr/local/bin
3:配置
sudo mkdir /etc/redissudo cp redis.conf /etc/redis/6379.confsudo cp utils/redis_init_script /etc/redis/123
4:運行和關閉
cd /etc/redis1
#使用root權限運行sudo ./redis_init_script start12
#再打開一個終端,執行下面的命令關閉rediscd /etc/redis ./redis_init_script stop123
#也可以通過redis客戶端關閉redis-cli shutdown12
5:使用supervisor監控進程
#先打開supervisor配置文件sudo vi /etc/supervisord.conf12
在文件尾部添加代碼
[program:redisd];command=/etc/redis/redis_init_script start;不可以使用上面這種方式啟動redis進程,用這種方式,supervisor監控的是腳本redis_init_script,而不是rediscommand=/usr/local/bin/redis-server /etc/redis/6379.confstdout_logfile=/var/log/supervisor/redis.logstdout_logfile_maxbytes=1MBstdout_logfile_backups=10username=rootpassword=root_password123456789
6:更新supervisor配置
sudo supervisorctl update1
現在redis服務已經在後臺運行
7:關閉redis
在supervisord.conf文件中,[program:redisd]標誌意味著在管理redis服務時,使用redisd(在redis後面加了一個字母d)去操作。
所以,關閉redis服務的方法有以下幾種
sudo supervisorctl stop redisd1
#或者通過redis客戶端的方式關閉redis-cli shutdown12
8:再次重新啟動
supervisorctl start redisd1
更多supervisor操作,請查看:
linux進程管理工具supervisor http://blog.csdn.net/win_turn/article/details/60466562
[2]supervisor的使用管理:實現對異常中斷的子進程的自動重啟(以redis為例)