zookeeper (伪)集群模式的安装

来源:互联网 发布:淘宝刷心悦会员封号 编辑:程序博客网 时间:2024/05/20 23:04

1)下载

wget http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

2)解压

tar zxvf zookeeper-3.4.6.tar.gz

3)配置

cd zookeeper-3.4.6
cp -rf conf/zoo_sample.cfg conf/zoo.cfg
vim conf/zoo.cfg

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.

#用于存放数据快照的文件夹,同事用于集群标识 ID 的 myid 文件也放在这儿(一个配置文件只能包含一个 dataDir,即使它被注释掉了)

dataDir=/usr/local/zooDataDir1

dataLogDir=/usr/local/zooDataLogDir

# 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

# zookeeper 集群中的每两台机器都是互连的

# 以下是集群其他服务的配置,格式: server.服务器ID=服务器IP:端口1:端口2

server.1=localhost:2888:3888

server.2=localhost:12888:13888

server.3=localhost:22888:23888

# 其中,端口1用来主动连接其他机器,端口2用来接受其他机器的连接,共同使zookeeper集群融为一体

# 服务器ID,在 dataDir(前面的一个配置项)这个目录下新建一个 myid 的文件,文件内容分别是 1,2,3。。。

4)启动zookeeper

依次启动每个节点: 
sh zkServer.sh start

5)进入zookeeper

sh zkCli.sh 

6)Java客户端的连接地址

localhost:2181,localhost:12181,localhost:22181
0 0
原创粉丝点击