我有一台安装了 Apache Kafka 的 Ubuntu 16.04 机器。start_kafka.sh
目前,我可以通过使用具有以下内容的脚本使其完美运行:
JMX_PORT=17264 KAFKA_HEAP_OPTS="-Xms1024M -Xmx3072M" /home/kafka/kafka_2.11-0.10.1.0/bin/kafka-server-start.sh -daemon /home/kafka/kafka_2.11-0.10.1.0/config/server.properties
现在,我想使用supervisor
它来自动重启进程,如果它失败并在重启机器后立即启动。问题是我无法supervisor
启动 Kafka。
我supervisor
使用安装pip
并将此配置文件放置在/etc/supervisord.conf
:
; Supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
[program:kafka]
command=/home/kafka/kafka_2.11-0.10.1.0/start_kafka.sh ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
startsecs=10 ; # of secs prog must stay up to be running (def. 1)
startretries=3 ; max # of serial start failures when starting (default 3)
;autorestart=unexpected ; when to restart if exited after running (def: unexpected)
;exitcodes=0,2 ; 'expected' exit codes used with autorestart (default 0,2)
stopsignal=TERM ; signal used to kill process (default TERM)
stopwaitsecs=180 ; max num secs to wait b4 SIGKILL (default 10)
stdout_logfile=NONE ; stdout log path, NONE for none; default AUTO
;environment=A="1",B="2" ; process environment additions (def no adds)
当我尝试启动 Kafka 时,出现以下错误:
# supervisorctl start kafka
kafka: ERROR (spawn error)
主管日志 (at /tmp/supervisord.log
) 包含以下内容:
2017-01-23 22:10:24,532 INFO spawned: 'kafka' with pid 21311
2017-01-23 22:10:24,536 INFO exited: kafka (exit status 127; not expected)
2017-01-23 22:10:25,542 INFO spawned: 'kafka' with pid 21312
2017-01-23 22:10:25,559 INFO exited: kafka (exit status 127; not expected)
2017-01-23 22:10:27,562 INFO spawned: 'kafka' with pid 21313
2017-01-23 22:10:27,567 INFO exited: kafka (exit status 127; not expected)
2017-01-23 22:10:30,571 INFO spawned: 'kafka' with pid 21314
2017-01-23 22:10:30,576 INFO exited: kafka (exit status 127; not expected)
2017-01-23 22:10:31,578 INFO gave up: kafka entered FATAL state, too many start retries too quickly
必须说我已经尝试删除-daemon
标志start_kafka.sh
以使用supervisor
但没有成功。
有人知道发生了什么吗?
我终于设法让主管与卡夫卡一起工作,但有两个变化:
-daemon
标志的 Kafka,因为主管需要非守护进程来管理这是工作配置:
start_kafka.sh
supervisord.conf