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}