通过supervisor自启动kafka服务
一、supervisor安装:
yum install supervisor
echo_supervisord_conf > /etc/supervisord.conf
二、生成基础配置:
vi /etc/supervisord.conf
最后添加两行
[include]
files = /etc/supervisor/*.conf
三、创建目录
mkdir /etc/supervisor
四、创建kafka启动文件
vi /etc/supervisor/kafka.conf
[program:kafka]
command=kafka-server-start.sh /usr/local/kafka/kafka_2.11-1.1.0/config/server.properties
user=root
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/tmp/supervisor_kafka.log
redirect_stderr=true
五、启动supervisor
supervisord -c /etc/supervisord.conf
#查看supervisor是否启动
pgrep supervisord
# 关闭supervisord supervisorctl shutdown # 启动 supervisord 或者 supervisord -c 你的supervisord.conf路径 查看是否正常运行 supervisorctl status #更新新的配置到supervisord supervisorctl update # 重新启动配置中的所有程序 supervisorctl reload
# 单机多kafka /etc/supervisor/kafka1.conf [program:kafka1] command=/opt/kafka_2.13-2.4.0/bin/kafka-server-start.sh /opt/kafka_2.13-2.4.0/config/server.properties1 user=root autostart=true autorestart=true startsecs=10 stdout_logfile=/tmp/supervisor_kafka1.log redirect_stderr=true /etc/supervisor/kafka1.conf [program:kafka2] command=/opt/kafka_2.13-2.4.0/bin/kafka-server-start.sh /opt/kafka_2.13-2.4.0/config/server.properties2 user=root autostart=true autorestart=true startsecs=10 stdout_logfile=/tmp/supervisor_kafka2.log redirect_stderr=true kafka3.conf同理
运维虐我千万遍,我对运维如初恋。