linux下 安装zookeeper,设置开机自启动

话不多说,直接上步骤

1、下载安装包


cd /usr/local

wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.6.1/apache-zookeeper-3.6.1-bin.tar.gz

这是清华大学的开源软件镜像网站,如果3.6.1的镜像不在了,直接去这个网站看看别的镜像,换个镜像下载

2、解压安装包

  tar -zxvf apache-zookeeper-3.6.1-bin.tar.gz

3、进去,修改配置文件

执行 
cp  zoo_sample.cfg zoo.cfg 

修改zoo.cfg

# The number of milliseconds of each tick
    # zookeeper 定义的基准时间间隔,单位:毫秒
  tickTime=2000
   # The number of ticks that the initial 
   # synchronization phase can take
   initLimit=10
   # The number of ticks that can pass between 
   # sending a request and getting an acknowledgement
   syncLimit=5
   # the directory where the snapshot is stored.
   # do not use /tmp for storage, /tmp here is just 
   # example sakes.
   # dataDir=/tmp/zookeeper
   # 数据文件夹
    dataDir=/tmp/zookeeper/data
   # 日志文件夹
    dataLogDir=/tmp/zookeeper/log
   # the port at which the clients will connect
   # 客户端访问 zookeeper 的端口号
  clientPort=2181
   # the maximum number of client connections.
   # increase this if you need to handle more clients
   #maxClientCnxns=60
    #自定义启动端口,防止冲突
    admin.serverPort=8888

   #
   # Be sure to read the maintenance section of the 
   # administrator guide before turning on autopurge.
   #
   # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
   #
   # The number of snapshots to retain in dataDir
   #autopurge.snapRetainCount=3
   # Purge task interval in hours
   # Set to "0" to disable auto purge feature
   #autopurge.purgeInterval=1 

dataDir=/tmp/zookeeper/data
dataLogDir=/tmp/zookeeper/log
这2个目录需要手动去创建

mkdir /tmp/zookeeper/data

mkdir /tmp/zookeeper/log

4、测试启动

到bin 目录下,启动程序。

5、设置服务器开机自启动

执行
cd /etc/rc.d/init.d/
vi zookeeper
在文件中输入,注意不要复制少了


#chkconfig:2345 20 90

#description:zookeeper

#processname:zookeeper
#jdk的路径,根据服务器情况自己修改
export JAVA_HOME=/usr/java/jdk1.8.0_231
#zk路径,根据情况修改
case $1 in
          start) su root /usr/local/apache-zookeeper-3.6.1-bin/bin/zkServer.sh start;;
          stop) su root /usr/local/apache-zookeeper-3.6.1-bin/bin/zkServer.sh stop;;
          status) su root /usr/local/apache-zookeeper-3.6.1-bin/bin/zkServer.sh status;;
          restart) su root /usr/local/apache-zookeeper-3.6.1-bin/bin/zkServer.sh restart;;
     *)  echo "require start|stop|status|restart"  ;;
esac
      

设置执行权限 

chmod 777 zookeeper

添加到启动项

chkconfig --add zookeeper


查看状态

chkconfig --list zookeeper

测试一下脚本

service zookeeper start
service zookeeper stop
service zookeeper restart
service zookeeper status

 

 

 

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值