当前位置:   article > 正文

ZooKeeper 集群部署_cdh zookeeper jmx代理

cdh zookeeper jmx代理

目录

1、下载apache-zookeeper包

2、修改配置

3、添加服务器id

4、启动ZooKeeper集群

5、客户端连接

6、添加新节点:

部署ZooKeeper集群之前请先部署jdk

使用hadoop用户部署ZooKeeper集群

1、下载apache-zookeeper包

部署机器:

  1. 192.168.20.11 node1
  2. 192.168.20.12 node2
  3. 192.168.20.13 node3

依次在node1,node2,node3上部署:

  1. # 进入安装目录
  2. [hadoop@node1 local]$ cd /usr/local
  3. # 下载apache-ZooKeeper二进制包
  4. [hadoop@node1 local]$ sudo wget https://archive.apache.org/dist/zookeeper/zookeeper-3.6.3/apache-zookeeper-3.6.3-bin.tar.gz
  1. # 解压
  2. [hadoop@node1 local]$ sudo tar -xvf apache-zookeeper-3.6.3-bin.tar.gz
  1. # 制作软链接
  2. [hadoop@node1 local]$ sudo ln -s apache-zookeeper-3.6.3-bin apache-zookeeper
  1. # 更改文件属主和属组为hadoop
  2. [hadoop@node1 local]$ sudo chown hadoop:hadoop -R apache-zookeeper
  3. [hadoop@node1 local]$ sudo chown hadoop:hadoop -R apache-zookeeper-3.6.3-bin

################################################### 

2、修改配置

依次在node1,node2,node3上配置:

  1. [hadoop@node1 apache-zookeeper]$ cd /usr/local/apache-zookeeper/conf
  2. # 将zoo_sample.cfg 复制一份 改名为 zoo.cfg
  3. [hadoop@node1 conf]$ sudo cp zoo_sample.cfg zoo.cfg
  4. [hadoop@node1 conf]$ vim zoo.cfg
  5. dataDir=/data/zookeeper/data
  6. server.1=192.168.20.11:2888:3888
  7. server.2=192.168.20.12:2888:3888
  8. server.3=192.168.20.13:2888:3888

启用jmx,在下面文件最后加上JMX配置

  1. [hadoop@node1 apache-zookeeper]$ cd /usr/local/apache-zookeeper/bin/
  2. [hadoop@node1 bin]$ vim zkEnv.sh
  3. JMXLOCALONLY=false
  4. JMXDISABLE=false
  5. JMXPORT=9998
  6. JMXAUTH=false
  7. JMXSSL=false

启用zkcli权限(for kafka eagle), 下面文件77行之后,添加 # zkcli permission ...

  1. [hadoop@node1 bin]$ vim zkServer.sh
  2. # zkcli permission
  3. ZOOMAIN="-Dzookeeper.4lw.commands.whitelist=* ${ZOOMAIN}"

 ################################################### 

3、添加服务器id

  1. [hadoop@node1 data]$ sudo mkdir -p /data/zookeeper/data/
  2. [hadoop@node1 data]$ sudo chown -R hadoop:hadoop zookeeper/
  3. [hadoop@node1 data]$sudo echo 1 > /data/zookeeper/data/myid
  4. # 分别在node2和node3添加
  5. [hadoop@node2 data]$sudo echo 2 > /data/zookeeper/data/myid
  6. [hadoop@node3 data]$sudo echo 3 > /data/zookeeper/data/myid

###################################################  

4、启动ZooKeeper集群

在node1和node2,node3操作:

  1. [hadoop@node1 bin]$ ./zkServer.sh start >/data/zookeeper/logs/startup.log 2>&1
  2. # 查看ZooKeeper集群状态 可以看到三台机器,两个follower,一个leader
  3. [hadoop@node1 bin]$ ./zkServer.sh status
  4. /usr/local/jdk/bin/java
  5. ZooKeeper JMX enabled by default
  6. ZooKeeper remote JMX Port set to 9998
  7. ZooKeeper remote JMX authenticate set to false
  8. ZooKeeper remote JMX ssl set to false
  9. ZooKeeper remote JMX log4j set to true
  10. Using config: /usr/local/apache-zookeeper/bin/../conf/zoo.cfg
  11. Client port found: 2181. Client address: localhost. Client SSL: false.
  12. Mode: follower
  13. [hadoop@node2 bin]$ ./zkServer.sh status
  14. /usr/local/jdk/bin/java
  15. ZooKeeper JMX enabled by default
  16. ZooKeeper remote JMX Port set to 9998
  17. ZooKeeper remote JMX authenticate set to false
  18. ZooKeeper remote JMX ssl set to false
  19. ZooKeeper remote JMX log4j set to true
  20. Using config: /usr/local/apache-zookeeper/bin/../conf/zoo.cfg
  21. Client port found: 2181. Client address: localhost. Client SSL: false.
  22. Mode: follower
  23. [hadoop@node3 bin]$ ./zkServer.sh status
  24. /usr/local/jdk/bin/java
  25. ZooKeeper JMX enabled by default
  26. ZooKeeper remote JMX Port set to 9998
  27. ZooKeeper remote JMX authenticate set to false
  28. ZooKeeper remote JMX ssl set to false
  29. ZooKeeper remote JMX log4j set to true
  30. Using config: /usr/local/apache-zookeeper/bin/../conf/zoo.cfg
  31. Client port found: 2181. Client address: localhost. Client SSL: false.
  32. Mode: leader

###################################################  

5、客户端连接

  1. [hadoop@node1 bin]$ ./zkCli.sh -server 127.0.0.1:2181
  2. [zk: 127.0.0.1:2181(CONNECTED) 0] ls /
  3. [zookeeper]
  4. # 创建永久节点
  5. > create /zk_test my_data
  6. > get /zk_test
  7. > set /zk_test junk
  8. > delete /zk_test

###################################################  

6、添加新节点:

  1. 1. 更新所有服务器的配置文件
  2. 2. 先轮流重启 Follower
  3. 3. 最后重启 Leader

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号