下载:apache-zookeeper-3.5.5.tar.gz

进入zookeeper安装目录查看lib文件夹和zookeeper-3.5.5.jar是否存在,如果没有需要手动添加,不然启动时会报错。
注:启动失败时,可以进入out.log日志进行查看错误原因

[hadoop@hadoop01 apache-zookeeper-3.5.5]$ ls -l
total 176
drwxr-xr-x.  2 hadoop hadoop   232 Apr  9 19:13 bin
-rw-r--r--.  1 hadoop hadoop 94388 May  3 19:40 build.xml
drwxr-xr-x.  2 hadoop hadoop   120 Sep 20 00:45 conf
-rw-r--r--.  1 hadoop hadoop   411 Feb 15  2019 excludeFindBugsFilter.xml
-rw-r--r--.  1 hadoop hadoop  1709 Feb 15  2019 ivysettings.xml
-rw-r--r--.  1 hadoop hadoop  7597 Apr  9 19:13 ivy.xml
drwxr-xr-x.  2 root   root    4096 Sep 20 00:02 lib
-rw-r--r--.  1 hadoop hadoop 11358 Feb 15  2019 LICENSE.txt
drwxrwxr-x.  2 hadoop hadoop    50 Sep 19 23:34 logs
-rw-r--r--.  1 hadoop hadoop   432 Apr  9 19:13 NOTICE.txt
-rw-r--r--.  1 hadoop hadoop  1398 Apr  2 21:05 owaspSuppressions.xml
-rw-r--r--.  1 hadoop hadoop 26485 May  3 19:40 pom.xml
-rw-r--r--.  1 hadoop hadoop  1560 May  3 19:41 README.md
-rw-r--r--.  1 hadoop hadoop  1347 Apr  2 21:05 README_packaging.txt
drwxr-xr-x.  3 hadoop hadoop    32 May  3 20:07 zookeeper-assembly
drwxr-xr-x.  3 hadoop hadoop    47 May  3 20:07 zookeeper-client
drwxr-xr-x. 12 hadoop hadoop  4096 May  3 19:40 zookeeper-contrib
drwxr-xr-x.  3 hadoop hadoop    32 May  3 20:07 zookeeper-docs
drwxr-xr-x.  3 hadoop hadoop    35 Feb 15  2019 zookeeper-it
drwxr-xr-x.  3 hadoop hadoop    32 May  3 20:07 zookeeper-jute
drwxr-xr-x.  5 hadoop hadoop   176 May  3 20:07 zookeeper-recipes
drwxr-xr-x.  7 hadoop hadoop    84 May  3 20:07 zookeeper-server

配置zookeeper:
进入安装目录下conf文件夹,执行下面命令对zoo_sample.cfg进行复制修改;
[hadoop@hadoop01 conf]$ cp zoo_sample.cfg zoo.cfg
[hadoop@hadoop01 conf]$ gedit zoo.cfg
添加内容:
server.1 = hadoop01:2888:3888
server.2 = hadoop02:2888:3888
server.3 = hadoop03:2888:3888

创建节点标识文件:
[hadoop@hadoop01 ~]$ mkdir -p /tmp/zookeeper
[hadoop@hadoop01 ~]$ gedit /tmp/zookeeper/myid
添加内容(输入对应服务器的ID号):
1
注:在其他节点也要进行同样设置,只是ID号不同

复制zookeeper安装文件:
scp -r apache-zookeeper-3.5.5 hadoop02:~/
scp -r apache-zookeeper-3.5.5 hadoop03:~/

测试zookeeper:
[hadoop@hadoop01 apache-zookeeper-3.5.5]$ bin/zkServer.sh start --启动hadoop01上的zookeeper
ZooKeeper JMX enabled by default
Using config: /home/hadoop/apache-zookeeper-3.5.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[hadoop@hadoop02 apache-zookeeper-3.5.5]$ bin/zkServer.sh start --启动hadoop02上的zookeeper
ZooKeeper JMX enabled by default
Using config: /home/hadoop/apache-zookeeper-3.5.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[hadoop@hadoop03 apache-zookeeper-3.5.5]$ bin/zkServer.sh start --启动hadoop03上的zookeeper
ZooKeeper JMX enabled by default
Using config: /home/hadoop/apache-zookeeper-3.5.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[hadoop@hadoop01 apache-zookeeper-3.5.5]$ bin/zkServer.sh status --查看zookeeper集群启动状态
ZooKeeper JMX enabled by default
Using config: /home/hadoop/apache-zookeeper-3.5.5/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: follower
注1:如果服务器不启动两台以上,会报错
注2:我们可以看到下载hadoop01是follower,根据zookeeper工作原理,集群中应该有一个leader
[hadoop@hadoop02 apache-zookeeper-3.5.5]$ bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/hadoop/apache-zookeeper-3.5.5/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: leader

