Linux下搭建Zookeeper环境
Zookeeper 是 Google 的 Chubby一个开源的实现,是 Hadoop 的分布式协调服务,它包含一个简单的原语集,分布式应用程序可以基于它实现同步服务,配置维护和命名服务等。
其工作原理示意图如下:
1.为什么使用Zookeeper
» 大部分分布式应用需要一个主控、协调器或控制器来管理物理分布的子进程(如资源、任务分配等)
» 目前,大部分应用需要开发私有的协调程序,缺乏一个通用的机制
» 协调程序的反复编写浪费,且难以形成通用、伸缩性好的协调器
» ZooKeeper:提供通用的分布式锁服务,用以协调分布式应用
2.Zookeeper能做什么
» Hadoop2.0,使用Zookeeper的事件处理确保整个集群只有一个活跃的NameNode,存储配置信息等
» HBase,使用Zookeeper的事件处理确保整个集群只有一个HMaster,察觉HRegionServer联机和宕机,存储访问控制列表等
3.Zookeeper的特性
» Zookeeper是简单的
» Zookeeper是富有表现力的
» Zookeeper具有高可用性
» Zookeeper采用松耦合交互方式
» Zookeeper是一个资源库
4.在Linux下的配置
我们启动三个主机,每个执行相同的操作。
首先下载压缩包
http://labs.renren.com/apache-mirror/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz
进行解压tar -zxvf zookeeper-3.4.5.tar.gz -C /home/hadoop/app
在zookeeper/conf/zoo.cfg中进行如下配置:(刚开始是zoo_sample.cfg,重命名一下,最下面三个是三台主机的IP)
# 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.
dataDir=/home/hadoop/app/zookeeper-3.4.5/data
# 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=1
server.1=192.168.230.135:2888:3888
server.2=192.168.230.136:2888:3888
server.3=192.168.230.137:2888:3888
回到data目录下(data目录是自己建的zookeeper/data),分别在不同主机下执行echo 1 > myid,echo 2 > myid,echo 3 > myid
在zookeeper/bin目录下,进行启动:./zkServer.sh start(关闭是 ./zkServer.sh stop)
进行监控:./zkServer.sh status
可以看到一台主节点,两台从节点。
批量启动zookeeper服务器脚本(可以自己修改):
#!/bin/sh echo 'start zkServer...' for i in 1 2 3 do ssh weekend0$i 'source /etc/profile;/home/hadoop/app/zookeeper-3.4.5/bin/zkServer.sh start' done
相关文章
- 国密SM3算法在linux和windows平台结果不一致问题
- 用linux mail命令发送邮件[Linux]
- Linux之绝对路径和相对路径
- Linux Command dpkg 软件管理
- Linux&Tina&Melis内存布局分析以及linux reserved memory机制
- linux workqueue实现原理
- 《Apache Zookeeper 官方文档》ZooKeeper可插入式身份认证
- 用 screenfetch 和 linux_logo 显示带有酷炫 Linux 标志的基本硬件信息
- Linux Deploy在安卓手机安装LINUX系统
- Linux 文件系统之入门必看!
- 【Linux】手把手教你如何搭建linux环境---云服务器
- 第10章 统计和查看Linux的系统状态
- 转 windows下安装pycharm并连接Linux的python环境 以及 windows 下notepad ++编辑 linux 的文件
- Apache Curator与Zookeeper版本兼容性异常:org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode =Unimplemented
- VMware创建Linux虚拟机之(四)ZooKeeper&HBase完全分布式安装
- Linux_查看linux并发连接数
- 大数据框架命令集合(Linux、Shell、Hadoop、Zookeeper、Kafka、Hive、Redis、Flink)
- Linux学习---linux下的彩蛋和各种有趣的命令
- 【转】Zookeeper学习---zookeeper 选举机制介绍
- linux关于防火墙的一些知识
- 【嵌入式Linux学习】11、Samba服务安装与配置
- 【正点原子MP157连载】 第十五章 IP核之FIFO实验-摘自【正点原子】STM32MP1嵌入式Linux驱动开发指南V1.7
- 【正点原子Linux连载】第三十七章 Linux内核移植 -摘自【正点原子】I.MX6U嵌入式Linux驱动开发指南V1.0
- [加入用户]解决useradd 用户后没有加入用户Home文件夹的情况,Linux改变文件或文件夹的訪问权限命令,linux改动用户password,usermod的ysuum安装包。飞
- 【Linux】linux经常使用基本命令
- Linux学习笔记(21)linux查看系统状态
- Linux学习笔记(7)CRT实现windows与linux的文件上传下载
- 【Linux】linux中删除指定日期之前的文件
- ZooKeeper系列之二:Zookeeper常用命令