系统升至Centos7后,systemd替代initd成了pid 为1的进程,用于启动其它unit
习惯写init.d脚本,本以为写systemd也简单,实际写zookeeper systemd就碰到不少问题
[Unit]
Description=zookeeper.service
After=network.target
[Service]
Type=forking
User=zookeeper
Group=zookeeper
SyslogIdentifier=zk
Environment=ZOO_LOG4J_PROP=WARN,ROLLINGFILE
Environment=ZOO_LOG_DIR=/data/softwares/zookeeper-3.4.14/logs
Environment=ZOOPIDFILE=/home/zookeeper/zookeeper_server.pid
PIDFile=/home/zookeeper/zookeeper_server.pid
WorkingDirectory=/data/softwares/zookeeper-3.4.14
ExecStart=/data/softwares/zookeeper-3.4.14/bin/zkServer.sh start
ExecStop=/data/softwares/zookeeper-3.4.14/bin/zkServer.sh stop
ExecReload=/data/softwares/zookeeper-3.4.14/bin/zkServer.sh restart
LimitNPROC=65536
LimitNOFILE=104800
Restart=on-failure
[Install]
WantedBy=multi-user.target
问题出在Environment=ZOOPIDFILE=和PIDFile=,前者是zookeeper zkServer.sh监控zk process pid文件,后者是systemd监控 zk process pid文件,两者不一致的话conflict就出来了,systemdctl start启动不了。网上找了一大堆都没说到点子上。strace systemdctl start zookeeper也解决不了,journalctl -u zookeeper报一大堆不相关的错误。
网友评论