Linux系统zookeeper集群配置

2018-03-15  本文已影响27人  17碎那年

总共3台机器, 只要配置好其中一台机器然后copy到另外两台就好了

1.创建目录

[root@nn1 ~]# cd /usr/local/
[root@nn1 local]# mkdir zookeeper
[root@nn1 local]# cd zookeeper
将zookeeper压缩包移动到这个新建目录下
[root@nn1 zookeeper]# mv /home/admin/software/zookeeper-3.4.11.tar.gz ./
解压
[root@nn1 zookeeper]# tar -zxvf zookeeper-3.4.11.tar.gz 
进入
[root@nn1 zookeeper]# cd zookeeper-3.4.11/
记得修改环境变量
[root@nn1 zookeeper-3.4.11]# vim /etc/profile
export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.11
export PATH=$PATH:$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf

2进入conf文件夹,修改配置

[root@nn1 zookeeper-3.4.11]# cd conf/
首先要将zoo_simple.cfg的名字修改为zoo.cfg
[root@nn1 conf]# mv zoo_simple.cfg zoo.cfg

3详细配置

[root@nn1 conf]# vim 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=/tmp/zookeeper
dataLogDir=/tmp/zookeeper/log
# the port at which the clients will connect
clientPort=2181
server.1=192.168.0.240:2881:3881
server.2=192.168.0.241:2882:3882
server.3=192.168.0.242:2883:3883

# 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

修改dataDir和dataLogDir
没有目录就创建目录

解释一下server
server.X=A:B:C

X-代表服务器编号

A-代表ip

B和C-代表端口,这个端口用来系统之间通信

要记得自己吧dataDir的路径改为什么了 去这个路径下创建文件叫myid
并且在文件里写入server.X对应的X

4复制粘贴

将配置好的全部拷贝到另外两台电脑相同的目录去
scp -r /usr/local/zookeeper root@192.168.0.241:/usr/local/
scp -r /usr/local/zookeeper root@192.168.0.242:/usr/local/

5启动

首先刷新一下环境变量
source /etc/profile
启动目录:
/usr/local/zookeeper/zookeeper-3.4.11/bin
启动命令:
./zkServer.sh start
查看状态:
./zkServer.sh status
启动成功后查看状态 显示一个leader两个follower

切记 要把防火墙关掉
完成.

上一篇下一篇

猜你喜欢

热点阅读