[4]supervisor使用管理:實現對異常中斷子進程的自動重啟(以mysql為例)

來源:互聯網
上載者:User

標籤:download   檔案目錄   檔案   space   actor   error:   fan   服務管理   iss   

實現進程服務管理,supervisort監聽到進程死後,會自動將它重新拉起,很方便的做到進程自動回復的功能,不再需要自己寫shell指令碼來控制
安裝過程
1、到官網下載最新版本,解壓編譯,
tar -zxvf supervisor-3.3.4.tar.gz 
cd supervisor-3.3.4
python setup.py install
可能會遇到如下錯誤:
Installed /usr/lib/python2.7/site-packages/supervisor-3.3.4-py2.7.egg
Processing dependencies for supervisor==3.3.4
Searching for meld3>=0.6.5
Reading https://pypi.python.org/simple/meld3/
Download error on https://pypi.python.org/simple/meld3/: [Errno 1] _ssl.c:504: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed -- Some packages may not be found!
Couldn't find index page for 'meld3' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [Errno 1] _ssl.c:504: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed -- Some packages may not be found!
No local packages or download links found for meld3>=0.6.5
error: Could not find suitable distribution for Requirement.parse('meld3>=0.6.5')
解決辦法:
tar -xf meld3-1.0.1.tar.gz
cd meld3-1.0.1
python setup.py install
重新執行安裝supervisor包
組建組態檔案
echo_supervisord_conf > /etc/supervisord.conf
查看設定檔
cat /etc/supervisord.conf |grep -v ";"|grep -v "^$"

[[email protected] ~]# cat /etc/supervisord.conf |grep -v ";"|grep -v "^$"
[unix_http_server]
[supervisord]
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
配置WEB管理進程
[inet_http_server]       
port=127.0.0.1:9001     ; 伺服器ip
username=xxx        ;自訂
password=xxx        ;自訂
建立管理設定檔目錄
mkdir /etc/supervisord

編輯設定檔,在設定檔底部,配置include
[include]
files=/etc/supervisord/*.conf
啟動
supervisord -c /etc/supervisord.conf

#在

/etc/supervisord目錄下添加mysql一個執行個體的設定檔,如下:


[[email protected] supervisord]# cat mysql_3306.conf 
[program:mysql_3306]
#command=/etc/init.d/mysql start --port=3306 --sleep=3 --tryies=3 --daemon
command=/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/var/lib/mysql/ --pid-file=/var/lib/mysql/host-172-16-32-152.pid --basedir=/usr/local/mysql --log-error=/var/lib/mysql/mariadb.log --user=mysql  
autostart=true
user=mysql
autorestart=unexpected
numprocs=1
redirect_stderr=true
startsecs=10
stdout_logfile=/var/log/block_push.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/block_push.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB

最後執行:

supervisorctl reload


[4]supervisor使用管理:實現對異常中斷子進程的自動重啟(以mysql為例)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.