zookeeper安裝配置


安裝zookeeper也很簡單,下載zookeeper-3.1.1.tar.gz,解壓到/home/hezhiming/zookeeper-3.1.1zookeeper要部署到各台機器的相同目錄下,且具有相同的配置文件。

 

配置:

clientPort 

監聽客戶端連接的端口; 

dataDir 

存儲內存中數據庫快照的位置; 

注意 應該謹慎地選擇日志存放的位置,使用專用的日志存儲設備能夠大大地提高系統的性能,如果將日志存儲在比較繁忙的存儲設備上,那么將會在很大程度上影響系統的性能。 

tickTime 

基本事件單元,以毫秒為單位。它用來控制心跳和超時,默認情況下最小的會話超時時間為兩倍的 tickTime 。 

server.1=10.15.107.142:2888:3888

#server.2=hadoop.cluster.second_master:2888:3888

#server.3=hadoop.cluster.slave1:2888:3888

增加server.x選項,配置運行zookeeper的機器主機名或是IP地址,2888表示zookeeper程序監聽端口,3888表示zookeeper選舉通信端口。

 

注意:如果zookeeper啟動不了,把系統默認防火牆關閉后再試:sudo service iptables stop

 

我的虛擬機linux上的zookeeper配置:

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.

dataDir=/hadoop/zookeeper-3.3.6/zookeeper_data

# the port at which the clients will connect

clientPort=3355

server.1=10.15.82.166:2555:3555

 

啟動和關閉zookeeper服務:

hfx@ubuntu:/hadoop/zookeeper-3.3.6/bin$ ./zkServer.sh start

JMX enabled by default

Using config: /hadoop/zookeeper-3.3.6/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

hfx@ubuntu:/hadoop/zookeeper-3.3.6/bin$ ./zkServer.sh stop

JMX enabled by default

Using config: /hadoop/zookeeper-3.3.6/bin/../conf/zoo.cfg

Stopping zookeeper ... STOPPED

 

監聽:

hfx@ubuntu:/hadoop/zookeeper-3.3.6/bin$ echo ruok | nc 127.0.0.1 3355

imok

 

這樣就代表了zookeeper服務啟動成功啦。

集群的zookeeper配置其實也是如此:

比如我想配3台機器的偽分布,copy3份配置文件

-rwxrw-r--  1 hfx hfx  502 Mar  3 17:19 zoo1.cfg*
-rwxrw-r--  1 hfx hfx  502 Mar  3 17:19 zoo2.cfg*
-rwxrw-r--  1 hfx hfx  502 Mar  3 17:20 zoo3.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.
dataDir=/hadoop/zookeeper-3.3.6/zookeeper_data1
# the port at which the clients will connect
clientPort=3351

 

server.1=10.15.91.115:8881:7771
server.2=10.15.91.115:8882:7772
server.3=10.15.91.115:8883:7773

再建3個文件夾存放數據

drwxrwxr-x  3 hfx  hfx     4096 Mar 11 00:29 zookeeper_data1/
drwxrwxr-x  3 hfx  hfx     4096 Mar 11 00:29 zookeeper_data2/
drwxrwxr-x  3 hfx  hfx     4096 Mar 11 00:29 zookeeper_data3/

記得每個文件夾下建一個myid的文件,里面寫1或者2或者3。

啟動

./zkServer.sh start zoo1.cfg
./zkServer.sh start zoo2.cfg
./zkServer.sh start zoo3.cfg

如此而已!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM