1、使用VMware安装3台ubuntu-16.04.3-server,机器节点奇数
ubuntu-server-zkp-1, ubuntu-server-zkp-2, ubuntu-server-zkp-3
安装是用户都是zhang
2、关闭防火墙ufw
sudo ufw disable
3、设置固定ip
ubuntu-server-zkp-1 192.168.1.131
ubuntu-server-zkp-2 192.168.1.132
ubuntu-server-zkp-3 192.168.1.133
sudo vim /etc/network/interfaces
修改:
# The primary network interface
auto ens33
iface ens33 inet static
address 192.168.1.131
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/zookeeper-3.4.11/
6、创建数据目录
/home/zhang/awin/zookeeper-3.4.11/data
7、修改配置文件
cd /home/zhang/awin/zookeeper-3.4.11/conf
vim zoo.cfg
写入:
tickTime=2000
dataDir=/home/zhang/awin/zookeeper-3.4.11/data
clientPort=2181
initLimit=5
syncLimit=2
server.1=192.168.1.131:2888:3888
server.2=192.168.1.132:2888:3888
server.3=192.168.1.133:2888:3888
8、写入myid文件
ubuntu-server-zkp-1 1
ubuntu-server-zkp-2 2
ubuntu-server-zkp-3 3
cd /home/zhang/awin/zookeeper-3.4.11/data
echo '1' > myid
9、启动
cd /home/zhang/awin/zookeeper-3.4.11/bin
启动:./zkServer.sh start
打印日志启动:./zkServer.sh start-foreground
10、查看jps结果
zhang@ubuntu:~/awin/zookeeper-3.4.11/bin$ jps
915 Jps
890 QuorumPeerMain
zhang@ubuntu:~/awin/zookeeper-3.4.11/bin$
11、命令行进入
cd /home/zhang/awin/zkp/zookeeper-3.4.11/bin
./zkCli.sh -server 192.168.1.131:2181
网友评论