ZooKeeper 安裝,啓動,驗證

轉自:http://www.cnblogs.com/smartloli/p/4298430.html


2.7.1安裝

  將下載好的安裝包,解壓到指定位置,這裏爲直接解壓到當前位置,命令如下:

tar -zxvf zk-{version}.tar.gz

  修改zk配置,將zk安裝目錄下conf/zoo_sample.cfg重命名zoo.cfg,修改其中的內容:

複製代碼
# The number of milliseconds of each tick
# 服務器與客戶端之間交互的基本時間單元(ms) 
tickTime=2000   

# The number of ticks that the initial  
# synchronization phase can take 
# zookeeper所能接受的客戶端數量 
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. 
# 保存zookeeper數據,日誌的路徑
dataDir=/home/hadoop/data/zookeeper

# the port at which the clients will connect 
# 客戶端與zookeeper相互交互的端口 
clientPort=2181 
server.1= dn1:2888:3888 
server.2= dn2:2888:3888 
server.3= dn3:2888:3888

#server.A=B:C:D  其中A是一個數字,代表這是第幾號服務器;B是服務器的IP地址;C表示服務器與羣集中的“領導者”交換信息的端口;當領導者失效後,D表示用來執行選舉時服務器相互通信的端口。
複製代碼

  接下來,在配置的dataDir目錄下創建一個myid文件,裏面寫入一個0-255之間的一個隨意數字,每個zk上這個文件的數字要是不一樣的,這些數字應該是從1開始,依次寫每個服務器。文件中序號要與dn節點下的zk配置序號一直,如:server.1=dn1:2888:3888,那麼dn1節點下的myid配置文件應該寫上1。

2.7.2啓動

  分別在各個dn節點啓動zk進程,命令如下:

bin/zkServer.sh start

  然後,在各個節點輸入jps命令,會出現如下進程:

QuorumPeerMain

2.7.3驗證

  上面說的輸入jps命令,若顯示對應的進程,即表示啓動成功,同樣我們也可以輸入zk的狀態命令查看,命令如下:

bin/zkServer.sh status

  會出現一個leader和兩個follower。



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章