zookeeper cluster install note

本文提供了一步一步指导安装和配置 ZooKeeper 3.2.2 的教程,包括修改 zoo.cfg 文件设置集群映射、创建 myid 文件、启动所有节点、检查运行状态、创建节点并模拟领导选举过程等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

here is a handy steps to intall zk 3.2.2

 

a.modify to zoo.cfg to add machines mapping.
 note:server.1=master:2888:3888
 the first port is used to connect to master(or listen to followers if this is a leader)
 second one is used to leader election.
b.add a myid file which contains a id that correponding to the settings in zoo.cfg
 (set to else if more then one)
c.start in all nodes
 zkServer.sh start
d.check running
 zkServer.sh status
 #or(note the host must be the leader node,else others will get NOTHING response,  maybe one of the ensemble:leader or followers)
 echo ruok | nc <leader- host> 2181
 zkServer.sh status    #this will show who r leader/follow
e.creat a tree node in any host
 zkClient.sh
 create /cluster test
 then check it now in others to see cluster-well-running:
 get /cluster
f.let the leader to dead to simulate to 'leader-election' occurs:
 ssh to leader for one thing,then:
 kill -9 <pid>
 now u will see the event occurs mentioned above.

stop see below.

*note:during execute the zkServer.sh in some znodes,u will get a excetion like this:
 WARN  [QuorumPeer:/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@336] - Cannot open channel to 2 at election address ubuntu1/192.168.0.2:3888
 this is a normal info (u will see it's WARN level);
 'to 2' is the id set in znode ubuntu1;
 3888:it is attempted to be a leader ,say 'leader election'
*if u want to stop a node,that means leader in general, will be attempted to election again,
 so login to new leader,then run cmd:
 zkServer.sh stop
  for any nodes.

* click 'jps ' in any node to see,there is a process running :

QuorumPeerMain

 

u know,the nodes are peer for both leader and followers as the pid named.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值