Linux安裝Zookeeper

Zookeeper能夠做爲分佈式集羣開發,本文是基於Centos7環境下安裝的Zookeeper,具體步驟以下文所示:html

(1)下載Zookeeper,這裏下載的是zookeeper-3.4.10.tar.gz,能夠使用Linux的wget命令,也能夠下載好安裝包,將其上傳至Linux環境中;下載的網址爲:apache

http://apache.fayea.com/zookeeper/
複製代碼

(2)將其解壓到/usr/local路徑下,解壓的命令以下:服務器

tar -zxvf zookeeper-3.4.10.tar.gz
複製代碼

(3)配置環境變量:使用命令分佈式

vi /etc/profile
複製代碼

查看profile文件的內容,在內容中添加以下語句:ide

在文件末尾添加此段內容: -- 開始和--中間的一段.(注意,儘可能保持環境變量名全大寫,下劃線隔開. 保持規範) -- 開始ui

export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.10
export PATH=$PATH:$ZOOKEEPER_HOME/bin
複製代碼

-- 結束this

(4)進入到zookeeper-3.4.10的conf文件夾下,使用以下命令:spa

cd /usr/local/zookeeper-3.4.10/conf/
複製代碼

(5)將zoo.sample.cfg拷貝出一份出來,將文件名強制zoo.cfg,使用以下命令:日誌

cp zoo_sample.cfg zoo.cfg
複製代碼

(6)使用以下命令對zoo.cfg文件內容進行編輯,code

vi zoo.cfg 
複製代碼

-- 按i進入編輯模式. 修改完成以後, esc退出編輯模式, 大寫字母Z雙擊便可保存.

在其後面添加zookeeper的文件路徑和日誌路徑,其內容以下:

#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=/tmp/zookeeper -- 這裏要設置一下文件路徑 路徑必須存在,不存在的話就新建一個唄

dataLogDir=/tmp/zookeeper/log -- 日誌路徑 路徑必須存在,不存在的話就新建一個唄

#the port at which the clients will connect

clientPort=2181 -- 若是是多機器的話,在clientPort處添加服務器的ip

#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.

#zookeeper.apache.org/doc/current…

#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

(7)進入到zookeeper的bin目錄下,

cd /usr/local/zookeeper-3.4.10/bin/
複製代碼

(8)啓動zookeeper的命令爲:

./zkServer.sh start
複製代碼

若是成功,顯示的內容以下:

JMX enabled by default Using config: /usr/local/zookeeper-3.4.10/bin/../conf/zoo.cfg Starting zookeeper ... STARTED

(9)查看zookeeper的狀態,檢測其是否啓動,使用以下命令:

./zkServer.sh status
複製代碼

輸出的內容以下: JMX enabled by default Using config: /usr/local/zookeeper-3.4.10/bin/../conf/zoo.cfg Mode: standalone (10)中止zookeeper的話,在bin目錄下,運行以下命令:

./zkServer.sh stop
複製代碼

中止運行zookeeper; 本文到此,zookeeper的安裝就算結束了。 若是本文侵權,請聯繫做者刪除

相關文章
相關標籤/搜索