Linux設定zookeeper開機自啟
阿新 • • 發佈:2018-12-09
1.建立目錄
在etc/systemd/system
目錄下建立zookeeper.service
檔案,該檔案檔名可以隨便起,字尾.service
不可改變
2.在檔案內編寫
[Unit] Description=Zookeeper-2181 After=network.target [Service] Type=forking Environment=ZOO_LOG_DIR=/usr/local/zookeeper-2181/log Environment=PATH=/usr/local/java/jdk1.8/bin:/usr/local/java/jdk1.8/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin PIDFile=/usr/local/zookeeper-2181/data/zookeeper_server.pid ExecStart=/usr/local/zookeeper-2181/bin/zkServer.sh start ExecStop=/usr/local/zookeeper-2181/bin/zkServer.sh stop ExecReload=/usr/local/zookeeper-2181/bin/zkServer.sh restart [Install] WantedBy=multi-user.target
其中[Service]
下的zookeeper-2181
為zookeeper檔案目錄
3.重新載入系統服務
使用命令systemctl daemon-reload
4.設定開機自啟
使用命令systemctl enable zookeeper.service
,enable後跟的是剛才建立的檔名
5.關閉開機自啟
使用命令systemctl disable zookeeper.service
,enable後跟的是剛才建立的檔名