ubuntu 16.04 lts 安装 zookeeper-3.4.9

阅读更多

ubuntu 16.04 lts 安装 zookeeper-3.4.9

 

       一台机器上模拟3个 zk server的集群安装

cd program/

mkdir zookeeper

cd software/

tar zxvf zookeeper-3.4.9.tar.gz -C /home/ubuntu/program/zookeeper

cd /home/ubuntu/program/zookeeper
mv zookeeper-3.4.9 zookeeper-1
cp -RP zookeeper-1 zookeeper-2
cp -RP zookeeper-1 zookeeper-3

cd /home/ubuntu/program/zookeeper
mkdir tmp
cd tmp
mkdir zk1
cd zk1
mkdir data
mkdir log
cd /home/ubuntu/program/zookeeper/tmp
cp -RP zk1 zk2
cp -RP zk1 zk3

       每个目录下创建zoo.cfg配置文件

cd /home/ubuntu/program/zookeeper/zookeeper-1/conf


/home/ubuntu/program/zookeeper/zookeeper-1/conf/zoo.cfg 内容如下:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/home/ubuntu/program/zookeeper/tmp/zk1/data
dataLogDir=/home/ubuntu/program/zookeeper/tmp/zk1/log
clientPort=2181
server.1=localhost:2287:3387
server.2=localhost:2288:3388
server.3=localhost:2289:3389
/home/ubuntu/program/zookeeper/zookeeper-2/conf/zoo.cfg 内容如下:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/home/ubuntu/program/zookeeper/tmp/zk2/data
dataLogDir=/home/ubuntu/program/zookeeper/tmp/zk2/log
clientPort=2182
server.1=localhost:2287:3387
server.2=localhost:2288:3388
server.3=localhost:2289:3389
/home/ubuntu/program/zookeeper/zookeeper-3/conf/zoo.cfg 内容如下:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/home/ubuntu/program/zookeeper/tmp/zk3/data
dataLogDir=/home/ubuntu/program/zookeeper/tmp/zk3/log
clientPort=2183
server.1=localhost:2287:3387
server.2=localhost:2288:3388
server.3=localhost:2289:3389


       在每个zk server配置文件的dataDir所对应的目录下,必须创建一个名为myid的文件,其中的内容必须与zoo.cfg中server.x 中的x相同,即:

/home/ubuntu/program/zookeeper/tmp/zk1/data/myid 中的内容为1,对应server.1中的1
/home/ubuntu/program/zookeeper/tmp/zk2/data/myid 中的内容为2,对应server.2中的2
/home/ubuntu/program/zookeeper/tmp/zk3/data/myid 中的内容为3,对应server.3中的3



       启动验证 :
cd /home/ubuntu/program/zookeeper/zookeeper-1/bin ./zkServer.sh start
cd /home/ubuntu/program/zookeeper/zookeeper-2/bin ./zkServer.sh start
cd /home/ubuntu/program/zookeeper/zookeeper-3/bin ./zkServer.sh start

       可以启动客户端测试下:
./zkCli.sh -server localhost:2181
成功后,应该会进到提示符下,类似下面这样:
[zk: localhost:2181(CONNECTED) 0]

 

你可能感兴趣的:(zookeeper,Ubuntu)