tar -zxvf zookeeper-3.4.6.tar.gz
cp -a conf/zoo_sample.cfg conf/zoo.cfg
修改配置文件
vi conf/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. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/opt/zookeeper # the port at which the clients will connect clientPort=2181 # 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. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # 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 server.1=centos1:2888:3888 server.2=centos2:2888:3888 server.3=centos3:2888:3888
这里我使用的3台虚拟机,这里主要设置server.X的X参数
在对应的每台机子上的/opt/zookeeper/myid设置为对应的X
将zk的文件scp到centos1,2,3各自一份
增加内存
zkEnv.sh
#在文件底部增加
export JVMFLAGS="-Xms1024m -Xmx2048m $JVMFLAGS"
查询内存大小
ps -ef|grep zookeeper
#查询pid
jmap --heap pid
启动
./bin/zkServer.sh start
停止
./bin/zkServer.sh stop
测试zk服务
jps
出现QuorumPeerMain或者
执行$ zkCli.sh -server centos1:2181,检查指定服务器是否成功启动。
zkCli.sh -server centos1:2181 Connecting to centos1:2181 2016-01-26 16:30:51,461 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT 2016-01-26 16:30:51,467 [myid:] - INFO [main:Environment@100] - Client environment:host.name=CentOS1 2016-01-26 16:30:51,467 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_65 2016-01-26 16:30:51,475 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2016-01-26 16:30:51,475 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre 2016-01-26 16:30:51,475 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/home/
dubbo上使用
dubbo.registry.address=zookeeper://centos1:2181?backup=10.0.30.139:2181