Zookeeper cluster configuration and startup--combat

Source: Internet
Author: User

1, Prepare:

A: three LINXU servers:

10.112.29.177

10.112.29.172

10.112.29.174

command hostname to get the hostname of each machine

vm-10-112-29-177

vm-10-112-29-172

vm-10-112-29-174

Create separately

/opt/zookeeper/server1/data

/opt/zookeeper/server1/datalog

/opt/zookeeper/server2/data

/opt/zookeeper/server2/datalog

/opt/zookeeper/server3/data

/opt/zookeeper/server3/datalog

B: Download Zookeeper

Version: zookeeper-3.4.8.tar.gz

Decompression TAR-ZXVF zookeeper-3.4.8.tar.gz

zookeeper-3.4.8

C: Download JDK

Version: jdk-7u80-linux-x64.gz

Decompression TAR-ZXVF jdk-7u80-linux-x64.gz

Jdk1.7.0_80

D: Configure Java environment variables

/etc/profile file include:
Export java_home=/usr/java/jdk1.7.0_80
Export path= $PATH:/usr/java/jdk1.7.0_80/bin

Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Source/etc/profile//execution takes effect view JDK version java-version

Java Version "1.7.0_80"
Java (TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot (TM) 64-bit Server VM (build 24.80-b11, Mixed mode)

2,zookeeper Cluster Configuration A: Modify configuration file Rename Conf/zoo_sample.cfg profile mv zoo_sample.cfg zoo.cfg Modify zoo.cfg file

# The number of milliseconds of each tick
ticktime=2000
# The number of ticks that 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 are just
# example Sakes.

Datadir=/opt/zookeeper/server1/data
Datalogdir=/opt/zookeeper/server1/datalog

server.1=vm-10-112-29-177:2888:3888server.2=vm-10-112-29-172:2888:3888server.3=vm-10-112-29-174:2888:3888

# The port at which the clients would connect
clientport=2181

# The maximum number of the 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

The other two machines are configured as follows:

Datadir=/opt/zookeeper/server2/data
Datalogdir=/opt/zookeeper/server2/datalog

Datadir=/opt/zookeeper/server3/data
Datalogdir=/opt/zookeeper/server3/datalog

tickTime:zookeeper中使用的基本时间单位, 毫秒值。initLimit:这个配置项是用来配置 Zookeeper 接受客户端(这里所说的客户端不是用户连接 Zookeeper 服务器的客户端,而是 Zookeeper 服务器集群中连接到 Leader 的 Follower 服务器)初始化连接时最长能忍受多少个 tickTime 时间间隔数。这里设置为5表名最长容忍时间为 5* 2000= 10秒。syncLimit:这个配置标识 Leader 与 Follower 之间发送消息,请求和应答时间长度,最长不能超过多少个 tickTime 的时间长度,总的时间长度就是 2* 2000= 4秒。dataDir 和 dataLogDir 看配置就知道干吗的了,不用解释。clientPort:监听client连接的端口号,这里说的client就是连接到Zookeeper的代码程序。server.{myid}={ip}:{leader服务器交换信息的端口}:{当leader服务器挂了后, 选举leader的端口}maxClientCnxns:对于一个客户端的连接数限制,默认是60,这在大部分时候是足够了。但是在我们实际使用中发现,在测试环境经常超过这个数,经过调查发现有的团队将几十个应用全部部署到一台机器上,以方便测试,于是这个数字就超过了。修改zoo.cfg非常简单,然后还需要创建myid文件:cd server1echo 1> myid然后拷贝server1为server2和server3,并修改其中的zoo.cfg配置,当然也要修改myid的内容为2和3。下面给出3个server的zoo.cfg 内容:# server1tickTime=2000initLimit=5syncLimit=2dataDir=/opt/zookeeper/server1/datadataLogDir=/opt/zookeeper/server1/dataLogclientPort=2181server.1=vm-10-112-29-177:2888:3888server.2=vm-10-112-29-172:2888:3888server.3=vm-10-112-29-174:2888:3888

Zookeeper cluster configuration and startup--combat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.