2、find / -name zoo.cfg
vim /etc/zookeeper/conf/zoo.cfg
配置内容如下:
maxClientCnxns=50
# 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=/var/lib/zookeeper/data
dataLogDir=/var/lib/zookeeper/dataLogDir //检查是否存在目录,若不存在,要在系统中创建这两个目录
# the port at which the clients will connect
clientPort=2181
autopurge.purgeInterval=3
autopurge.SnapRetainCount=3
server.1=192.168.232.100:2888:3888
server.2=192.168.232.101:2888:3888
server.3=192.168.232.102:2888:3888
3、把zoo.cfg配置文件拷贝到另外两个节点
scp /etc/zookeeper/conf/zoo.cfg root@192.168.232.101:/etc/zookeeper/conf/
scp /etc/zookeeper/conf/zoo.cfg root@192.168.232.102:/etc/zookeeper/conf/
4、如2中说明,在三个节点上创建相应的目录
mkdir -p /var/lib/zookeeper/datamkdir -p /var/lib/zookeeper/dataLogDir
5、在三台机器上的dataDir指定的目录下创建myid文件,其内容分别为zoo.cfg文件中的server.x的x(例如server.1=192.168.232.100:2888:3888,其对应的myid内容为1)
6、vim /etc/zookeeper/conf/java.env 内容如下:
# zk buffer size 64M
export JVMFLAGS="-Djute.maxbuffer=0x3FFFFC0 $JVMFLAGS"
# java heap size 1GB
export JVMFLAGS="-Xms1g -Xmx1g $JVMFLAGS" //该项设置为1g,根据自己机器的内存情况来设置,太大会导致zkServer.sh脚本启动失败
7、启动zookeeper
./zkServer.sh start
./zkServer.sh status