1.使用yum命令安装supervisor
yum install -y epel-release
yum install -y supervisor
2.修改supervisor配置
cd /etc
vim supervisord.conf
# web登录界面
[inet_http_server] ; inet (TCP) server disabled by default
port=0.0.0.0:9001 ; (ip_address:port specifier, *:port for all iface)
username=admin ; (default is no username (open server))
password=Cocktail_py_123 ; (default is no password (open server))
# 命令行
[supervisorctl]
serverurl=unix:///var/run/supervisor/supervisor.sock ; use a unix:// URL for a unix socket
serverurl=http://0.0.0.0:9001 ; use an http:// url to specify an inet socket
;username=chris ; should be same as http_username if set
;password=123 ; should be same as http_password if set
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history ; use readline history if available
# 相应配置文件,这里需要绝对路径
[include]
files = /etc/supervisord.d/*.ini
3. .ini配置文件文件
cd /etc/supervisord.d/
vim redis.ini
# redis配置文件
[program:redis]
command=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
autostart=true
autorestart=true
startsecs=3
# 注意 redis.conf文件需要修改
# daemonize no
vim zookeeper.ini
# zookeeper配置文件
[program:zookeeper]
command=/usr/local/zookeeper/bin/zkServer.sh start-foreground
user=root
autostart=true
autorestart=true
startsecs=3
vim kafka.ini
# kafka配置文件
[program:kafka]
command=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties
user=root
autostart=true
autorestart=true
startsecs=3
vim es.ini
# elasticsearch配置文件
[supervisord]
minfds=65536
minprocs=32768
[program:es-node]
command = /data/elasticsearch-6.0.0/bin/elasticsearch
directory = /data/elasticsearch-6.0.0
user = elk
startsecs = 3
redirect_stderr = true
stdout_logfile_maxbytes = 50MB
stdout_logfile_backups = 10
stdout_logfile = /data/elasticsearch-6.0.0/logs/supervisor.log
vim cerebro.ini
# cerebro配置文件
[program:cerebro-node]
command = /opt/cerebro-0.8.1/bin/cerebro -Dhttp.port=12345 -Dhttp.address=0.0.0.0
directory = /opt/cerebro-0.8.1/
user = elk
startsecs = 3
redirect_stderr = true
stdout_logfile_maxbytes = 100MB
stdout_logfile_backups = 10
stdout_logfile = /opt/cerebro-0.8.1/logs/supervisor.log
4.以配置文件的方式启动supervisor
supervisord -c /etc/supervisord.conf
5.supervisor相关命令
systemctl enable supervisord # 开机自启动
systemctl status supervisord # 查看supervisord服务状态
# ps -ef|grep supervisord # 查看是否存在supervisord进程
# systemctl reload supervisord # 重新加载
# systemctl restart supervisord
# systemctl start supervisord # 启动supervisord服务
1、使用如下命令更新Supervisor的配置。
supervisorctl update
如果设置了账号密码就需要
supervisorctl -uxxxxx -pxxxx update
2、重启所需的服务
supervisorctl restart program_name
[program:rabbitmq_worker]
command=php /home/wwwroot/rabbitmq/worker/receive.php
process_name=%(program_name)s_%(process_num)02d ;多进程名称肯定不同,匹配多个
numprocs=4 ;启动多个进程
autostart=true ;是否随supervisor启动
autorestart=true ;是否在挂了之后重启,意外关闭后会重启,比如kill掉!
startsecs=5
startretries=3 ;启动尝试次数
stderr_logfile=/tmp/rabbitmq_worker_err.log ;标准输出的位置
stdout_logfile=/tmp/rabbitmq_worker_out.log ;标准错误输出的位置