Zookeeper之集群搭建-yellowcong
来源:互联网 发布:跳蚤街二手市场软件 编辑:程序博客网 时间:2024/05/22 06:42
之前讲的都是单机的一个zookeeper的安装,这次我们玩集群的操作,通过脚本完成数据的启动,通过脚本来管理zookeeper的集群
架构设计
zookeeper安装
1 zoo.cfg配置
#官方的包wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz#我七牛的安装包wget http://yellowcong.qiniudn.com/zookeeper-3.4.10.tar.gz #解压tar -zxvf zookeeper-3.4.10.tar.gz#修改配置文件cp zoo_sample.cfg zoo.cfg#修改配置文件vim zoo.cfg
以下是配置文件,自己做的时候,需要注意修改dataDir和dataLogDir还有端口配置
# synchronization phase can takeinitLimit=10# The number of ticks that can pass between# sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just# example sakes.#数据存储目录dataDir=/tmp/zookeeper1/data#日志地址dataLogDir=/tmp/zookeeper1/logs# the port at which the clients will connectclientPort=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#配置集群,#server.1 前面这个1 需要在$dataDir 目录建立myid文件写上这个id#127.0.0.1 这个ip 如果你是多个机器,那就注意点,写自己机器的ip#2222 第一个2222是各个子节点的数据交流端口#2225 第二个端口是用于竞选,当某个节点挂掉了,选择主节点server.1=127.0.0.1:2222:2225server.2=127.0.0.1:3333:3335server.3=127.0.0.1:4444:4445
2 目录建立
建立目录的节点,同时需要添加myid的号 ,注意每个节点的id和节点的myid文件不能搞错了,刚刚我就搞错了,我说咋一个节点咋都起不来啊。
---------------------节点一------------------------#创建日志和存储目录mkdir -p /tmp/zookeeper1/data /tmp/zookeeper1/logs#添加pidecho 1 > /tmp/zookeeper1/data/myid ---------------------节点二------------------------mkdir -p /tmp/zookeeper2/data /tmp/zookeeper2/logsecho 2 > /tmp/zookeeper2/data/myid ---------------------节点三------------------------mkdir -p /tmp/zookeeper3/data /tmp/zookeeper3/logsecho 3 > /tmp/zookeeper3/data/myid #查看myid文件信息,一定要和当前节点对应上cat /tmp/zookeeper1/data/myid cat /tmp/zookeeper2/data/myid cat /tmp/zookeeper3/data/myid
目录结构
3 启动服务
#建立脚本启动,这样省事vim zookeeper.sh#给执行权限chmod +x zookeeper.sh
zookeeper.sh脚本
#!/bin/bashSERVER1="/usr/local/zookeeper/zookeeper1/zookeeper-3.4.10/bin/zkServer.sh"SERVER2="/usr/local/zookeeper/zookeeper2/zookeeper-3.4.10/bin/zkServer.sh"SERVER3="/usr/local/zookeeper/zookeeper3/zookeeper-3.4.10/bin/zkServer.sh"case $1 instart) echo "start zookeeper" sh $SERVER1 start sh $SERVER2 start sh $SERVER3 start ;;stop) echo "stop zookeeper" sh $SERVER1 stop sh $SERVER2 stop sh $SERVER3 stop ;;restart) echo "restart zookeeper" sh $SERVER1 restart sh $SERVER2 restart sh $SERVER3 restart ;;status) echo "zookeeper info" sh $SERVER1 status sh $SERVER2 status sh $SERVER3 status ;;*) echo "./zookeeper.sh start|stop|restart" exit 1 ;;esacexit 0
脚本截图,这个地方有简单的启动信息
4 设定开机启动
vim /etc/rc.localsu - root -c '/usr/local/zookeeper/zookeeper.sh start'
开机如果没有生效,请参考我的另一篇文章:
http://blog.csdn.net/yelllowcong/article/details/78424025
阅读全文
0 0
- Zookeeper之集群搭建-yellowcong
- ActiveMQ之集群(主从)搭建-yellowcong
- hadoop之zookeeper集群搭建
- ZooKeeper之搭建集群模式。
- Redis之集群redis-trib.rb环境的搭建-yellowcong
- Redis之Codis集群的搭建与使用-yellowcong
- Zookeeper之Watcher事件-yellowcong
- Redis之集群安装-yellowcong
- Redis之集群删除-yellowcong
- Solr之集群安装-yellowcong
- centos zookeeper 实战之集群搭建
- Zookeeper学习之集群环境搭建
- ZooKeeper之搭建伪集群模式。
- Zookeeper 介绍 Zookeeper 搭建 Zookeeper 集群搭建
- zookeeper(3) zookeeper集群搭建
- Zookeeper之Eclipse插件安装-yellowcong
- Zookeeper之Curator框架简单使用-yellowcong
- Zookeeper框架Curator之事件监听-yellowcong
- Glide框架
- Noip 2016 换教室
- centos 卸载python和yum之后的解决办法
- ABP官方文档(二十五)【数据传输对象验证】
- JSTL标签与EL表达式xaing
- Zookeeper之集群搭建-yellowcong
- Lucene 代码详解
- 完全理解 Python 迭代对象、迭代器、生成器
- 微信开发必备外网映射工具----Ngroke
- 【Caffe特征图可视化】【权重图weight】【特征图feat】
- 你不知道的CSS3选择器--精辟用法
- Android Chronometer类
- 4.3(4)
- jqgrid ajax加载