zookeeper的集群部署步骤

一、使用WinSCP远程录三台服务器

二、使用XShell5分别连接三台服务器,对其使用命令进行远程操作

三、分别在三台服务器下建立zookeeper的文件夹

        mkdir zookeeper

四、分别在三台服务器上下载zookeeper-3.4.10(或在一台服务上下载,然后复制到其他两台),并解压,名称分别为zookeeper-3.4.10_1,ookeeper-3.4.10_2,ookeeper-3.4.10_3

       tar -czvf zookeeper-3.4.10.tar.gz ./zookeeper-3.4.10_1

五、定位到conf路径下,创建文件zoo.cfg

       cd zookeeper-3.4.10_1/conf/        (另外两台同样)

       touch zoo.cfg

六、分别在zookeeper-3.4.10_1,zookeeper-3.4.10_3,zookeeper-3.4.10_3下创建data文件夹,并在data文件夹下创建logs文件夹

       cd ../           (另外两台同样)

       mkdir data

       cd data

       mkdir logs

七、分别修改三个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=/home/softwares/zookeeper/zookeeper-3.4.10_1/data  
dataLogDir=/home/softwares/zookeeper/zookeeper-3.4.10_1/data/logs
# 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=0.0.0.0:2888:3888
server.2=180.76.234.29:4888:5888
server.3=180.76.234.29:6888:788

1)分别将dataDir和dataLogDir的路径修改为实际路径

2)由于三台服务器部署在不同的机器上,所以它们的端口号clientPort可以设为一样的,也可以设为不一样。

3)server.X=A:B:C 其中

   X:是一个数字,表示这是第几号server

   A:  是该server所在的IP地址,分别写三台服务器的IP地址

     B:   配置该server和集群中的leader交换信息所使用的的端口,由于三台服务器部署在不同的机器上,所以可以设置为一样,也可以设置为不一样

     C:   配置选举leader时所使用的端口,由于三台服务器部署在不同的机器上,所以可以设置为一样,也可以设置为不一样

八、分别在/zookeeper-3.4.10_1/data,/zookeeper-3.4.10_2/data,/zookeeper-3.4.10_3/data路径下创建myid,并分别在文件里写入1,2,3。

     touch myid

九、分别进入/zookeeper-3.4.10_1/bin,/zookeeper-3.4.10_2/bin,/zookeeper-3.4.10_3/bin目录,输入命令:./zkServer.sh start 启动服务器。使用./zkServer.sh status命令查看三台服务器的运行状态。使用./zkServer.sh stop 命令停止服务器运行。

      

猜你喜欢

转载自www.cnblogs.com/mercuryji/p/zookeeper_deploy_cluster.html