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 安装 配置集群的更多相关文章

  1. zookeeper安装 配置集群

    zookeeper下载 http://zookeeper.apache.org/releases.html. 解压 重命名 新建data log两个文件夹配置单个启动 tar -xvf zookeep ...

  2. zookeeper 安装及集群

    一.zookeeper介绍 zookeeper是一个中间件,为分布式系统提供协调服务,可以为大数据服务,也可以为java服务. 分布式系统,很多计算机组成一个整体,作为一个整体一致对外并处理同一请求, ...

  3. Zookeeper 安装及集群配置注意点

    Zookeeper在ubuntu下安装及集群搭建,关于集群搭建,网上很多文章 可以参考:https://www.ibm.com/developerworks/cn/opensource/os-cn-z ...

  4. 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 ...

  5. zookeeper安装与集群搭建

    此处以centos系统下zookeeper安装为例,详细步骤可参考官网文档:zookeeper教程 一.单节点部署 1.下载zookeeper wget http://mirrors.hust.edu ...

  6. nginx安装配置+集群tomcat:Centos和windows环境

    版本:nginx-1.8.0.tar.gz 官网:http://nginx.org/en/download.html         版本:apache-tomcat-6.0.44.tar.gz  官 ...

  7. zookeeper安装(集群)

    Dubbo 建议使用Zookeeper 作为服务的注册中心.Zookeeper 集群中只要有过半的节点是正常的情况下,那么整个集群对外就是可用的.正是基于这个特性,要将ZK 集群的节点数量要为奇数(2 ...

  8. ZooKeeper伪分布集群安装及使用 RMI+ZooKeeper实现远程调用框架

    使用 RMI + ZooKeeper 实现远程调用框架,包括ZooKeeper伪集群安装和代码实现两部分.  一.ZooKeeper伪集群安装: 1>获取ZooKeeper安装包 下载地址:ht ...

  9. (转)ZooKeeper伪分布式集群安装及使用

    转自:http://blog.fens.me/hadoop-zookeeper-intro/ 前言 ZooKeeper是Hadoop家族的一款高性能的分布式协作的产品.在单机中,系统协作大都是进程级的 ...

随机推荐

  1. git 使用流程(使用代码库github)

    一:先在github 上注册账号,并创建一个项目: 二:mac 命令行-进入自己的工作空间 1:建立库     git init 2:初始化配置 git config --global user.na ...

  2. 寻找[nginx] 由Lua 粘合的Nginx生态环境-- agentzh

    来自:linuxtone org     Chnangelog:         120312 fixed as s/hhttp/http/g ,thanx muxueqz         12030 ...

  3. 导出CCS3.3数据及使用matlab处理的方法

    CCS3.3是一款DSP的集成开发环境(IDE).在做DSP开发时,为验证算法.经常须要使用matlab进行算法验证,验证算法就须要数据.因此,一种交互的方法是: 使用DSP开发板连接CCS 用CCS ...

  4. Android API之android.provider.ContactsContract.RawContacts

    android.provider.ContactsContract.RawContacts Constants for the raw contacts table, which contains o ...

  5. php开发中sql语句拼接示例(插入、查询、更新)

    1.插入语句 $sql="insert into Ad(AdClassID,AdType,AdTit,AdFileName,AdUrl,AShow,Addtime) values('&quo ...

  6. 深入PHP内核之参数

    1.看一下一个扩展中的简单代码 ZEND_BEGIN_ARG_INFO(params_add_arginfo, 0) ZEND_ARG_INFO(0, a) ZEND_ARG_INFO(0, b) Z ...

  7. HDUOJ-----2838Cow Sorting(组合树状数组)

    Cow Sorting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  8. Android学习系列(6)--App模块化及工程扩展

    这篇文章是Android开发人员的必备知识,是我特别为大家整理和总结的,不求完美,但是有用. 1.需求    无论是在.net还是java平台,合理的分层架构是最普遍的模块化思路之一.    dll, ...

  9. ADF_ADF基本概要(汇总)

    20150601 Created By BaoXinjian

  10. android 布局权重问题(最近布局经常坑爹)

    android 布局 权重 With layout_weight you can specify a size ratio between multiple views. E.g. you have ...