zookeeer 集群和伪集群模式

时间:2024-06-14 13:33:26
环境变量设置:
# .bash_profile # Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi # User specific environment and startup programs export PATH=$PATH:$HOME/bin export PS1="`hostname`:\$PWD# "
export PATH
PATH=$PATH:$HOME/bin:/usr/local/redis/bin:/usr/local/mongodb/bin/
export PATH
export JAVA_HOME=/usr/java/jdk1.8.0_20
export PATH=$JAVA_HOME/bin:$PATH server1:
配置文件:
zjtest7-redis:/opt/zookeeper/conf# pwd
/opt/zookeeper/conf zjtest7-redis:/opt/zookeeper/conf# cat zoo.cfg | grep -v "^#"
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/zookeeper/server1/data
dataLogDir=/opt/zookeeper/server1/logs
clientPort=2181
server.1=192.168.32.80:2888:3888
server.2=192.168.32.81:2888:3888
server.3=192.168.32.82:2888:3888 zjtest7-redis:/opt/zookeeper/server1/data# pwd
/opt/zookeeper/server1/data
zjtest7-redis:/opt/zookeeper/bin# cat /opt/zookeeper/server1/data/myid
1
Server 2配置:
zjtest7-redis2:/opt/zookeeper/conf# cat zoo.cfg | grep -v "^#"
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/zookeeper/server2/data
dataLogDir=/opt/zookeeper/server2/logs
clientPort=2181
server.1=192.168.32.80:2888:3888
server.2=192.168.32.81:2888:3888
server.3=192.168.32.82:2888:3888 zjtest7-redis2:/opt/zookeeper/server2# cd data/
zjtest7-redis2:/opt/zookeeper/server2/data# ls
mydata
zjtest7-redis2:/opt/zookeeper/server2/data# cat myid
2 Server 3配置:
zjtest7-haproxy:/opt/zookeeper/conf# cat zoo.cfg | grep -v "^#"
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/zookeeper/server3/data
dataLogDir=/opt/zookeeper/server3/logs
clientPort=2181
server.1=192.168.32.80:2888:3888
server.2=192.168.32.81:2888:3888
server.3=192.168.32.82:2888:3888 验证集群可用性:
zjtest7-redis:/opt/zookeeper/bin# telnet 192.168.32.80 2181
Trying 192.168.32.80...
Connected to 192.168.32.80.
Escape character is '^]'.
stat
Zookeeper version: 3.4.8--1, built on 02/06/2016 03:18 GMT
Clients:
/192.168.32.80:54143[0](queued=0,recved=1,sent=0) Latency min/avg/max: 0/0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0x0
Mode: follower ##集群角色
Node count: 4
Connection closed by foreign host.
zjtest7-redis:/opt/zookeeper/bin# 伪集群模式:
redis01:/zookeeper/server1/conf# cat zoo.cfg | grep -v "^#"
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/zookeeper/server1/data
dataLogDir=/zookeeper/server1/logs
clientPort=2181
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890