第一步:现在http://www-eu.apache.org/dist/zookeeper/zookeeper-3.4.9/ 下载一个gz包,然后解压。当然,zookeeper 需要在java 的环境中运行,所以,你需要安装jdk http://java.sun.com/javase/downloads/index.jsp  。

第二部:cd zookeeper-3.4.9/,cp conf/zoo_sample.cfg conf/zoo.cfg     zoo_sample.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.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients 
#maxClientCnxns=60
#
# 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=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

建议需要去看一下 zookeeper的部署和管理的指南 http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance 虽然是英文的,但是可以进行翻译

在部署和管理的指南中有提到

dataDir=/tmp/zookeeper  这个配置,在原注解中do not use /tmp for storage, /tmp here is just example sakes. 需要将tmp 换成其他目录,官方文档上是:/var/lib/zookeeper/

然后是配置各个节点 地址  最终的配置如下

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

# do not use /tmp for storage, /tmp here is just

# example sakes.

dataDir=/home/zookeeper/server/data

# the port at which the clients will connect

clientPort=2181

# the maximum number of client connections.

# increase this if you need to handle more clients

#maxClientCnxns=60

#

# 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=3

# Purge task interval in hours

# Set to "0" to disable auto purge feature

#autopurge.purgeInterval=1

server.1 = 10.211.55.9:2888:3888

server.2 = 10.211.55.12:2888:3888

server.3 = 10.211.55.13:2888:3888

10.211.55.9是我自己的ip 根据自己的ip去配置,接下来要注意:

在配置的dataDir 下创建myid 文件,内容就是对应的你当前 ip 下的 server.x

例如 server 的 ip 为 10.211.55.9  conf 文件中是 server.1 = 10.211.55.9:2888:3888   myid 对应的内容就是 1

server 的 ip 为 10.211.55.12  conf 文件中是 server.2 = 10.211.55.12:2888:3888  myid 对应的内容就是 2

  即:server.x  =>  myid = x

最后一步在每个服务器上开启服务,cd zookeeper-3.4.9/  ./bin/zkServer.sh start

启动之后,通过  ./bin/zkServer.sh status 查看服务的状态

或者

以上都是成功的

如果出现了提示:Error contacting service.It is probably not running

会有以下的原因:

1. 配置错了,仔细阅读以下流程

2. zoo.cfg 三个端口没有开启。

附上官网文档,地址 http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance 即 指南

  1. Install the Java JDK. You can use the native packaging system for your system, or download the JDK from:

    http://java.sun.com/javase/downloads/index.jsp

  2. Set the Java heap size. This is very important to avoid swapping, which will seriously degrade ZooKeeper performance. To determine the correct value, use load tests, and make sure you are well below the usage limit that would cause you to swap. Be conservative - use a maximum heap size of 3GB for a 4GB machine.

  3. Install the ZooKeeper Server Package. It can be downloaded from:

    http://zookeeper.apache.org/releases.html

  4. Create a configuration file. This file can be called anything. Use the following settings as a starting point:

    tickTime=2000
    dataDir=/var/lib/zookeeper/
    clientPort=2181
    initLimit=5
    syncLimit=2
    server.1=zoo1:2888:3888
    server.2=zoo2:2888:3888
    server.3=zoo3:2888:3888

    You can find the meanings of these and other configuration settings in the section Configuration Parameters. A word though about a few here:

    Every machine that is part of the ZooKeeper ensemble should know about every other machine in the ensemble. You accomplish this with the series of lines of the form server.id=host:port:port. The parameters host and port are straightforward. You attribute the server id to each machine by creating a file named myid, one for each server, which resides in that server's data directory, as specified by the configuration file parameter dataDir.

  5. The myid file consists of a single line containing only the text of that machine's id. So myid of server 1 would contain the text "1" and nothing else. The id must be unique within the ensemble and should have a value between 1 and 255.

  6. If your configuration file is set up, you can start a ZooKeeper server:

    $ java -cp zookeeper.jar:lib/slf4j-api-1.6.1.jar:lib/slf4j-log4j12-1.6.1.jar:lib/log4j-1.2.15.jar:conf \ org.apache.zookeeper.server.quorum.QuorumPeerMain zoo.cfg

    QuorumPeerMain starts a ZooKeeper server, JMX management beans are also registered which allows management through a JMX management console. The ZooKeeper JMX document contains details on managing ZooKeeper with JMX.

    See the script bin/zkServer.sh, which is included in the release, for an example of starting server instances.

  7. Test your deployment by connecting to the hosts:

    In Java, you can run the following command to execute simple operations:

    $ bin/zkCli.sh -server 127.0.0.1:218

