专栏首页浅枫沐雪搭建zookeeper集群

搭建zookeeper集群

  • 下载zookeeper-3.4.14.tar.gz
  • 使用xshell的rz命令或者xftp工具将zookeeper-3.4.14.tar.gz压缩文件上传到三台主机的 /opt 目录下
  • 解压 zookeeper-3.4.14.tar.gz tar -zxvf zookeeper-3.4.14.tar.gz
  • 切换到zookeeper-3.4.14目录,创建data和log文件夹【三台机器都要创建】 cd zookeeper-3.4.14 mkdir data log ############################################### [root@hservice zookeeper-3.4.14]# ls -l 总用量 1672 drwxr-xr-x 2 2002 2002 202 3月 7 2019 bin -rw-rw-r-- 1 2002 2002 97426 3月 7 2019 build.xml drwxr-xr-x 2 2002 2002 77 3月 7 2019 conf drwxr-xr-x 2 root root 6 9月 29 19:13 data drwxr-xr-x 2 2002 2002 4096 3月 7 2019 dist-maven -rw-rw-r-- 1 2002 2002 1709 3月 7 2019 ivysettings.xml -rw-rw-r-- 1 2002 2002 10742 3月 7 2019 ivy.xml drwxr-xr-x 4 2002 2002 308 3月 7 2019 lib -rw-rw-r-- 1 2002 2002 11970 3月 7 2019 LICENSE.txt drwxr-xr-x 2 root root 6 9月 29 19:13 log -rw-rw-r-- 1 2002 2002 3132 3月 7 2019 NOTICE.txt -rw-rw-r-- 1 2002 2002 31622 3月 7 2019 pom.xml -rw-rw-r-- 1 2002 2002 1765 3月 7 2019 README.md -rw-rw-r-- 1 2002 2002 1770 3月 7 2019 README_packaging.txt drwxr-xr-x 3 2002 2002 22 3月 7 2019 src -rw-rw-r-- 1 2002 2002 1515359 3月 7 2019 zookeeper-3.4.14.jar -rw-rw-r-- 1 2002 2002 836 3月 7 2019 zookeeper-3.4.14.jar.asc -rw-rw-r-- 1 2002 2002 33 3月 7 2019 zookeeper-3.4.14.jar.md5 -rw-rw-r-- 1 2002 2002 41 3月 7 2019 zookeeper-3.4.14.jar.sha1 drwxr-xr-x 3 2002 2002 47 3月 7 2019 zookeeper-client drwxr-xr-x 12 2002 2002 4096 3月 7 2019 zookeeper-contrib drwxr-xr-x 7 2002 2002 4096 3月 7 2019 zookeeper-docs drwxr-xr-x 3 2002 2002 35 3月 7 2019 zookeeper-it drwxr-xr-x 4 2002 2002 46 3月 7 2019 zookeeper-jute drwxr-xr-x 5 2002 2002 176 3月 7 2019 zookeeper-recipes drwxr-xr-x 3 2002 2002 32 3月 7 2019 zookeeper-server
  • 切换到conf目录下, 复制zoo_sample.cfg 文件名为zoo.cfg cd conf [root@hservice conf]# ls configuration.xsl log4j.properties zoo_sample.cfg [root@hservice conf]# cp zoo_sample.cfg zoo.cfg [root@hservice conf]# ls configuration.xsl log4j.properties zoo.cfg zoo_sample.cfg [root@hservice conf]#
  • 修改zoo.cfg文件
# 需要修改的文件
dataDir=/opt/zookeeper-3.4.14/data
dataLogDir=/opt/zookeeper-3.4.14/log
server.1=192.168.129.200:2888:3888
server.2=192.168.129.201:2888:3888
server.3=192.168.129.202:2888:3888

使用scp将修改完的zoo.cfg文件赋值到其它两台主机conf目录下

scp zoo.cfg root@node1:/opt/zookeeper-3.4.14/conf/
  • 为三台主机添加zookeeper环境变量 ZOOKEEPER_HOME=/opt/zookeeper-3.4.14 PATH=$PATH:$ZOOKEEPER_HOME/bin

启动zookeeper