zookeeper客户端命令:
[hadoop@hadoop02 apache-zookeeper-3.5.5]$ bin/zkCli.sh -server hadoop02:2181 --进入命令模式
Connecting to hadoop02:2181
2019-09-20 01:08:45,673 [myid:] - INFO  [main:Environment@109] - Client environment:zookeeper.version=3.5.5-390fe37ea45dee01bf87dc1c042b5e3dcce88653, built on 05/03/2019 12:07 GMT
2019-09-20 01:08:45,675 [myid:] - INFO  [main:Environment@109] - Client environment:host.name=hadoop02
2019-09-20 01:08:45,676 [myid:] - INFO  [main:Environment@109] - Client environment:java.version=1.8.0_11
2019-09-20 01:08:45,678 [myid:] - INFO  [main:Environment@109] - Client environment:java.vendor=Oracle Corporation
2019-09-20 01:08:45,678 [myid:] - INFO  [main:Environment@109] - Client environment:java.home=/usr/java/jdk1.8.0_11/jre
2019-09-20 01:08:45,678 [myid:] - INFO  [main:Environment@109] - Client environment:java.class.path=/home/hadoop/apache-zookeeper-3.5.5/bin/../zookeeper-server/target/classes:/home/hadoop/apache-zookeeper-3.5.5/bin/../build/classes:/home/hadoop/apache-zookeeper-3.5.5/bin/../zookeeper-server/target/lib/*.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../build/lib/*.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/zookeeper-jute-3.5.5.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/zookeeper-3.5.5.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/slf4j-log4j12-1.7.25.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/slf4j-api-1.7.25.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/netty-all-4.1.29.Final.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/log4j-1.2.17.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/json-simple-1.1.1.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/jline-2.11.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/jetty-util-9.4.17.v20190418.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/jetty-servlet-9.4.17.v20190418.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/jetty-server-9.4.17.v20190418.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/jetty-security-9.4.17.v20190418.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/jetty-io-9.4.17.v20190418.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/jetty-http-9.4.17.v20190418.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/javax.servlet-api-3.1.0.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/jackson-databind-2.9.8.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/jackson-core-2.9.8.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/jackson-annotations-2.9.0.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/commons-cli-1.2.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../lib/audience-annotations-0.5.0.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../zookeeper-*.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../zookeeper-server/src/main/resources/lib/*.jar:/home/hadoop/apache-zookeeper-3.5.5/bin/../conf:
2019-09-20 01:08:45,678 [myid:] - INFO  [main:Environment@109] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2019-09-20 01:08:45,678 [myid:] - INFO  [main:Environment@109] - Client environment:java.io.tmpdir=/tmp
2019-09-20 01:08:45,678 [myid:] - INFO  [main:Environment@109] - Client environment:java.compiler=<NA>
2019-09-20 01:08:45,678 [myid:] - INFO  [main:Environment@109] - Client environment:os.name=Linux
2019-09-20 01:08:45,678 [myid:] - INFO  [main:Environment@109] - Client environment:os.arch=amd64
2019-09-20 01:08:45,678 [myid:] - INFO  [main:Environment@109] - Client environment:os.version=3.10.0-957.el7.x86_64
2019-09-20 01:08:45,679 [myid:] - INFO  [main:Environment@109] - Client environment:user.name=hadoop
2019-09-20 01:08:45,679 [myid:] - INFO  [main:Environment@109] - Client environment:user.home=/home/hadoop
2019-09-20 01:08:45,679 [myid:] - INFO  [main:Environment@109] - Client environment:user.dir=/home/hadoop/apache-zookeeper-3.5.5
2019-09-20 01:08:45,679 [myid:] - INFO  [main:Environment@109] - Client environment:os.memory.free=28MB
2019-09-20 01:08:45,681 [myid:] - INFO  [main:Environment@109] - Client environment:os.memory.max=228MB
2019-09-20 01:08:45,681 [myid:] - INFO  [main:Environment@109] - Client environment:os.memory.total=31MB
2019-09-20 01:08:45,685 [myid:] - INFO  [main:ZooKeeper@868] - Initiating client connection, connectString=hadoop02:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@504bae78
2019-09-20 01:08:45,691 [myid:] - INFO  [main:X509Util@79] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2019-09-20 01:08:45,701 [myid:] - INFO  [main:ClientCnxnSocket@237] - jute.maxbuffer value is 4194304 Bytes
2019-09-20 01:08:45,708 [myid:] - INFO  [main:ClientCnxn@1653] - zookeeper.request.timeout value is 0. feature enabled=
Welcome to ZooKeeper!
2019-09-20 01:08:45,715 [myid:hadoop02:2181] - INFO  [main-SendThread(hadoop02:2181):ClientCnxn$SendThread@1112] - Opening socket connection to server hadoop02/192.168.1.101:2181. Will not attempt to authenticate using SASL (unknown error)
2019-09-20 01:08:45,722 [myid:hadoop02:2181] - INFO  [main-SendThread(hadoop02:2181):ClientCnxn$SendThread@959] - Socket connection established, initiating session, client: /192.168.1.101:42902, server: hadoop02/192.168.1.101:2181
JLine support is enabled
[zk: hadoop02:2181(CONNECTING) 0] 2019-09-20 01:08:45,779 [myid:hadoop02:2181] - INFO  [main-SendThread(hadoop02:2181):ClientCnxn$SendThread@1394] - Session establishment complete on server hadoop02/192.168.1.101:2181, sessionid = 0x200005e4ec10000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

[zk: hadoop02:2181(CONNECTED) 0] create /zk 'MyNode' --创建znode
Created /zk
[zk: hadoop02:2181(CONNECTED) 2] ls /zk --显示znode
[]

[zk: hadoop02:2181(CONNECTED) 4] quit --退出

WATCHER::

WatchedEvent state:Closed type:None path:null
2019-09-20 01:11:00,516 [myid:] - INFO  [main:ZooKeeper@1422] - Session: 0x200005e4ec10000 closed
2019-09-20 01:11:00,516 [myid:] - INFO  [main-EventThread:ClientCnxn$EventThread@524] - EventThread shut down for session: 0x200005e4ec10000
[hadoop@hadoop02 apache-zookeeper-3.5.5]$ --返回界面

【zookeeper】apache-zookeeper-3.5.5的安装测试的更多相关文章

  1. 决战大数据之三-Apache ZooKeeper Standalone及复制模式安装及测试

    决战大数据之三-Apache ZooKeeper Standalone及复制模式安装及测试 [TOC] Apache ZooKeeper 单机模式安装 创建hadoop用户&赋予sudo权限, ...

  2. windows下安装apache zookeeper

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件.它是一个为分布式应用提供一致性服务的软件,提供的功 ...

  3. 在 Linux 多节点安装配置 Apache Zookeeper 分布式集群

    规划: 三台物理服务器就形成了(法定人数).对于高可用性集群,您可以使用高于3的任何奇数.例如,如果设置5台服务器,则集群可以处理两个故障节点等. 物理服务器需要开启的端口 2888 , 3888 和 ...

  4. zookeeper-3.5.5安装报错:找不到或无法加载主类 org.apache.zookeeper.server.quorum.QuorumPeerMain

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/jiangxiulilinux/artic ...

  5. Apache Zookeeper 使用-安装

    Apache Zookeeper 使用-安装 官方网站 https://zookeeper.apache.org/ 官方文档 下载地址 Zookeeper 是什么? ZooKeeper is a ce ...

  6. apache zookeeper的安装

    original article:http://zookeeper.praveendeshmane.co.in/zookeeper/zookeeper-3-4-6-single-server-setu ...

  7. zookeeper 安装 测试及集群

    centos 安装 zookeeper-3.5.2-alpha.tar.gz 网上搜索了 一下 安装教程 其实很简单 主要总结一下 中间遇到的坑 1.zookeeper 3.4.6 启动失败. 很有可 ...

  8. 1. Apache ZooKeeper快速课程入门

    Tips Tips做一个终身学习的人! 日拱一卒,功不唐捐. 在过去的几十年里,互联网改变了我们生活的方式.Internet上提供的服务通常由复杂的软件系统支持,这些系统跨越了大量的服务器,而且常常位 ...

  9. 2.动手实操Apache ZooKeeper

    Tips 做一个终身学习的人! 日拱一卒,功不唐捐. 在本节中,我们将讲解如何下载并安装Apache ZooKeeper,以便我们可以直接开始使用ZooKeeper. 本部分旨在通过提供详细的安装和使 ...

  10. 【ZooKeeper】ZooKeeper安装及简单操作

    ZooKeeper介绍 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件.它是一个为分布式应用提供一 ...

随机推荐

  1. python虛擬環境和工具

    1.命令 pip install virtualenvwrapper-win mkvirtualenv env_xadmin deactivate  退出 pip list pip install m ...

  2. 【面试】c++单例模式

    1. 单例模式 #include <iostream> using namespace std; class CSingleton { private: CSingleton() {} / ...

  3. 如何用java代码写一个堆栈

    public class Stack { int[] data; int maxSize; int top; public Stack(int maxSize) { this.maxSize = ma ...

  4. 报错:ImportError: cannot import name "KafkaProducer" from "kafka"

    报错背景: 在Pycharm中安装完成kafka-python之后,我开始在代码中引入kafka的包. from kafka import KafkaProducer 但是引入之后报错 报错现象: 报 ...

  5. Python - Django - 序列化

    app01/__int__.py: import pymysql pymysql.install_as_MySQLdb() app01/models.py: from django.db import ...

  6. C++运行出现"what(): std::bad_alloc"的解决办法

    注:这里只是我的代码出现这种情况及对应的解决办法,你的代码不一定出现和我一样的情况.左移这篇随笔仅供参考. 运行程序出现如下结果: terminate called after throwing an ...

  7. js中 这些值是false

  8. Linux开机报错,提示根目录有错误,无法通过检测进入系统

    报错信息如下: VolGroup-lv_root contains a file system with errors, check forced. 修复方法:(因为我的是虚拟机,可以随意做备份,所以 ...

  9. Graphviz(01) notepad++ Run xxx.gv

    1.新建文件dot.bat 放到 d:\,内容如下: set gvname=%% @echo '"d:\dot.bat" "$(FULL_CURRENT_PATH)&qu ...

  10. PHP检测日期格式

    <?php $date1 = '2019-01-01'; $date2 = '2019-01-01 23:59'; $date3 = '2019-01-01 23:59:59'; $date4 ...