zookeeper安装与集群搭建
此处以centos系统下zookeeper安装为例,详细步骤可参考官网文档:zookeeper教程
一、单节点部署
1、下载zookeeper
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
2、解压下载下来的压缩文件
tar -zxvf zookeeper-3.4..tar.gz
3、进入解压缩文件夹的conf目录,新建zoo.cfg配置文件(zookeeper启动时默认加载conf目录下的zoo.cfg文件)
cd zookeeper-3.4.
cd conf/
touch zoo.cfg
vi zoo.cfg
该目录下有一个样例配置文件,可供参考:zoo_sample.cfg
4、修改配置文件(默认监听服务器上所有网卡收到的请求):
vi zoo.cfg
修改完成后,配置文件内容如下:
tickTime=
dataDir=/opt/zookeeper-3.4./data
clientPort=
官网介绍如下:
This file can be called anything, but for the sake of this discussion call it conf/zoo.cfg. Change the value of dataDir to specify an existing (empty to start with) directory. Here are the meanings for each of the fields:
tickTime
the basic time unit in milliseconds used by ZooKeeper. It is used to do heartbeats and the minimum session timeout will be twice the tickTime.
dataDir
the location to store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database.
clientPort
the port to listen for client connections
5、创建配置文件中提到的datadir目录:
mkdir -p /opt/zookeeper-3.4./data
6、启动zookeeper,安装目录bin目录下执行如下指令:
./zkServer.sh start
其他相关命令:
关闭:./zkServer.sh stop
重启: ./zkServer.sh restart
查看状态: ./zkServer.sh status
到此zookeeper安装完成
二、集群搭建
此处主要介绍在同一机器上搭建一伪集群,生成环境建议多机进行集群部署
1、将zk安装文件夹复制成三份
cp -dr zookeeper-3.4. zookeeper-3.4.10_1
cp -dr zookeeper-3.4. zookeeper-3.4.10_2
2、修改各集群节点配置文件
vi zookeeper-3.4./conf/zoo.cfg
vi zookeeper-3.4.10_1/conf/zoo.cfg
vi zookeeper-3.4.10_2/conf/zoo.cfg
修改后给配置文件分别为:
zookeeper-3.4.10/conf/zoo.cfg
tickTime=
dataDir=/opt/zookeeper-3.4./data
clientPort=
initLimit=
syncLimit=
server.=127.0.0.1::
server.=127.0.0.1::
server.=127.0.0.1::
zookeeper-3.4.10_1/conf/zoo.cfg
tickTime=
dataDir=/opt/zookeeper-3.4.10_1/data
clientPort=
initLimit=
syncLimit=
server.=127.0.0.1::
server.=127.0.0.1::
server.=127.0.0.1::
zookeeper-3.4.10_2/conf/zoo.cfg
tickTime=
dataDir=/opt/zookeeper-3.4.10_2/data
clientPort=
initLimit=
syncLimit=
server.=127.0.0.1::
server.=127.0.0.1::
server.=127.0.0.1::
server后面的端口,前者用于zk间节点通信,后者用于leader选举
附上一段官网原文:
tickTime=
dataDir=/var/lib/zookeeper
clientPort=
initLimit=
syncLimit=
server.=zoo1::
server.=zoo2::
server.=zoo3:: The new entry, initLimit is timeouts ZooKeeper uses to limit the length of time the ZooKeeper servers in quorum have to connect to a leader. The entry syncLimit limits how far out of date a server can be from a leader. With both of these timeouts, you specify the unit of time using tickTime. In this example, the timeout for initLimit is 5 ticks at 2000 milleseconds a tick, or 10 seconds. The entries of the form server.X list the servers that make up the ZooKeeper service. When the server starts up, it knows which server it is by looking for the file myid in the data directory. That file has the contains the server number, in ASCII. Finally, note the two port numbers after each server name: "" and "". Peers use the former port to connect to other peers. Such a connection is necessary so that peers can communicate, for example, to agree upon the order of updates. More specifically, a ZooKeeper server uses this port to connect followers to the leader. When a new leader arises, a follower opens a TCP connection to the leader using this port. Because the default leader election also uses TCP, we currently require another port for leader election. This is the second port in the server entry.
3、为每个节点分别新建myid文件,文件内容对应上述配置文件中server的编号
echo "" > zookeeper-3.4./data/myid
echo "" > zookeeper-3.4.10_1/data/myid
echo "" > zookeeper-3.4.10_2/data/myid
4、启动zookeeper
zookeeper-3.4./bin/zkServer.sh start
zookeeper-3.4.10_1/bin/zkServer.sh start
zookeeper-3.4.10_2/bin/zkServer.sh start
5、查看集群状态

