linux 安装zookeeper+开机启动

1、下载:wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz

2、解压到user/local

3、cd    /usr/local/zookeeper-3.4.8/conf

     cp zoo_sample.cfg zoo.cfg 

     vi  zoo.cfg

# The number of milliseconds of each tick
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=/usr/zookeeper
dataLogDir=/usr/zookeeper/log
# the port at which the clients will connect
clientPort=2181

# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# 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

4、环境变量:

    vi  /etc/profile 最后增加:

export  ZOOKEEPER_INSTALL=/usr/local/zookeeper-3.4.8
export  PATH=$PATH:$ZOOKEEPER_INSTALL/bin

   保存后: sorce /etc/profile

5、启动:

    cd  /usr/local/zookeeper-3.4.8/bin

    执行: ./zkServer.sh  start

 

root@bogon bin]# ./zkServer.sh  start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@bogon bin]# ./zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181

  6、测试: ./zkCli.sh -server 127.0.0.1:2181

 

开机启动

1、在zkEnv.sh中指定当前用户jdk环境变量
export JAVA_HOME=/usr/java/jdk1.8.0_211/

2、在/etc/rc.d/init.d文件夹下创建zookeeper文件
内容:

#!/bin/bash
#chkconfig:2345 20 90
 
#description:zookeeper
 
#processname:zookeeper

case $1 in
        start) su root /usr/local/zookeeper-3.4.8/bin/zkServer.sh start;;
        stop) su root /usr/local/zookeeper-3.4.8/bin/zkServer.sh stop;;
        status) su root /usr/local/zookeeper-3.4.8/bin/zkServer.sh status;;
        restart) su /usr/local/zookeeper-3.4.8/bin/zkServer.sh restart;;
        *) echo "require start|stop|status|restart" ;;
esac

3、用命令chmod 修改一下zookeeper文件权限
chmod u+x zookeeper

4、chkconfig --add zookeeper 添加启动服务(默认就能自启动)
chkconfig --list 查看是否添加成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值