1.下載下傳Zookeeper安裝包,上傳到伺服器中:https://zookeeper.apache.org/
2.建立Zookeeper主機使用者(按需)
useradd zookeeper echo “zookeeper:${pwd}” |chpasswd
3.建立zookeeper的dataDir、dataLogDir目錄:
mkdir -p /home/zookeeper/${dataDir} /home/zookeeper/{$dataLogdir}
4.在${zookeeper_install_path}/conf/下建立:zoo.cnf配置檔案,添加如下内容:
# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial# synchronization phase can takeinitLimit=10# The number of ticks that can pass between# sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just# example sakes.dataDir=${dataDir}dataLogDir=${dataLogdir}# the port at which the clients will connectclientPort=${port}# the maximum number of client connections.# increase this if you need to handle more clientsmaxClientCnxns=300## 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 dataDirautopurge.snapRetainCount=10# Purge task interval in hours# Set to "0" to disable auto purge featureautopurge.purgeInterval=60server.1=*.*.*.*:${sync_port1}:${sync_port2}server.2=*.*.*.*:${sync_port1}:${sync_port2}server.3=*.*.*.*:${sync_port1}:${sync_port2}
5.按需修改zoo.cnf配置檔案,clientPort、dataDir、dataLogDir、server1.server2.server3......
6.在${zookeeper_install_path}/bin/zkEnv.sh檔案中添加如下資訊(3.6.2版本),不啟動export
export JVMFLAGS=" -Dzookeeper.admin.enableServer=false $JVMFLAGS"
7.在zoo.cnf配置檔案中,dataDir路徑下添加myid檔案,如上,内容為zoo.cnf配置檔案server.1中的數字1。
8.把配置好的zookeeper包,打包後拷貝到其它伺服器上,并修改myid
tar -zcvf ${tar.gz_name_file} ${zookeeper_path}
9.分别啟動zookeeper節點:
${/home/zookeeper/}/bin/ ./zkServer.sh start
10.zookeeper添加ACL通路權限:
addauth digest ${username}:${passwd}setAcl /${path} auth:${username}:${passwd}:cdrwa#通路:addauth digest ${username}:${passwd}