zookeeper 集群简单搭建,以及Error contacting service,It is probably not running问题解决的更多相关文章

  1. 关于伪分布zookeeper集群启动出错(Error contacting service. It is probably not running.)

    今天在配置zookeeper伪分布集群的时候,发现竟然出错了,以前我都是在多台电脑上搭建,大家可以参考我写的Hadoop HA搭建中的zookeeper如何搭建 现在就来说一下为何会出错. 出错的原因 ...

  2. ZooKeeper 集群搭建 Error contacting service. It is probably not running.

    搭建环境:Centos 7 虚拟机 3台 按照此教程搭建:https://www.ilanni.com/?p=11393 之后出现错误:Error contacting service. It is ...

  3. zookeeper 集群 Cannot open channel to X at election address Error contacting service. It is probably not running.

    zookeeper集群   启动 1.问题现象. 启动每一个都提示  STARTED 但是查看 status时全部节点都报错 [root@ip-172-31-19-246 bin]# sh zkSer ...

  4. centos7下安装zookeeper&zookeeper集群的搭建

    一.centos7下安装zookeeper 1.zookeeper 下载地址 https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/ 2.安装步骤 ...

  5. zookeeper集群的搭建以及hadoop ha的相关配置

    1.环境 centos7 hadoop2.6.5 zookeeper3.4.9 jdk1.8 master作为active主机,data1作为standby备用机,三台机器均作为数据节点,yarn资源 ...

  6. 大数据平台搭建-zookeeper集群的搭建

    本系列文章主要阐述大数据计算平台相关框架的搭建,包括如下内容: 基础环境安装 zookeeper集群的搭建 kafka集群的搭建 hadoop/hbase集群的搭建 spark集群的搭建 flink集 ...

  7. [转]ZooKeeper 集群环境搭建 (本机3个节点)

    ZooKeeper 集群环境搭建 (本机3个节点) 是一个简单的分布式同步数据库(或者是小文件系统) ------------------------------------------------- ...

  8. zookeeper集群环境搭建详细图文教程

    zookeeper集群环境搭建详细图文教程 zhoubang @ 2018-01-02 [文档大纲] 友情介绍 软件环境 注意点 环境安装 1. 新建用于存储安装包以及软件安装的目录 2. 下载安装z ...

  9. Docker 一步搞定 ZooKeeper 集群的搭建

    Docker 一步搞定 ZooKeeper 集群的搭建 背景 原来学习 ZK 时, 我是在本地搭建的伪集群, 虽然说使用起来没有什么问题, 但是总感觉部署起来有点麻烦. 刚好我发现了 ZK 已经有了 ...

随机推荐

  1. 处理Oracle 监听文件listener.log

       如果连接时候变得较慢 查看Oracle日志记录,可能是因为此文件太大,超过2G, 需要定期清理,(如果多用户,记得用root,可能没权限) 查看listener.log? find / -nam ...

  2. TypeScript 命名空间

    随着代码的不断增加,我们需要有组织的组合代码.TypeScript在1.x版本中提供了命名空间的方式进行代码组织,这也是TypeScript官方代码的组织方式.同时,TypeScript还实现了Jav ...

  3. eclipse设置text file encoding UTF-8和文件的换行符 Unix 格式

    阿里华山版java开发手册代码格式第10条: 步骤:1.Window - Preferences, 2.左边选择 General - Workspace , 3.右边Text file encodin ...

  4. LaTeX 课本、LaTeX 学习方法、LaTeX 入门(2)

    1. 关于TeX,LaTeX,MikTex,CTeX等的区别 2. 课本 课本1 >> 下载链接:复制链接到迅雷或IDM下载很快 课本2 >> 下载链接:复制链接到迅雷或IDM ...

  5. STM32之串口波特率计算

    1.1 波特率结构框图 1.2 波特率寄存器示意图 1.3 波特率计算公式示意图 两图看出,串口波特率寄存器是一个32位,只用低16位,低16位又划分,低4位用来装小数,其他用来装整数. 波特率计算公 ...

  6. centos7安装php7.3的redis扩展(不是redis服务!)

    PHP其他扩展加装扩展也是一样的步骤~ PHP官网下载redis扩展: http://pecl.php.net/package/redis 稳定版吧: [root@wf ~]# wget http:/ ...

  7. Python开发【第一章】:简介和入门

    Python简介 Python的创始人为Guido van Rossum.1989年圣诞节期间,在阿姆斯特丹,Guido为了打发圣诞节的无趣,决心开发一个新的脚本解释程序,做为ABC 语言的一种继承. ...

  8. vue的就地复用--- v-for与:key

    v-for遵循的是vue的就地复用原则.文本与数据是绑定的,所以当文本被重新渲染的时候,列表也会被重新渲染. 就地复用只适用于不依赖子组件状态或临时DOM状态的列表渲染输出.[比如表单输入值的列表渲染 ...

  9. JAVA堆,栈的区别,用AarrayList、LinkedList自定义栈

    大家都知道java模拟机在运行时要开辟空间所以它有特定的五个内存划分: 1.寄存器:    2.本地方法区:    3.方法区:    4.栈内存:    5.堆内存: 但是我们今天来注重讲一下栈和堆 ...

  10. protobuf的使用(netty传输多种对象类型)

    重点是: 1.枚举DataType的定义 2.oneof的使用