zookeeper集羣搭建

####環境 zookeeper集羣:服務器

192.168.10.91 id:1app

192.168.10.92 id:2ui

192.168.10.93 id:3日誌

####安裝zookeepercode

  • 安裝jdk,略

# tar xzvf /tmp/zookeeper-3.4.6.tar.gzserver

# mkdir -p /data/app/zookeeper-3.4.6/{data,log}requests

# cp /data/app/zookeeper-3.4.6/conf/zoo_sample.cfg /data/app/zookeeper-3.4.6/conf/zoo.cfgit

# vi /data/app/zookeeper-3.4.6/conf/zoo.cfgio

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/app/zookeeper-3.4.6/data   #修改data目錄
clientPort=2181
server.1=192.168.10.91:2888:3888      #集羣中每臺服務器的信息
server.2=192.168.10.92:2888:3888      #server.id  ,id惟一,需寫入data目錄中
server.3=192.168.10.93:2888:3888

# echo 1 > /data/app/zookeeper-3.4.6/data/myid #將每臺zookeeper中的配置文件中的serverid寫入data目錄中的myid文件中集羣

啓動zookeeper

  • 啓動第一臺zookeeper # /data/app/zookeeper-3.4.6/bin/zkServer.sh start
JMX enabled by default
Using config: /data/app/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

# echo stat |nc 127.0.0.1 2181

This ZooKeeper instance is not currently serving requests
  • 啓動第二臺zookeeper # /data/app/zookeeper-3.4.6/bin/zkServer.sh start
JMX enabled by default
Using config: /data/app/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

# echo stat |nc 127.0.0.1 2181

Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT
Clients:
 /127.0.0.1:41847[0](queued=0,recved=1,sent=0)

Latency min/avg/max: 0/0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x100000000
Mode: leader             #第二臺服務器啓動後集羣創建,這臺被選爲leader
Node count: 4
  • 啓動第三臺zookeeper # echo stat |nc 127.0.0.1 2181
Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT
Clients:
 /127.0.0.1:46892[0](queued=0,recved=1,sent=0)

Latency min/avg/max: 0/0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x100000000
Mode: follower          #加入集羣,mode爲follower
Node count: 4

####zookeeper啓動日誌 在當前目錄下的zookeeper.out,啓動日誌會輸出到這裏

相關文章
相關標籤/搜索