# 三台都需要执行
/opt/zookeeper-3.4.14/bin
zkServer.sh  status # 查看状态
zkServer.sh  start # 启动zookeeper服务
####################################
zkCli.sh # 启动zookeeper工具,任意一台机器执行 
# DEMO
[root@hservice bin]# zkServer.sh 
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.14/bin/../conf/zoo.cfg
Usage: /opt/zookeeper-3.4.14/bin/zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}
[root@hservice bin]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: follower
[root@hservice bin]# zkCli.sh 
Connecting to localhost:2181
2019-09-29 20:24:46,132 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT
2019-09-29 20:24:46,136 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=hservice
2019-09-29 20:24:46,136 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_181
2019-09-29 20:24:46,138 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2019-09-29 20:24:46,138 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/opt/jdk1.8.0_181/jre
2019-09-29 20:24:46,138 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/opt/zookeeper-3.4.14/bin/../zookeeper-server/target/classes:/opt/zookeeper-3.4.14/bin/../build/classes:/opt/zookeeper-3.4.14/bin/../zookeeper-server/target/lib/*.jar:/opt/zookeeper-3.4.14/bin/../build/lib/*.jar:/opt/zookeeper-3.4.14/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/zookeeper-3.4.14/bin/../lib/slf4j-api-1.7.25.jar:/opt/zookeeper-3.4.14/bin/../lib/netty-3.10.6.Final.jar:/opt/zookeeper-3.4.14/bin/../lib/log4j-1.2.17.jar:/opt/zookeeper-3.4.14/bin/../lib/jline-0.9.94.jar:/opt/zookeeper-3.4.14/bin/../lib/audience-annotations-0.5.0.jar:/opt/zookeeper-3.4.14/bin/../zookeeper-3.4.14.jar:/opt/zookeeper-3.4.14/bin/../zookeeper-server/src/main/resources/lib/*.jar:/opt/zookeeper-3.4.14/bin/../conf:.:/opt/jdk1.8.0_181/lib/tools.jar:/opt/jdk1.8.0_181/jre/rt.jar
2019-09-29 20:24:46,138 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2019-09-29 20:24:46,138 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2019-09-29 20:24:46,139 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2019-09-29 20:24:46,139 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2019-09-29 20:24:46,141 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2019-09-29 20:24:46,142 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-862.el7.x86_64
2019-09-29 20:24:46,142 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2019-09-29 20:24:46,142 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2019-09-29 20:24:46,142 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/opt/zookeeper-3.4.14/bin
2019-09-29 20:24:46,143 [myid:] - INFO  [main:ZooKeeper@442] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@255316f2
2019-09-29 20:24:46,175 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1025] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
Welcome to ZooKeeper!
JLine support is enabled
2019-09-29 20:24:46,440 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2019-09-29 20:24:46,458 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x6d7c4873940004, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper, hbase]
[zk: localhost:2181(CONNECTED) 1] 

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • Python31 Socket2

    上图中在cmd里也使用ipconfig命令,但是可以看到的是显示的内容比通过python显示的内容要多,这是因为我们设置接收长度为1024,所以client一...

    py3study
  • WPF 中如何绑定附加属性?XAML 中记得加括号,C# 中记得不能用字符串

    在 XAML 中写绑定是 WPF 学习的必修课,进阶一点的,是用 C# 代码来写绑定。然而一旦绑定的属性是附加属性,好多小伙伴就会开始遇到坑了。

    walterlv
  • 人工智能|备战Tensorflow技能认证之两种快速构建模型的常用方式

    Tensorflow认证考试内容五项中的第一项是基础/简单模型,第二项是学习数据集模型。小编猜想,这两者都是比较基础的知识,涉及到的知识应该主要包含:全连接神经...

    算法与编程之美
  • 一周简报 | Talkingdata投资市场研究公司Newzoo,打造国际化精细分析

    编辑导语 UCloud U市场 镜像2.0时代震撼发布;美洽SDK:新增来源分布报表下钻分析功能;腾讯云作为钻石级赞助商,亮相第五届全球移动游戏大会;Talki...

    BestSDK
  • Hacker基础之Linux篇:基础Linux命令十一

    上节我们说到了netstat这个用于查看网络状态的命令,现在我们介绍其他查看网络状态的命令

    用户1631416
  • Jpa配置实体类创建时间更新时间自动赋值,@CreateDate,@LastModifiedDate

    操作数据库映射实体类时,通常需要记录createTime和updateTime,如果每个对象新增或修改去都去手工操作创建时间、更新时间,会显得比较繁琐。

    天涯泪小武
  • SpringCloud 整合zookeeper搭建服务注册中心原

    用户5927264

扫码关注云+社区

领取腾讯云代金券