1、下載zookeeper的安裝包
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz
2、解壓壓縮包
tar zxvf zookeeper-3.3.6.tar.gz
3、在zookeeper的跟目錄下創建兩個文件夾data和datalog
這兩個路徑主要是用來存放zk的數據以及日志的(待會需要手動在配置文件中設置)
在data目錄下創建一個myid的文件,里面的值可以給個任意的值,主要用於集群中區分某個勢力
4、將入zookeeper的conf目錄下,復制zoo_sample.cfg文件並自定義配置
cp zoo_sample.cfg zoo.cfg
vi zoo.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=/www/websoft/zookeeper-3.3.6/data dataLogDir=/www/websoft/zookeeper-3.3.6/datalog # the port at which the clients will connect clientPort=2181 server.100=192.168.1.21:2888:3888
這里只是配置了一個單機的zookeeper,需要配置成集群的話只要在最后面加上其他服務器的ip和端口就行了(類似server.100=192.168.1.21:2888:3888)
5、啟動zookeeper
cd /www/websoft/zookeeper-3.3.6
bin/zkServer.sh start &
zk啟動后查看zk的啟動情況
bin/zkServer.sh status
當出現這種信息就說明你的zk已經安裝成功了