Zookeeper学习笔记2
环境搭建
JDK(>1.6)安装
略
Zookeeper安装
1、下载
http://mirror.bit.edu.cn/apache/zookeeper/stable/zookeeper-3.4.10.tar.gz
2、解压
tar -zxvf zookeeper-3.4.10.tar.gz
3、在zookeeper-xx/conf文件夹下面创建配置文件,可直接复制zoo_sample.cfg
cp zoo_sample.cfg zoo.cfg
看看内容:
# 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
运行
单机环境
1、配置文件默认zoo.cfg
2、启动服务
3、启动客户端
集群环境
搭建集群只需要修改配置文件,添加一个myid的文件
1、zoo.cfg
# 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.2.192:2888:3888
server.2=192.168.2.200:2888:3888
server.3=192.168.2.233:2888:3888
server.server_id=server_ip:port_1:port_2
server_id:服务器编号1~255
server_ip:服务器ip
port_1:flower和leader同步数据的端口
port_2:flower进行leader选举的端口
2、在192.168.2.192机器上添加/tmp/zookeeper/myid
内容为1,
同理,其他机器的zoo.cfg一样,添加对应的myid文件
3、在其中任意台机器中运行
./bin/zkServer.sh status
你将会看到是leader还是flower
JMX enabled by default
Using config: /opt/Java/zookeeper-3.3.6/bin/../conf/zoo.cfg
Mode: leader
如果提示未运行,请查看zookeeper.out找到原因
4、在任一台机器创建节点,其他机器将同步数据
Zookeeper学习笔记2的更多相关文章
- ZooKeeper 学习笔记
ZooKeeper学习笔记 1. zookeeper基本概念 zookeeper是一个分布式的,开放源码的分布式应用程序协调服务,是hadoop和Habase的重要组件,是为分布式应用提供一致性服 ...
- ZooKeeper学习笔记(二)——内部原理
zookeeper学习笔记(二)--内部原理 1. zookeeper的节点的类型 总的来说可以分为持久型和短暂型,主要区别如下: 持久:客户端与服务器端断开连接的以后,创建的节点不会被删除: 持久化 ...
- ZooKeeper学习笔记(一)——概述
zookeeper学习笔记(一)--概述 1. 概述 Zookeeper是一个开源的分布式的,为分布式应用提供协调服务的Apache项目.zookeeper从设计模式的角度来理解:是一个基于观察者设计 ...
- Zookeeper学习笔记(中)
Zookeeper学习笔记(中) Zookeeper的基本原理和基本实现 深入了解ZK的基本原理 ZK的一致性: ZAB 协议: Zookeeper 原子消息广播协议 ZK通过选举保证 leader ...
- Zookeeper学习笔记(上)
Zookeeper学习笔记 本篇主要是一些基本的介绍和API的使用介绍, 有些只是记录了知识点,而没有完全在笔记中详细解释, 需要自行查找资料补充相关概念 主要参考了课程中的内容: Zookeeper ...
- ZooKeeper学习笔记一:集群搭建
作者:Grey 原文地址:ZooKeeper学习笔记一:集群搭建 说明 单机版的zk安装和运行参考:https://zookeeper.apache.org/doc/r3.6.3/zookeeperS ...
- ZooKeeper学习笔记三:使用ZooKeeper实现一个简单的配置中心
作者:Grey 原文地址:ZooKeeper学习笔记三:使用ZooKeeper实现一个简单的配置中心 前置知识 完成ZooKeeper集群搭建以及熟悉ZooKeeperAPI基本使用 需求 很多程序往 ...
- ZooKeeper学习笔记二:API基本使用
Grey ZooKeeper学习笔记二:API基本使用 准备工作 搭建一个zk集群,参考ZooKeeper学习笔记一:集群搭建. 确保项目可以访问集群的每个节点 新建一个基于jdk1.8的maven项 ...
- ZooKeeper学习笔记四:使用ZooKeeper实现一个简单的分布式锁
作者:Grey 原文地址: ZooKeeper学习笔记四:使用ZooKeeper实现一个简单的分布式锁 前置知识 完成ZooKeeper集群搭建以及熟悉ZooKeeperAPI基本使用 需求 当多个进 ...
- Zookeeper学习笔记(下)
这是ZK学习笔记的下篇, 主要希望可以分享一些 ZK 的应用以及其应用原理 我本人的学习告一段落, 不过还遗留了一些ZK相关的任务开发和性能测试的任务, 留待以后完成之后再通过其他文章来进行分享了 Z ...
随机推荐
- opencv: 线性拟合
opencv提供了fitline函数用于直线拟合,原型为: C++: void fitLine(InputArray points, OutputArray line, int distType, d ...
- java io系列26之 RandomAccessFile
本文主要介绍 RandomAccessFile. 转载请注明出处:http://www.cnblogs.com/skywang12345/p/io_26.html 更多内容请参考:java io系列0 ...
- JDBC-DBCP
依赖 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns=" ...
- System.Web.Optimization 合并压缩技术的使用
捆绑和压缩原理是:将多个css文件动态合并和压缩为一个css文件.多个js文件动态合并和压缩为一个js文件,如此达到减少浏览器对服务器资源文件的请求数量.缩小资源文件的尺寸来提高页面反应速度的目的.A ...
- 在CentOS7上安装Zabbix3.0
#!/bin/bash # # .配置无人值守的安装,定义安装过程中需要用到的一些信息 # mysql_root_pw=root_pw mysql_zabbix_pw=zabbix_pw DBPass ...
- 细说shiro之二:组件架构
官网:https://shiro.apache.org/ Shiro主要组件包括:Subject,SecurityManager,Authenticator,Authorizer,SessionMan ...
- docker 系列 - 容器数据持久化和数据共享
docker 主要有两种数据存储形式, 一种是storage driver(也叫做 Graph driver), 另一种是 volume driver. stroage driver主要是存储那些无状 ...
- ImageView获取宽高
在Android里放置一个ImageView im1,宽和高都是200.以下代码都是直接在OnCreate里使用. 1.在Android OnCreate里如果直接使用iv.GetWidth()返回值 ...
- Uncaught TypeError: $(…).orgcharts is not a function
调整js顺序没有解决,最后增加NoConflict解决,注意红色部分 function initorgcharts() { var $jq = jQuery.noConflict(true); org ...
- setDefaultKeyMode设置Activity的五种按键模式
setDefaultKeyMode (int mode) 用来设置一个Activity的默认的按键模式, mode一共有五种 DEFAULT_KEYS_DISABLE DEFAULT_KEYS_DIA ...