zookeeper安裝配置

來源:互聯網
上載者:User

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

 

配置:

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

如此而已!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.