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. cd命令(转)

    原文地址:http://www.cnblogs.com/peida/archive/2012/10/24/2736501.html Linux cd 命令可以说是Linux中最基本的命令语句,其他的命 ...

  2. Java监控工具

     1. jmap 查看heapdump 2. jstack         查看javacore 3.jps        列出jvm进程 4.jstatd      启动jvm监控服务.它是一个基于 ...

  3. android 上线流程

    1.首先打开安卓市场官网,在右上角找到注册按钮,先注册成为开发者. 2.而后点击“开发者”进入“开发者中心”页面(也可从网页下方的“开发者入口”进入). 3.选择“发布软件”选项,依次上传创建的APP ...

  4. Ubuntu系统安装VMware Tools的简单方法

    不少网友反映在VMWare虚拟机下安装Ubuntu系统后无法安装VMware Tools,这里给出一个简单方法,只需要几步即可解决. 第一步:进入系统后,点击虚拟机上的安装vmware tools,回 ...

  5. workflow中的‘非典型’自动触发器trigger_model

    Openerp中workflow的设计机制 工作流程系统在OpenERP里是非常有用的机制,可以用于即时描述单据(模型)状态的演进过程.工作流实现了状态流转的可配置,通过迁移的 condition代替 ...

  6. 如何使用jmeter来实现更大批量的并发的解决方案

    近期在用JMeter进行负载测试的 时候,发现使用单台机器模拟测试超过比如500个进程的并发就有些力不从心或者说不能如实的反应实际情况,在执行的过程中,JMeter自身会自动关闭, 要解决这个问题,则 ...

  7. TransactionScope 的基本原理简介

    C# 的事务编程 1 Db事务 DbConnection 中创建基于当前连接的 DbTransaction 2  使用TransactionScope ,创建环境事务 一旦创建,在这个环境包含的DbC ...

  8. TaskController.java 20160712

    package main.java.com.zte.controller.system; import java.io.PrintWriter; import java.util.ArrayList; ...

  9. Geeks Union-Find Algorithm Union By Rank and Path Compression 图环算法

    相同是查找一个图是否有环的算法,可是这个算法非常牛逼,构造树的时候能够达到O(lgn)时间效率.n代表顶点数 原因是依据须要缩减了树的高度,也叫压缩路径(Path compression),名字非常高 ...

  10. ASP.NET#使用母版时,如果要使用js中的getElementById()方法取得某个内容页的元素时要注意的问题

    当使用母版,要使用js中的getElementById()方法取得某个内容页的元素时,所选取的id并不是母版中内容页的id,而是在设计内容页时设定的id例子:母版页: ...... <head ...