本帖最后由 不二晨 于 2018-6-25 18:01 编辑
复制虚拟机
将上次的安装的单机模式的ZooKeeper服务器,copy出两份出来。ZooKeeper集群数量最好的单数个,因为电脑性能限制,采用三个主机节点。在克隆虚拟机之前,需要将运行中的虚拟机关闭。
![]()
在克隆虚拟机的类型上,我们需要选择完整克隆虚拟机,而不是选择克隆一个虚拟机的链接。
![]()
修改网络地址
在原来配置好的网络配置文件,修改ip地址,不要让ip地址在网络上造成冲突。
网络适配器的文件配置地址是/etc/sysconfig/network-scripts,修改ifcfg-ens33文件中ip地址信息。修改完网络地址后,需要把防火墙给关闭了,命令是systemctl stop firewalld.service
1 TYPE=Ethernet
2 PROXY_METHOD=none
3 BROWSER_ONLY=no
4 BOOTPROTO=dhcp
5 DEFROUTE=yes
6 IPV4_FAILURE_FATAL=no
7 IPV6INIT=yes
8 IPV6_AUTOCONF=yes
9 IPV6_DEFROUTE=yes
10 IPV6_FAILURE_FATAL=no
11 IPV6_ADDR_GEN_MODE=stable-privacy
12 NAME=ens33
13 UUID=2199e331-171c-4a63-958d-2c37d084a298
14 DEVICE=ens33
15 ONBOOT=yes
16 BOOTPROTO=static
17 IPADDR=192.168.28.124
19 NETMASK=255.255.255.0
20 GATEWAY=192.168.28.2
21 DNS1=192.168.0.1
修改zoo.cfg文件
1
2 # synchronization phase can take
3 initLimit=10
4 # The number of ticks that can pass between
5 # sending a request and getting an acknowledgement
6 syncLimit=5
7 # the directory where the snapshot is stored.
8 # do not use /tmp for storage, /tmp here is just
9 # example sakes.
10 #dataDir=/tmp/zookeeper
11 dataDir=/usr/local/service/zookeeper/data
12 dataLogDir=/usr/local/service/zookeeper/logs
13 # the port at which the clients will connect
14 clientPort=2181
15 # the maximum number of client connections.
16 # increase this if you need to handle more clients
17 #maxClientCnxns=60
18 #
19 # Be sure to read the maintenance section of the
20 # administrator guide before turning on autopurge.
21 #
22 # http://zookeeper.apache.org/doc/ ... html#sc_maintenance
23 #
24 # The number of snapshots to retain in dataDir
25 #autopurge.snapRetainCount=3
26 # Purge task interval in hours
27 # Set to "0" to disable auto purge feature
28 #autopurge.purgeInterval=1
29 server.1=192.168.28.124:2888:3888
30 server.2=192.168.28.125:2888:3888
31 server.3=192.168.28.126:2888:3888
将三个ZooKeeper配置文件中都要加上
server.1=192.168.28.124:2888:3888
server.2=192.168.28.125:2888:3888
server.3=192.168.28.126:2888:3888
格式是服务器ip地址:leader和follower通信的端口号:负责leader选举的通信端口号
写入myid文件
更改完网络,关闭了防火墙,我们需要在zoo.cfg中配置的dataDir路径中,写上myid文件,文件中的内容是我们配置的server.n中的n。也就是在192.168.28.124服务器上myid写入1,192.168.28.125服务器上写入2,以此类推。
启动服务,检查状态
向三台服务器发送启动zk服务的命令,检查状态
1 [root@localhost network-scripts]# zkServer.sh status
2 ZooKeeper JMX enabled by default
3 Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
4 Mode: follower
1 [root@localhost data]# zkServer.sh status
2 ZooKeeper JMX enabled by default
3 Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
4 Mode: follower
1 [root@localhost data]# zkServer.sh status
2 ZooKeeper JMX enabled by default
3 Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
4 Mode: leader
至此集群模式安装完成。 |
|