到此zk集群配置完成
zookeeper安装与集群搭建的更多相关文章
- zookeeper 安装以及集群搭建
安装环境: jdk1.7 zookeeper-3.4.10.tar.gz VM虚拟机redhat6.5-x64:192.168.1.200 192.168.1.201 192.168.1.202 ...
- zookeeper及kafka集群搭建
zookeeper及kafka集群搭建 1.有关zookeeper的介绍可参考:http://www.cnblogs.com/wuxl360/p/5817471.html 2.zookeeper安装 ...
- 【运维技术】Zookeeper单机以及集群搭建教程
Zookeeper单机以及集群搭建教程 单机搭建 单机安装以及启动 安装zookeeper的前提是必须有java环境 # 选择目录进行下载安装 cd /app # 下载zk,可以去官方网站下载,自己上 ...
- Zookeeper 安装及集群配置注意点
Zookeeper在ubuntu下安装及集群搭建,关于集群搭建,网上很多文章 可以参考:https://www.ibm.com/developerworks/cn/opensource/os-cn-z ...
- 基于zookeeper的Swarm集群搭建
简介 Swarm:docker原生的集群管理工具,将一组docker主机作为一个虚拟的docker主机来管理. 对客户端而言,Swarm集群就像是另一台普通的docker主机. Swarm集群中的每台 ...
- Zookeeper简介与集群搭建【转】
Zookeeper简介 Zookeeper是一个高效的分布式协调服务,可以提供配置信息管理.命名.分布式同步.集群管理.数据库切换等服务.它不适合用来存储大量信息,可以用来存储一些配置.发布与订阅等少 ...
- zookeeper 安装及集群
一.zookeeper介绍 zookeeper是一个中间件,为分布式系统提供协调服务,可以为大数据服务,也可以为java服务. 分布式系统,很多计算机组成一个整体,作为一个整体一致对外并处理同一请求, ...
- ActiveMQ此例简单介绍基于docker的activemq安装与集群搭建
ActiveMQ拓展连接 此例简单介绍基于Docker的activemq安装与集群搭建 一 :安装 1.获取activemq镜像 docker pull webcenter/activemq 2.启动 ...
- Redis单机安装以及集群搭建
今天主要来看一下Redis的安装以及集群搭建(我也是第一次搭建). 环境:CentOS 7.1,redis-5.0.7 一.单机安装 1.将Redis安装包放置服务器并解压 2.进入redis安装目录 ...
随机推荐
- 一条长为L的绳子,一面靠墙,另外三边组成矩形,问此矩形最大面积能是多少?
靠墙的两边设为x,墙的对边设为y,有2x+y=L; 则y=L-2x, 矩形面积函数为xy=x(L-2x)=-2x2+xL,即f(x)=-2x2+xL 这时就是求二次函数的极值问题了. 按二次函数y=a ...
- java线程总结(3/5)
一.线程同步和死锁问题 异步问题: package com.horizon.action; /** * 测试同步问题 * */ public class TestSync { public stati ...
- Office 如何下载网页的视频 JWPlayer的内嵌视频
右击页面空白处,查看页面源代码 在里面搜索mp4或者swf,video,一般网页中的视频都是这些格式,仔细找一定能找到对应的地址 然后复制到迅雷下载即可
- HTML5中标记与特殊属性
不允许写结束标记的元素有(只允许<元素/>): area.base.br.col.command.embed.hr.img.input. keygen.link.meta.param.so ...
- 11-hibernate,单表GRUD操作实例
1,save 2,update 3,delete 4,get/load(查询单个纪录) 实例代码: import java.io.File; import java.io.FileInputStrea ...
- iOS 移动端生成工具开发
代码地址如下:http://www.demodashi.com/demo/11284.html 一.准备工作 编译环境 xcode 用于生成冗余架构代码, 实现生成零耦合架构 二.程序实现 上个月的一 ...
- JavaScript正则表达式基础知识汇总
一.创建正则对象: 1.构造函数RegExp创建正则对象 var pattern = new RegExp('s$'); //pattern匹配以s结尾的字符串 2.使用正则直接量 var patte ...
- 在linux下运行jmeter
之前在用JMeter做性能测试时基本都用自己的笔记本电脑. 考虑到网络传输和占用系统资源情况时进行了以下分析: 1 在笔记本上,开始-cmd "ping 服务器",得到传输时间.在 ...
- C#反射取数组单个元素的类型
去bing上查了一下,果然有和我一样蛋疼的朋友,他们在论坛研究了半天,最后还是暴力解决: public Type GetArrayElementType(Type t) { string tName ...
- Atitit.分区对索引的影响 分区索引和全局索引 attilax总结
Atitit.分区对索引的影响 分区索引和全局索引 attilax总结 1. 分区的好处1 2. 分区键:2 3. 分区的建议:2 4. 分区索引和全局索引:2 5. 全局索引就是在全表上创建索引, ...