安装ZooKeeper的一些记录

主要安装过程时按照网上大部分博客中的方法:

  1. 安装jdk
  2. 下载zookeeper的程序包,解压到任意可以用的目录,假设为/usr/zk
  3. 设置环境变量ZOOKEEPER_HOME=/usr/zk/zookeeper.x.x.x.,并将$ZOOKEEPER_HOME/bin$ZOOKEEPER_HOME/conf添加到PATH中
  4. 配置文件
    示例文件为/usr/zk/zookeeper.x.x.x/conf/zoo_sample.cfg,将其名称更改为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=/tmp/zookeeper
# 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
server.1 = 192.168.30.184:2888:3888
server.2 = 192.168.30.190:2888:3888
server.3 = 192.168.30.191:2888:3888
server.4 = 192.168.30.192:2888:3888
server.5 = 192.168.30.193:2888:3888
  1. 上面配置文件中的dataDir=/tmp/zookeeper,因此要创建这个文件夹
  2. zookeeper启动时,需要用到myid文件指定节点id,这个myid文件需要自己创建放在在dataDir目录下,内容就为server.1对应的1、2、3、4、5…,视节点而定
  3. 启动各个节点的zookeeper服务程序,如果启动出错,在当前目录中查看zookeeper.out日志文件。
#zkServer.sh start

遇到l了问题

zookeeper.out文件中就一句 command ‘java’ cannot found,
说明java环境没有配置好,但是运行java -version可以正常输出版本号
原因:启动时加了sudo导致的。
sudo zkServer.sh start,加了sudo会导致环境改变,验证如下:

archlab@worker92:/opt/zookeeper-3.4.9/bin$ sudo java -version
sudo: java: command not found
archlab@worker92:/opt/zookeeper-3.4.9/bin$ 

其他的没什么问题。防火墙时已经关闭的。

启动后,可以看一下jps:

archlab@worker92:/opt/zookeeper-3.4.9/bin$ jps
6421 Jps
6269 QuorumPeerMain
archlab@worker92:/opt/zookeeper-3.4.9/bin$ 

各节点都启动之后,通过status命令查看状态:

archlab@worker92:/opt/zookeeper-3.4.9/bin$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Mode: leader
archlab@worker92:/opt/zookeeper-3.4.9/bin$ 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值