在 CentOS 上,ZooKeeper 的启动脚本通常位于 /usr/lib/systemd/system/
或 /etc/init.d/
目录下
/usr/lib/systemd/system/zookeeper.service
或 /etc/init.d/zookeeper
。你可以使用 find
命令来查找它:sudo find / -name zookeeper.service 2>/dev/null
或
sudo find / -name zookeeper 2>/dev/null
[Unit]
Description=Apache ZooKeeper
After=network.target
[Service]
User=zookeeper
Group=zookeeper
ExecStart=/usr/bin/zkServer.sh start /path/to/zookeeper/config
ExecStop=/usr/bin/zkServer.sh stop /path/to/zookeeper/config
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
在这个例子中,ExecStart
和 ExecStop
行指向了 ZooKeeper 的可执行文件(zkServer.sh
)和配置文件(/path/to/zookeeper/config
)。请确保这些路径是正确的。
systemctl
或 service
命令启动、停止或重启 ZooKeeper 服务:启动:
sudo systemctl start zookeeper
或
sudo service zookeeper start
停止:
sudo systemctl stop zookeeper
或
sudo service zookeeper stop
重启:
sudo systemctl restart zookeeper
或
sudo service zookeeper restart
sudo systemctl status zookeeper
或
sudo service zookeeper status