zookeeper 集羣安裝

今天閒來無事,從新安裝zookeeper 環境。因爲我的有幾臺虛擬主機。總共四臺服務器。html

其中選擇三臺作zookeeper集羣。具體ip以下:linux

IP地址  主機名稱
100.xx.xx.31 master
100.xx.xx.72 slave1 
100.xx.xx.122 slave2

如合配置主機名,能夠修改linux hosts文件。具體文件路徑: /var/hosts,內容以下:apache

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
100.xx.xx.31   xxxx-xxxx
100.xx.xx.31   master
100.xx.xx.72   slave1
100.xx.xx.122  slave2
~              服務器

修改完上述配置事後,下載zookeeper, 我下載的版本:zookeeper-3.4.9  dom

下載完成,直接解壓,zookeeper 目錄結構:maven

drwxr-xr-x 10 1001 1001    4096 Aug 23 15:42 .
drwxr-xr-x  6 root root    4096 Dec  4 12:20 ..
drwxr-xr-x  2 1001 1001    4096 Dec  4 02:07 bin
-rw-rw-r--  1 1001 1001   83539 Aug 23 15:39 build.xml
-rw-rw-r--  1 1001 1001   90824 Aug 23 15:39 CHANGES.txt
drwxr-xr-x  2 1001 1001    4096 Dec  4 02:04 conf
drwxr-xr-x 10 1001 1001    4096 Aug 23 15:39 contrib
drwxr-xr-x  2 1001 1001    4096 Aug 23 15:44 dist-maven
drwxr-xr-x  6 1001 1001    4096 Aug 23 15:40 docs
-rw-rw-r--  1 1001 1001    1953 Aug 23 15:39 ivysettings.xml
-rw-rw-r--  1 1001 1001    3499 Aug 23 15:39 ivy.xml
drwxr-xr-x  4 1001 1001    4096 Aug 23 15:40 lib
-rw-rw-r--  1 1001 1001   11938 Aug 23 15:39 LICENSE.txt
-rw-rw-r--  1 1001 1001     171 Aug 23 15:39 NOTICE.txt
-rw-rw-r--  1 1001 1001    1770 Aug 23 15:39 README_packaging.txt
-rw-rw-r--  1 1001 1001    1585 Aug 23 15:39 README.txt
drwxr-xr-x  5 1001 1001    4096 Aug 23 15:39 recipes
drwxr-xr-x  8 1001 1001    4096 Aug 23 15:40 src
-rw-rw-r--  1 1001 1001 1368238 Aug 23 15:39 zookeeper-3.4.9.jar
-rw-rw-r--  1 1001 1001     819 Aug 23 15:42 zookeeper-3.4.9.jar.asc
-rw-rw-r--  1 1001 1001      33 Aug 23 15:39 zookeeper-3.4.9.jar.md5
-rw-rw-r--  1 1001 1001      41 Aug 23 15:39 zookeeper-3.4.9.jar.sha1  ide

找到conf 目錄ui

cp zoo_sample.cfg   zoo.cfgthis

修改zoo.cfg 文件:spa

# 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.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/var/work/data/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888

~                            

根據須要調整你要修改標好的配置。

須要說明下zookeeper  幾個端口的意思:

zookeeper監聽三個端口: 2181用來監聽zookeeper客戶端鏈接, 2888, 若是是領導者, 用來監聽跟隨者鏈接, 3888用來在選舉領導者階段, 用來監聽其餘服務器的鏈接。

配置文件修改完成後,須要建立myid 文件,myid 文件存在data目錄下,本次安裝data目錄:/var/work/data/zookeeper 

根據zoo.cfg 配置,分別在不一樣server 上myid寫入:1,2,3 。

ok, 基本搞定,接下來啓動zookeeper . 

[root@xxxx   bin]# ./zkServer.sh  start     

停用zookeeper 

[root@xxxx bin]# ./zkServer.sh  stoo

大功告成,下次咱們再分享zookeeper 詳細配置。  

相關文章
相關標籤/搜索