zookeeper 安装 配置集群
https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/
[root@znode01 src]# tar -xzvf zookeeper-3.5.-alpha.tar.gz
[root@znode01 src]# ls
zookeeper-3.5.-alpha zookeeper-3.5.-alpha.tar.gz
[root@znode01 zookeeper-3.5.-alpha]# ls
bin ivysettings.xml recipes
build.xml ivy.xml src
CHANGES.txt lib zookeeper-3.5.-alpha.jar
conf LICENSE.txt zookeeper-3.5.-alpha.jar.asc
contrib NOTICE.txt zookeeper-3.5.-alpha.jar.md5
dist-maven README_packaging.txt zookeeper-3.5.-alpha.jar.sha1
docs README.txt
[root@znode01 zookeeper-3.5.-alpha]# cd conf/
[root@znode01 conf]# ls
configuration.xsl log4j.properties zoo_sample.cfg
[root@znode01 conf]# mv zoo_sample.cfg zoo.cfg
[root@znode01 conf]# ls
configuration.xsl log4j.properties zoo.cfg
修改配置文件:
[root@znode01 conf]# cat zoo.cfg
# The number of milliseconds of each tick
tickTime= #Zookeeper服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个tickTime时间就会发送一个心跳。tickTime以毫秒为单位。
# The number of ticks that the initial
# synchronization phase can take
initLimit= #集群中的follower服务器与leader之间初始连接时能容忍的最多心跳数(ticTime的数量)
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit= #集群中的follower服务器与leader服务器之间请求和应答之间能容忍的最多必跳数(tickTime的数量)
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/tmp/zookeeper #Zookeeper保存数据的目录,默认情况下,Zookeeper将写数据的日志文件也何存在这个目录里。
# the port at which the clients will connect
clientPort= #客户端连接Zookeeper服务器的端口,Zookeeper会监听这个端口,接受客户端的访问请求。
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=
#
# 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=
# Purge task interval in hours
# Set to "" to disable auto purge feature
#autopurge.purgeInterval=
#服务器名称与地址:集群信息(服务器编号,服务器地址,LF通信端口,选举端口)
#server.N=YYY:A:B
server.=192.168.1.104::
server.=192.168.1.103::
server.=192.168.1.108::
zk设置为奇数:
zookeeper有这样一个特性:集群中只要有过半的机器是正常工作的,那么整个集群对外就是可用的。也就是说如果有2个zookeeper,那么只要有1个死了zookeeper就不能用了,因为1没有过半,所以2个zookeeper的死亡容忍度为0;同理,要是有3个zookeeper,一个死了,还剩下2个正常的,过半了,所以3个zookeeper的容忍度为1;同理你多列举几个:2-->0;3-->1;4-->1;5-->2;6-->2会发现一个规律,2n和2n-1的容忍度是一样的,都是n-1,所以为了更加高效,何必增加那个不必要的zookeeper!!!!!
[root@znode01 conf]# mkdir /tmp/zookeeper
[root@znode01 conf]# touch /tmp/zookeeper/myid;echo > /tmp/zookeeper/myid
#创建一个myid文件,里面的内容是server.N中的N(server.2里面的内容为2)
将配好的zookeeper发到别外的两个节点上:
[root@znode01 local]# scp -r -P22022 zookeeper-3.5.-alpha 192.168.1.108:/usr/local/
[root@znode01 local]# scp -r -P22022 zookeeper-3.5.-alpha 192.168.1.103:/usr/local/
注意其它的节点的myid内容分别人2,3。查看个个结点的myid
[root@znode01 zookeeper-3.5.-alpha]# cat /tmp/zookeeper/myid [root@znode02 zookeeper-3.5.-alpha]# cat /tmp/zookeeper/myid [root@znode03 zookeeper-3.5.-alpha]# cat /tmp/zookeeper/myid
启动zookeeper:
[root@znode01 bin]# ./zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.-alpha/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@znode02 zookeeper-3.5.-alpha]# ./bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.-alpha/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@znode03 zookeeper-3.5.-alpha]# ./bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.-alpha/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
之前的zoo.cnf做一下小的修改如下:
[root@znode01 zookeeper-3.5.-alpha]# cat conf/zoo.cfg
# The number of milliseconds of each tick
#Zookeeper服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个tickTime时间就会发送一个心跳。tickTime以毫秒为单位。
tickTime=
# The number of ticks that the initial
# synchronization phase can take
#集群中的follower服务器与leader之间初始连接时能容忍的最多心跳数(ticTime的数量)
initLimit=
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
#集群中的follower服务器与leader服务器之间请求和应答之间能容忍的最多必跳数(tickTime的数量)
syncLimit=
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
#Zookeeper保存数据的目录,默认情况下,Zookeeper将写数据的日志文件也何存在这个目录里。
dataDir=/tmp/zookeeper
# the port at which the clients will connect
#客户端连接Zookeeper服务器的端口,Zookeeper会监听这个端口,接受客户端的访问请求。
clientPort=
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=
#
# 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=
# Purge task interval in hours
# Set to "" to disable auto purge feature
#autopurge.purgeInterval=
#服务器名称与地址:集群信息(服务器编号,服务器地址,LF通信端口,选举端口)
#server.N=YYY:A:B
server.=192.168.1.104::
server.=192.168.1.103::
server.=192.168.1.108::
下面看一下三个结点的过行情况:
[root@znode01 zookeeper-3.5.-alpha]# ./bin/zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.-alpha/bin/../conf/zoo.cfg
Client port found: . Client address: localhost.
Mode: follower
[root@znode02 zookeeper-3.5.-alpha]# ./bin/zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.-alpha/bin/../conf/zoo.cfg
Client port found: . Client address: localhost.
Mode: leader
[root@znode03 zookeeper-3.5.-alpha]# ./bin/zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.-alpha/bin/../conf/zoo.cfg
Client port found: . Client address: localhost.
Mode: follower
这里要注意防火墙是不是把相应的端口打开!!!!
zookeeper 安装 配置集群的更多相关文章
- zookeeper安装 配置集群
zookeeper下载 http://zookeeper.apache.org/releases.html. 解压 重命名 新建data log两个文件夹配置单个启动 tar -xvf zookeep ...
- zookeeper 安装及集群
一.zookeeper介绍 zookeeper是一个中间件,为分布式系统提供协调服务,可以为大数据服务,也可以为java服务. 分布式系统,很多计算机组成一个整体,作为一个整体一致对外并处理同一请求, ...
- Zookeeper 安装及集群配置注意点
Zookeeper在ubuntu下安装及集群搭建,关于集群搭建,网上很多文章 可以参考:https://www.ibm.com/developerworks/cn/opensource/os-cn-z ...
- 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安装与集群搭建
此处以centos系统下zookeeper安装为例,详细步骤可参考官网文档:zookeeper教程 一.单节点部署 1.下载zookeeper wget http://mirrors.hust.edu ...
- nginx安装配置+集群tomcat:Centos和windows环境
版本:nginx-1.8.0.tar.gz 官网:http://nginx.org/en/download.html 版本:apache-tomcat-6.0.44.tar.gz 官 ...
- zookeeper安装(集群)
Dubbo 建议使用Zookeeper 作为服务的注册中心.Zookeeper 集群中只要有过半的节点是正常的情况下,那么整个集群对外就是可用的.正是基于这个特性,要将ZK 集群的节点数量要为奇数(2 ...
- ZooKeeper伪分布集群安装及使用 RMI+ZooKeeper实现远程调用框架
使用 RMI + ZooKeeper 实现远程调用框架,包括ZooKeeper伪集群安装和代码实现两部分. 一.ZooKeeper伪集群安装: 1>获取ZooKeeper安装包 下载地址:ht ...
- (转)ZooKeeper伪分布式集群安装及使用
转自:http://blog.fens.me/hadoop-zookeeper-intro/ 前言 ZooKeeper是Hadoop家族的一款高性能的分布式协作的产品.在单机中,系统协作大都是进程级的 ...
随机推荐
- Mahout0.6-VectorDumper bug修复
VectorDumper类的功能是从SequenceFile中按照键值对的方式读取信息并将其转化为文本形式,具体使用见第五部分1.1.2节第3)条.如果不对源码进行修改使用时存在两个bug,现在只对b ...
- 移动端兼容 - faskclick.js
fasckclick为解决移动端300ms延迟而生 github地址为:https://github.com/ftlabs/fastclick 使用方法: 1. 原生使用(window.onload或 ...
- Hibernate框架简介(二)基本使用增、删、改、查
一.Hibernate框架简介 Hibernate是一个优秀的Java持久化层解决方案,是当今主流的对象-关系映射(ORM,ObjectRelationalMapping)工具 1.1.理解持久化 瞬 ...
- VB 中定义FileSystemObject对象,要先添加对象
存取文件的方法有很多种,可以使用上述VB提供的函数,使用Windows API函数等等,但是最简单的方法是使用FileSystemObject对象. 1.使用FileSystemObject对象 F ...
- jquery 清除style样式
$("#show").removeAttr("style"); //ie,ff均支持 $("#show").attr("style ...
- maven 将jar包添加到本地仓库
maven 如何将jar包添加到本地仓库 CreateTime--2018年4月19日12:50:50 Author:Marydon 情景描述:当项目所需的jar包,maven中央仓库中没有该j ...
- 【Oracle】事务处理
名词解释 DML:Data Manipulation Language (数据库操纵语言) 例如:DELETE.INSERT.UPDATE.SELECT DDL:Data Definition Lan ...
- Python之对象的属性
# -*- coding: utf-8 -*- #python 27 #xiaodeng #Python之对象的属性 #http://python.jobbole.com/82622/ #对象的属性 ...
- 判断是否为SIM卡联系人
判断是否为SIM卡联系人 在AsyncQueryContacts类中. private List<TxrjAccount> accounts = new ArrayList<Txrj ...
- ACM遇到的问题与解决方案
C++防止栈溢出措施: 只要在你的代码里加上下面这句话, OK,栈溢出直接搞定!!! #pragma comment(linker, "/STACK:102400000,102400000& ...