zookeeper 简单集群配置
2016-06-19 09:32
369 查看
修改conf/zoo.cfg配置文件
首先在第一台机下配置一下信息
server.1=192.168.1.105:2888:3888 第一个端口2888是指follower服务器和leader服务器的通信端口,第二个端口3888指的是选举leader服务器时互相通信的端口
server.2=192.168.1.106:2888:3888
server.3=192.168.1.107:2888:3888
保存并退出。
利用命令 scp zoo.cfg root@192.168.1.106:opt/zookeeper/conf 把配置文件复制到106的机器中,同样也复制到107的机器中。
以下是105机器的文件配置:
# 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.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
server.1=192.168.1.105:2888:3888
server.2=192.168.1.106:2888:3888
server.3=192.168.1.107:2888:3888
然后找到zoo.cfg中的dataDir的配置项目,进入目录,默认为/tmp/zookeeper 在此目录中创建myid文件 105的myid填上1 106机器填上2 107机器填上3
配置完毕,启动zookeeper zkServer.sh start.注意各个服务器的防火墙。
利用telnet 192.168.1.105 2181 检查zookeeper状态,然后输入stat 出现以下内容
![](https://img-blog.csdn.net/20160619092207895?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
This Zookeeper instance is not currently serving requests 是因为zookeeper 只启动了一台,集群不生效(zookeeper 集群生效的前提是超过一半的机器能正常服务),不能对外服务。
所以要把另外一台 启动。然后再查看状态出现:
![](https://img-blog.csdn.net/20160619092607570?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
查看另外一台的状态:
![](https://img-blog.csdn.net/20160619093146468?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
集群模式就配置完毕。
首先在第一台机下配置一下信息
server.1=192.168.1.105:2888:3888 第一个端口2888是指follower服务器和leader服务器的通信端口,第二个端口3888指的是选举leader服务器时互相通信的端口
server.2=192.168.1.106:2888:3888
server.3=192.168.1.107:2888:3888
保存并退出。
利用命令 scp zoo.cfg root@192.168.1.106:opt/zookeeper/conf 把配置文件复制到106的机器中,同样也复制到107的机器中。
以下是105机器的文件配置:
# 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.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
server.1=192.168.1.105:2888:3888
server.2=192.168.1.106:2888:3888
server.3=192.168.1.107:2888:3888
然后找到zoo.cfg中的dataDir的配置项目,进入目录,默认为/tmp/zookeeper 在此目录中创建myid文件 105的myid填上1 106机器填上2 107机器填上3
配置完毕,启动zookeeper zkServer.sh start.注意各个服务器的防火墙。
利用telnet 192.168.1.105 2181 检查zookeeper状态,然后输入stat 出现以下内容
This Zookeeper instance is not currently serving requests 是因为zookeeper 只启动了一台,集群不生效(zookeeper 集群生效的前提是超过一半的机器能正常服务),不能对外服务。
所以要把另外一台 启动。然后再查看状态出现:
查看另外一台的状态:
集群模式就配置完毕。
相关文章推荐
- Oracle解锁scott账户
- 面向对象之构造函数以及静态变量(未完成)
- CSS基础
- 万无一失之网站的高可用架构
- 2016年Android开发流程
- CLRS 15.4最长公共子序列
- 【codevs】1069 关押罪犯
- 【Linux】进程概念与编程
- 深度学习与自然语言处理(3)_斯坦福cs224d Lecture 3
- 汇编和c函数交叉混合调用
- 瞬时响应之网站的高性能架构
- 第十六周学习进度
- 小白进阶之随机排列数组
- gdal将shp数据转换为geojson数据
- 大型网站架构演化
- 附加作业:源自刘乾老师的问题
- java通过Socket实现TCP网络通信
- [置顶] Web前端 之 RequireJS
- ios学习路线—静态变量,全局变量exterm,局部变量,实例变量
- 数据结构实验之栈四:括号匹配