操作方法
请自行下载安装配置zookeeper的服务器环境 本经验仅仅介绍如何配置zookeeper的开机自动启动
首先请登陆你的linux服务器 用cd 命令切换到/etc/rc.d/init.d/目录下
接着用touch zookeeper创建一个文件
然后为这个文件添加可执行权限 chmod +x zookeeper
接着用vi zookeeper来编辑这个文件
接着在zookeeper里面输入如下内容 #!/bin/bash #chkconfig:2345 20 90 #description:zookeeper #processname:zookeeper case $1 in start) su root /usr/local/sw/zookeeper/bin/zkServer.sh start;; stop) su root /usr/local/sw/zookeeper/bin/zkServer.sh stop;; status) su root /usr/local/sw/zookeeper/bin/zkServer.sh status;; restart) su root /usr/local/sw/zookeeper/bin/zkServer.sh restart;; *) echo "require start|stop|status|restart" ;; esac
然后保存退出 先按esc 然后按:键盘 接这个输入wq即可保存退出
这个时候我们就可以用service zookeeper start/stop来启动停止zookeeper服务了
最后一点我们需要开机自动启动 所以需要添加到启动里面 使用chkconfig --add zookeeper命令吧zookeeper添加到开机启动里面
添加完成之后接这个使用chkconfig --list 来看看我们添加的zookeeper是否在里面
如果上面的操作都正常的话;你就可以重启你的linux服务器了
如果您觉得本经验有帮助,请点击正下方的或右上角的“大拇指”或“分享”或“关注TA”给我支持和鼓励 为了方便下次寻找,您可以点击“收藏”收藏本经验