8.3.ZooKeeper集群安装配置
1.Zookeeper的搭建方式
Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式。
单机模式:Zookeeper只运行在一台服务器上,适合测试环境;
伪集群模式:就是在一台物理机上运行多个Zookeeper 实例;
集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个“集合体”(ensemble)
Zookeeper通过复制来实现高可用性,只要集合体中半数以上的机器处于可用状态,它就能够保证服务继续(zookeeper集群机制
)
Zookeeper集群机制:半数机制:集群中半数以上机器存活,集群可用
2.ZooKeeper服务器集群搭建
Zookeeper 集群搭建指的是 ZooKeeper 分布式模式安装。通常由 2n+1台 servers 组成。这是因为为了保证 Leader 选举(基于 Paxos 算法
的实现)能过得到多数的支持,所以 ZooKeeper 集群的数量一般为奇数。
Zookeeper 运行需要 java 环境,所以需要提前安装 jdk。对于安装leader+follower 模式的集群,大致过程如下:
卸载系统自带的OpenJDK:查看(rpm -qa|grep java) 卸载(rpm -e --nodeps xxxxxxxxx),然后安装sun公司的 JDK,然后修改环境变量/etc/profile,
并source /etc/profile加载配置文件
搭建要求:
(1) zk服务器集群规模不小于3个节点
(2) 要求各服务器之间系统时间要保持一致:date -s命令
(3) 关闭防火墙:service iptables stop
1.解压缩zookeeper到指定目录: tar -zxvf zookeeper-3.4.5.tar.gz -C /usr/local/src
2.重命名:解压后将文件夹,重命名为zookeeper: mv zookeeper-3.4.5 zookeeper
3.修改环境变量:vi /etc/profile
export ZOOKEEPER_HOME=/usr/local/src/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
4.重新编译文件:source /etc/profile
5.修改配置文件:将 /usr/local/src/zookeeper/conf/目录下的zoo_sample.cfg,重命名为zoo.cfg:mv zoo_sample.cfg zoo.cfg
6.在/usr/local/zk/conf目录下,修改文件 vi zoo.cfg,创建data、log目录,并添加如下内容
# 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=/usr/local/src/zookeeper/data #文件存放目录,默认设置/tmp/zookeeper临时存放目录,每次重启后会丢失,在这我们自己设一个目录,/usr/local/src/zookeeper/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
添加内容:
dataDir=/usr/local/src/zookeeper/data #zookeeper数据存放目录
dataLogDir=/usr/local/src/zookeeper/log
server.1=shizhan2:2888:3888 (主机名, 心跳端口、选举端口) 201
server.2=shizhan3:2888:3888 205
server.3=shizhan5:2888:3888 207
7.在data目录下创建myid:创建文件myid:touch myid,存放服务器ID
8.将集群下发到其他机器上:基于 SSH 协议在网络之间进行安全传输的命令
scp -r /usr/local/src/zookeeper root@192.168.232.205:/usr/local/src/ ---(shizhan3:) scp -r /usr/local/src/zookeeper root@192.168.232.201:/usr/local/src/ --- (shizhan2)
9.修改myid:和server服务器ID保持一致
到shizhan2上:修改myid为:1
到shizhan3上:修改myid为:2
到shizhan5上:修改myid为:3
10.启动每台机器:zkServer.sh start
11.查看集群状态,主从信息:zkServer.sh status
Zookeeper集群的角色:Leader 和 follower
8.3.ZooKeeper集群安装配置的更多相关文章
- 原创:centos7.1下 ZooKeeper 集群安装配置+Python实战范例
centos7.1下 ZooKeeper 集群安装配置+Python实战范例 下载:http://apache.fayea.com/zookeeper/zookeeper-3.4.9/zookeepe ...
- hbase和ZooKeeper集群安装配置
一:ZooKeeper集群安装配置 1:解压zookeeper-3.3.2.tar.gz并重命名为zookeeper. 2:进入~/zookeeper/conf目录: 拷贝zoo_sample.cfg ...
- Zookeeper 集群安装配置,超详细,速度收藏!
今天,栈长分享下 Zookeeper 的集群安装及配置. 下载 下载地址:http://zookeeper.apache.org/ 下载过程就不说了,我们下载了最新的zookeeper-3.4.11. ...
- Zookeeper 集群安装配置
今天,栈长分享下 Zookeeper 的集群安装及配置. 下载 下载地址:http://zookeeper.apache.org/ 下载过程就不说了,我们下载了最新的zookeeper-3.4.11. ...
- zookeeper集群安装配置
http://www.firefoxbug.net/?p=2565
- hbase单机环境的搭建和完全分布式Hbase集群安装配置
HBase 是一个开源的非关系(NoSQL)的可伸缩性分布式数据库.它是面向列的,并适合于存储超大型松散数据.HBase适合于实时,随机对Big数据进行读写操作的业务环境. @hbase单机环境的搭建 ...
- 1、zookeeper集群安装
前提准备3台centos7.0虚拟机 c7003:192.168.70.103 c7004:192.168.70.104 c7005:192.168.70.105 并在三台虚拟机上配置hosts为 1 ...
- (Linux环境Kafka集群安装配置及常用命令
Linux环境Kafka集群安装配置及常用命令 Kafka 消息队列内部实现原理 Kafka架构 一.下载Kafka安装包 二.Kafka安装包的解压 三.设置环境变量 四.配置kafka文件 4.1 ...
- Zookeeper集群安装Version3.5.1
Zookeeper集群安装,基于版本3.5.1, 使用zookeeper-3.5.1-alpha.tar.gz安装包. 1.安装规划 zookeeper集群模式,安装到如下三台机器 10.43.159 ...
随机推荐
- SpringBoot: 1.创建第一个SpringBoot项目(转)
一.新建项目 二.打开项目的pom文件,在里面添加maven依赖 1 <!--springboot项目依赖的父项目--> 2 <parent> 3 <groupId& ...
- kubeadm安装集群系列-3.添加工作节点
添加工作节点 worker通过kubeadm join加入集群,加入所需的集群的token默认24小时过期 查看Token kubeadm token list # 如果失效创建一个新的 kubead ...
- 小林的VB6動態壁紙模擬程序
本項目參考了以下資料[這可能對你理解程序運行有幫助]: https://github.com/Yinmany/WinWallpaper https://blog.csdn.net/breaksoftw ...
- SQL2000中文版打不上SP4提示用户验证没有通过
https://jingyan.baidu.com/article/7f41ececf24841593d095cd8.html 解决方法: 在安装SQL Server SP4,有时候会出现:无论用wi ...
- PAT A1016 Phone Bills (25)
题目描述 A long-distance telephone company charges its customers by the following rules: Making a long-d ...
- F. 汤圆防漏理论
ghc很喜欢吃汤圆,但是汤圆很容易被粘(zhān)漏. 根据多年吃汤圆经验,ghc总结出了一套汤圆防漏理论: 互相接触的汤圆容易粘(zhān)在一起,并且接触面积不同,粘(zhān)在一起的粘(niá ...
- UAV图像拼接软件编译环境配置
1,需要下载的软件: 依次安装qt-opensource.addin qt安装目录为C:\Qt\4.8.6 2,vs2010配置 *配置UAVBeta工程的属性,下图黑色字体部分与qt相关,取决于你的 ...
- mac手册汉化 2019
1.安装依赖 brew install automake brew install opencc 2.编译 wget https://github.com/man-pages-zh/manpages- ...
- Fix Scheduled Task Won’t Run for .BAT File
Step 1: Check File/Folder Permissions The first step to fixing this issue is ensuring that the accou ...
- C#文本_文件夹操作
1我们常用的File类 可以用来对文件的一些操作 下面看代码. using System;using System.Collections.Generic;using System.IO;using ...