1、使用VMware安装1台ubuntu-16.04.3-server
ubuntu-server-zkp-sham
安装是用户都是zhang
2、关闭防火墙ufw
sudo ufw disable
3、设置固定ip
sudo vim /etc/network/interfaces
修改:
# The primary network interface
auto ens33
iface ens33 inet static
address 192.168.1.122
gateway 192.168.1.1
netmask 255.255.255.0
dns-nameservers 192.168.0.1, 192.168.1.1
4、zookeeper安装包
zookeeper-3.4.11.tar.gz
5、安装包解压到三个路径下,机器节点奇数
/home/zhang/awin/zkp-1/zookeeper-3.4.11/
/home/zhang/awin/zkp-2/zookeeper-3.4.11/
/home/zhang/awin/zkp-3/zookeeper-3.4.11/
6、创建数据目录
/home/zhang/awin/zkp-1/zookeeper-3.4.11/data
/home/zhang/awin/zkp-2/zookeeper-3.4.11/data
/home/zhang/awin/zkp-3/zookeeper-3.4.11/data
7、修改配置文件
cd /home/zhang/awin/zkp-1/zookeeper-3.4.11/conf
vim zoo.cfg
写入:
tickTime=2000
dataDir=/home/zhang/awin/zkp-1/zookeeper-3.4.11/data
clientPort=2181
initLimit=5
syncLimit=2
server.1=192.168.1.122:2888:3888
server.2=192.168.1.122:4888:5888
server.3=192.168.1.122:6888:7888
cd /home/zhang/awin/zkp-2/zookeeper-3.4.11/conf
vim zoo.cfg
写入:
tickTime=2000
dataDir=/home/zhang/awin/zkp-2/zookeeper-3.4.11/data
clientPort=3181
initLimit=5
syncLimit=2
server.1=192.168.1.122:2888:3888
server.2=192.168.1.122:4888:5888
server.3=192.168.1.122:6888:7888
cd /home/zhang/awin/zkp-3/zookeeper-3.4.11/conf
vim zoo.cfg
写入:
tickTime=2000
dataDir=/home/zhang/awin/zkp-3/zookeeper-3.4.11/data
clientPort=4181
initLimit=5
syncLimit=2
server.1=192.168.1.122:2888:3888
server.2=192.168.1.122:4888:5888
server.3=192.168.1.122:6888:7888
8、写入myid文件
cd /home/zhang/awin/zkp-1/zookeeper-3.4.11/data
echo '1' > myid
cd /home/zhang/awin/zkp-2/zookeeper-3.4.11/data
echo '2' > myid
cd /home/zhang/awin/zkp-3/zookeeper-3.4.11/data
echo '3' > myid
9、启动,三个都执行
cd /home/zhang/awin/zkp-1/zookeeper-3.4.11/bin
启动:./zkServer.sh start
打印日志启动:./zkServer.sh start-foreground
10、查看jps结果
zhang@ubuntu:~/awin/zkp$ jps
2644 QuorumPeerMain
3115 Jps
2575 QuorumPeerMain
2687 QuorumPeerMain
zhang@ubuntu:~/awin/zkp$
11、命令行进入
cd /home/zhang/awin/zkp/zookeeper-3.4.11/bin
./zkCli.sh -server 192.168.1.122:2181

clipboard.png

clipboard.png

clipboard.png