ZooKeeper服务器集群环境配置实测
来源:互联网 发布:账号绑定网络 编辑:程序博客网 时间:2024/05/19 18:11
1、下载zookeeper压缩包
去官网下载zookeeper压缩包:http://zookeeper.apache.org/
本人测试时用的是zookeeper-3.4.3版本,接下来都已该版本进行描述。
2、修改配置文件
解压zookeeper-3.4.3.tar,进入到conf目录,将zoo_sample.cfg拷贝一份命名为zoo.cfg(Zookeeper 在启动时会找这个文件作为默认配置文件),打开该文件进行修改为以下格式(注意权限问题,如果最后配置有问题请检查过程中权限是否正确)
# 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.
# the port at which the clients will connect
clientPort=2181
#
# 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=1a
dataDir=/home/Hadoop/temp/zookeeper/data
server.0=10.10.10.213:2888:3888
server.1=10.10.10.213:2888:3888
server.2=10.10.10.213:2888:3888
配置项详解(声明,这段详解摘抄网上的,由于版本太多,已经不清楚哪个才是原创了,所以借鉴冒犯之处,还望原博主见谅):
tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。
除了修改 zoo.cfg 配置文件,集群模式下还要配置一个文件 myid,这个文件在 dataDir 目录下,这个文件里面就有一个数据就是 A 的值,Zookeeper 启动时会读取这个文件,拿到里面的数据与 zoo.cfg 里面的配置信息比较从而判断到底是那个 server。
initLimit:这个配置项是用来配置 Zookeeper 接受客户端(这里所说的客户端不是用户连接 Zookeeper 服务器的客户端,而是 Zookeeper 服务器集群中连接到 Leader 的 Follower 服务器)初始化连接时最长能忍受多少个心跳时间间隔数。当已经超过 10 个心跳的时间(也就是 tickTime)长度后 Zookeeper 服务器还没有收到客户端的返回信息,那么表明这个客户端连接失败。总的时间长度就是 5*2000=10 秒。
syncLimit:这个配置项标识 Leader 与 Follower 之间发送消息,请求和应答时间长度,最长不能超过多少个 tickTime 的时间长度,总的时间长度就是 2*2000=4 秒。
server.A=B:C:D:其中 A 是一个数字,表示这个是第几号服务器;B 是这个服务器的 ip 地址;C 表示的是这个服务器与集群中的 Leader 服务器交换信息的端口;D 表示的是万一集群中的 Leader 服务器挂了,需要一个端口来重新进行选举,选出一个新的 Leader,而这个端口就是用来执行选举时服务器相互通信的端口。如果是伪集群的配置方式,由于 B 都是一样,所以不同的 Zookeeper 实例通信端口号不能一样,所以要给它们分配不同的端口号。
3、启动zookeeper
将zookeeper-3.4.3分别拷贝到3个服务器中(注意权限问题,并且建议目录相同,方便管理和降低出错率),进入zookeeper-3.4.3目录,启动zookeeper
bin/zkServer.sh start
此时如果报错先不理会,继续在另两台服务器中执行相同操作。
4、检查配置是否成功
待3台服务器均启动后,如果过程正确的话zookeeper应该已经自动选好leader,进入每台服务器的zookeeper-3.4.3目录,执行以下操作查看zookeeper启动状态
bin/zkServer.sh status
如果出现以下代码表示安装成功了
JMX enabled by default
Using config: /home/Hadoop/zookeeper-3.4.3/bin/../conf/zoo.cfg
Mode: follower
- ZooKeeper服务器集群环境配置实测
- Zookeeper集群环境配置
- Zookeeper集群环境配置
- ZooKeeper集群环境安装与配置
- ZooKeeper集群环境安装与配置
- ZooKeeper集群环境安装与配置
- ZooKeeper集群环境安装与配置
- ZooKeeper集群环境的配置与安装
- zookeeper+activemq配置消息中间件集群 服务器配置
- zookeeper+activemq配置消息中间件集群 服务器配置
- zookeeper+activemq配置消息中间件集群 服务器配置
- 搭建ZooKeeper服务器集群
- 搭建Zookeeper服务器集群
- 搭建zookeeper服务器集群
- 搭建ZooKeeper服务器集群
- linux上部署zookeeper伪集群【实测可用】
- zookeeper集群环境搭建
- zookeeper 集群环境搭建
- Field XXXX input value is longer than screen field-BDC
- Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法
- 虚拟地球原理与实现
- 深度学习框架Keras学习系列(二):神经网络与BP算法(Neural Network and BP Algorithm)
- 解决传送到后台乱码和值为null问题
- ZooKeeper服务器集群环境配置实测
- NOIP 2017 普及组 棋盘 chess
- Maven 安装与环境变量配置
- spring-web整合(学生类增删改查web的实现)
- 助力中国芯片业崛起,潘文明2017全国高校FPGA巡讲开幕
- [LeetCode]Maximum Subarray题解
- 【Scikit-Learn 中文文档】十:交叉分解
- 数据库主键字段取值-UUID
- 二叉树的初始化及其添加和遍历JAVA