zookeeper伪集群
Zookeeper运行需要java环境,需要安装jdk,建议本地下载好需要的安装包然后上传到服务器上面,服务器上面下载速度太慢。
上传
[root@192 ~]# java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
解压
[root@192 modules]# tar -zxvf zookeeper-3.4.13.tar.gz -C /opt/soft/
拷贝三份
[root@192 soft]# cp -r zookeeper-3.4.13/ zookeeper1
[root@192 soft]# cp -r zookeeper1 zookeeper2
[root@192 soft]# cp -r zookeeper1 zookeeper3
[root@192 soft]# ll
total 16
drwxr-xr-x. 12 root root 4096 Sep 9 14:44 zookeeper1
drwxr-xr-x. 12 root root 4096 Sep 9 14:45 zookeeper2
drwxr-xr-x. 12 root root 4096 Sep 9 14:46 zookeeper3
drwxr-xr-x. 12 501 games 4096 Sep 9 14:51 zookeeper-3.4.13
修改配置文件
重命名并修改zookeeper1
配置文件
[root@192 conf]# mv zoo_sample.cfg zoo.cfg
[root@192 conf]# ll
total 20
-rw-r--r--. 1 root root 535 Sep 9 11:38 configuration.xsl
-rw-r--r--. 1 root root 2161 Sep 9 11:38 log4j.properties
-rw-r--r--. 1 root root 285 Sep 9 15:03 zoo.cfg
-rw-r--r--. 1 root root 2306 Sep 9 11:48 zookeeper.out
-rw-r--r--. 1 root root 922 Sep 9 11:38 zoo_sample.cfg
[root@192 conf]# vim zoo.cfg
[root@192 conf]# cat zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/soft/zookeeper1/data
dataLogDir=/opt/soft/zookeeper1/logs
clientPort=2181
autopurge.snapRetainCount=500
autopurge.purgeInterval=24
server.1= 192.168.1.101:2888:3888
server.2= 192.168.1.101:2889:3889
server.3= 192.168.1.101:2890:3890
[root@192 conf]#
修改zookeeper2
配置文件
[root@192 conf]# cat /opt/soft/zookeeper2/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataLogDir=/opt/soft/zookeeper2/logs
dataDir=/opt/soft/zookeeper2/data
clientPort=2182
autopurge.snapRetainCount=500
autopurge.purgeInterval=24
server.1= 192.168.1.101:2888:3888
server.2= 192.168.1.101:2889:3889
server.3= 192.168.1.101:2890:3890
修改zookeeper3
配置文件
[root@192 conf]# cat /opt/soft/zookeeper3/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataLogDir=/opt/soft/zookeeper3/logs
dataDir=/opt/soft/zookeeper3/data
clientPort=2183
autopurge.snapRetainCount=500
autopurge.purgeInterval=24
server.1= 192.168.1.101:2888:3888
server.2= 192.168.1.101:2889:3889
server.3= 192.168.1.101:2890:3890
查看配置好的三个配置文件
[root@192 ~]# egrep -v "^#|^$" /opt/soft/zookeeper1/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/soft/zookeeper1/data
dataLogDir=/opt/soft/zookeeper1/logs
clientPort=2181
autopurge.snapRetainCount=500
autopurge.purgeInterval=24
server.1= 192.168.1.101:2888:3888
server.2= 192.168.1.101:2889:3889
server.3= 192.168.1.101:2890:3890
[root@192 ~]# egrep -v "^#|^$" /opt/soft/zookeeper2/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataLogDir=/opt/soft/zookeeper2/logs
dataDir=/opt/soft/zookeeper2/data
clientPort=2182
autopurge.snapRetainCount=500
autopurge.purgeInterval=24
server.1= 192.168.1.101:2888:3888
server.2= 192.168.1.101:2889:3889
server.3= 192.168.1.101:2890:3890
[root@192 ~]# egrep -v "^#|^$" /opt/soft/zookeeper3/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataLogDir=/opt/soft/zookeeper3/logs
dataDir=/opt/soft/zookeeper3/data
clientPort=2183
autopurge.snapRetainCount=500
autopurge.purgeInterval=24
server.1= 192.168.1.101:2888:3888
server.2= 192.168.1.101:2889:3889
server.3= 192.168.1.101:2890:3890
参数 | 说明 |
---|---|
tickTime=2000 |
这个时间是作为zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是说每个tickTime 时间就会发送一个心跳 |
initLimit=10 |
这个配置项是用来配置zookeeper 接受客户端(这里所说的客户端不是用户连接zookeeper 服务器的客户端,而是zookeeper服务器集群中连接到leader的follower服务器)初始化连接时最长能忍受多少个心跳时间间隔数。当已经超过 10 个心跳的时间(也就是tickTime )长度后 zookeeper 服务器还没有收到客户端的返回信息,那么表明这个客户端连接失败。总的时间长度就是 10*2000=20 秒 |
syncLimit=5 |
这个配置项标识leader 与follower 之间发送消息,请求和应答时间长度,最长不能超过多少个tickTime的时间长度,总的时间长度就是5*2000=10 秒 |
dataDir=/opt/soft/zookeeper1/data |
zookeeper 保存数据的目录,默认情况下zookeeper 将写数据的日志文件也保存在这个目录里; |
dataLogDir=/opt/soft/zookeeper1/logs |
zookeeper 保存日志文件数据 |
clientPort=2181 |
这个端口就是客户端连接Zookeeper 服务器的端口,Zookeeper 会监听这个端口接受客户端的访问请求 |
server.1= 192.168.1.101:2888:3888 |
server.A=B:C:D 中的A 是一个数字,表示这个是第几号服务器,B 是这个服务器的IP 地址,C 第一个端口用来集群成员的信息交换,表示这个服务器与集群中的leader 服务器交换信息的端口,D 是在leader 挂掉时专门用来进行选举leader 所用的端口。 |
创建数据目录和日志目录
[root@192 ~]# mkdir -p /opt/soft/zookeeper1/{data,logs}
[root@192 ~]# mkdir -p /opt/soft/zookeeper2/{data,logs}
[root@192 ~]# mkdir -p /opt/soft/zookeeper3/{data,logs}
[root@192 ~]# echo "1">/opt/soft/zookeeper1/data/myid
[root@192 ~]# echo "2">/opt/soft/zookeeper2/data/myid
[root@192 ~]# echo "3">/opt/soft/zookeeper3/data/myid
[root@192 ~]# cat /opt/soft/zookeeper1/data/myid
1
[root@192 ~]# cat /opt/soft/zookeeper2/data/myid
2
[root@192 ~]# cat /opt/soft/zookeeper3/data/myid
3
[root@192 ~]#
myid
中的值对应server.A=B:C:D
中的A
配置环境变量
[root@192 ~]# vim /etc/profile
#jdk
export JAVA_HOME=/usr/java/jdk1.8.0_202-amd64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
# append zk1_env
export PATH=$PATH:/opt/soft/zookeeper1/bin
# append zk2_env
export PATH=$PATH:/opt/soft/zookeeper2/bin
# append zk3_env
export PATH=$PATH:/opt/soft/zookeeper3/bin
启动
[root@192 ~]# /opt/soft/zookeeper1/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper1/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@192 ~]# /opt/soft/zookeeper1/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper1/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
[root@192 ~]# /opt/soft/zookeeper2/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper2/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@192 ~]# /opt/soft/zookeeper1/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper1/bin/../conf/zoo.cfg
Mode: follower
[root@192 ~]# /opt/soft/zookeeper2/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper2/bin/../conf/zoo.cfg
Mode: leader
[root@192 ~]# /opt/soft/zookeeper3/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper3/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@192 ~]# /opt/soft/zookeeper3/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper3/bin/../conf/zoo.cfg
Mode: follower
[root@192 ~]#
停止
[root@192 ~]# /opt/soft/zookeeper1/bin/zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper1/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[root@192 ~]# /opt/soft/zookeeper2/bin/zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper2/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[root@192 ~]# /opt/soft/zookeeper3/bin/zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper3/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[root@192 ~]# ps -ef|grep zookeeper
root 4068 3406 0 15:46 pts/0 00:00:00 grep zookeeper
[root@192 ~]#
查看状态
[root@192 ~]# ps -ef|grep zookeeper
root 3649 1 0 15:07 pts/0 00:00:02 /usr/java/jdk1.8.0_202-amd64/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /opt/soft/zookeeper1/bin/../build/classes:/opt/soft/zookeeper1/bin/../build/lib/*.jar:/opt/soft/zookeeper1/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/soft/zookeeper1/bin/../lib/slf4j-api-1.7.25.jar:/opt/soft/zookeeper1/bin/../lib/netty-3.10.6.Final.jar:/opt/soft/zookeeper1/bin/../lib/log4j-1.2.17.jar:/opt/soft/zookeeper1/bin/../lib/jline-0.9.94.jar:/opt/soft/zookeeper1/bin/../lib/audience-annotations-0.5.0.jar:/opt/soft/zookeeper1/bin/../zookeeper-3.4.13.jar:/opt/soft/zookeeper1/bin/../src/java/lib/*.jar:/opt/soft/zookeeper1/bin/../conf:.:/usr/java/jdk1.8.0_202-amd64/jre/lib/rt.jar:/usr/java/jdk1.8.0_202-amd64/lib/dt.jar:/usr/java/jdk1.8.0_202-amd64/lib/tools.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /opt/soft/zookeeper1/bin/../conf/zoo.cfg
root 3725 1 0 15:07 pts/0 00:00:04 /usr/java/jdk1.8.0_202-amd64/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /opt/soft/zookeeper2/bin/../build/classes:/opt/soft/zookeeper2/bin/../build/lib/*.jar:/opt/soft/zookeeper2/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/soft/zookeeper2/bin/../lib/slf4j-api-1.7.25.jar:/opt/soft/zookeeper2/bin/../lib/netty-3.10.6.Final.jar:/opt/soft/zookeeper2/bin/../lib/log4j-1.2.17.jar:/opt/soft/zookeeper2/bin/../lib/jline-0.9.94.jar:/opt/soft/zookeeper2/bin/../lib/audience-annotations-0.5.0.jar:/opt/soft/zookeeper2/bin/../zookeeper-3.4.13.jar:/opt/soft/zookeeper2/bin/../src/java/lib/*.jar:/opt/soft/zookeeper2/bin/../conf:.:/usr/java/jdk1.8.0_202-amd64/jre/lib/rt.jar:/usr/java/jdk1.8.0_202-amd64/lib/dt.jar:/usr/java/jdk1.8.0_202-amd64/lib/tools.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /opt/soft/zookeeper2/bin/../conf/zoo.cfg
root 3777 1 0 15:07 pts/0 00:00:02 /usr/java/jdk1.8.0_202-amd64/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /opt/soft/zookeeper3/bin/../build/classes:/opt/soft/zookeeper3/bin/../build/lib/*.jar:/opt/soft/zookeeper3/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/soft/zookeeper3/bin/../lib/slf4j-api-1.7.25.jar:/opt/soft/zookeeper3/bin/../lib/netty-3.10.6.Final.jar:/opt/soft/zookeeper3/bin/../lib/log4j-1.2.17.jar:/opt/soft/zookeeper3/bin/../lib/jline-0.9.94.jar:/opt/soft/zookeeper3/bin/../lib/audience-annotations-0.5.0.jar:/opt/soft/zookeeper3/bin/../zookeeper-3.4.13.jar:/opt/soft/zookeeper3/bin/../src/java/lib/*.jar:/opt/soft/zookeeper3/bin/../conf:.:/usr/java/jdk1.8.0_202-amd64/jre/lib/rt.jar:/usr/java/jdk1.8.0_202-amd64/lib/dt.jar:/usr/java/jdk1.8.0_202-amd64/lib/tools.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /opt/soft/zookeeper3/bin/../conf/zoo.cfg
root 3995 3406 0 15:45 pts/0 00:00:00 grep zookeeper
zookeeper伪集群的更多相关文章
- (原) 1.2 Zookeeper伪集群安装
本文为原创文章,转载请注明出处,谢谢 Zookeeper伪集群安装 zookeeper单机安装配置可以查看 1.1 zookeeper单机安装 1.复制三份zookeeper,分别为zookeeper ...
- win10环境下搭建zookeeper伪集群
一.下载zookeeper https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/ 这里笔者下载的是zookeeper-3.3.6 二.配置zoo ...
- 分享知识-快乐自己:zookeeper 伪集群搭建
1):单一 zookeeper 搭建步骤 2):zookeeper 伪集群搭建 1):新建一个集群目录 [root@zoodubbo opt]# mkdir zookeeper_cluster 2) ...
- ZooKeeper伪集群环境搭建
1.从官网下载程序包. 2.解压. [dev@localhost software]$ tar xzvf zookeeper-3.4.6.tar.gz 3.进入zookeeper文件夹后创建data文 ...
- CentOS6.3搭建ZooKeeper伪集群
1. 将zookeeper安装包移动至/home, 解压后改名为zookeeper 相关命令 # 解压 .tar.gz # 重命名 zookeeper 2. 进入zookeeper/conf/目录下, ...
- zookeeper伪集群搭建
zookeeper伪集群搭建 1. 下载zookeeper: https://zookeeper.apache.org/ 2. 解压: tar -zxvf zookeeper-3.4.14.tar.g ...
- windows下zookeeper伪集群搭建
下载 http://www.apache.org/dyn/closer.cgi/zookeeper/ 解压 D:\Java\soft\zookeeper-3.4.6 伪集群 1.在 \zookeepe ...
- zookeeper 伪集群模式
问题二:开发没有足够机器,一台机子上是否装三个zookeeper服务器集群. 问题解答: 这种安装模式只能说是一种伪集群模式.三个zookeeper服务器都安装在同一个服务器(platform)上,需 ...
- [dubbo实战] dubbo+zookeeper伪集群搭建
zookeeper作为注册中心,服务器和客户端都要访问,如果有大量的并发,肯定会有等待.所以可以通过zookeeper集群解决. 一.为什么需要zookeeper呢? 大部分分布式应用需要一个主控.协 ...
- dubbo+zookeeper伪集群配置
zookeeper作为注册中心,服务器和客户端都要访问,如果有大量的并发,肯定会有等待.所以可以通过zookeeper集群解决. 一.为什么需要zookeeper呢? 大部分分布式应用需要一个主控.协 ...
随机推荐
- web项目jsp中无法引入js问题
https://blog.csdn.net/C1042135353/article/details/80274685#commentBox 这篇文章超赞的,几个小时的时间看了这篇文章豁然开朗,瞬间懂了 ...
- jmeter之beanshell使用
beanshell官网:http://www.BeanShell.org/ 一.beanshell介绍 是一种完全符合Java语法规范的轻量级的脚本语言: 相当于一个小巧免费嵌入式的Java源代码解释 ...
- html中video标签
video标签: <video src="视频的后缀名是.webM/.ogg/.mp4 "></video>属性: src:用于告诉video标签需要播放的 ...
- Example With JdbcDaoSupport
By extended the JdbcDaoSupport, set the datasource and JdbcTemplate in your class is no longer requi ...
- C#中的变量祥解
一.C#数据类型: A:值类型 值类型变量可以直接分配一个值,它是从System.ValueType派生而来,值类型直接包含数据,比如int,char,float,他们分别存储整型数据,字符,浮点数, ...
- 读书分享全网学习资源大合集,推荐Python3标准库等五本书「02」
0.前言 在此之前,我已经为准备学习python的小白同学们准备了轻量级但超无敌的python开发利器之visio studio code使用入门系列.详见 1.PYTHON开发利器之VS Code使 ...
- C# Memcache集群原理、客户端配置详细解析
概述 memcache是一套开放源的分布式高速缓存系统.由服务端和客户端组成,以守护程序(监听)方式运行于一个或多个服务器中,随时会接收客户端的连接和操作.memcache主要把数据对象缓存到内存中, ...
- net core WebApi——尝试企业微信内部应用
目录 前言 企业微信 开始 测试 小结 @ 前言 这几天忙活着别的东西,耽误了很长时间,从文件操作完了之后就在考虑着下一步鼓捣点儿啥,因为最开始的业务开发就是企业微信相关的,这刚好来做个内部应用的小例 ...
- 欧几里得(Euclid)与拓展的欧几里得算法
欧几里得(Euclid)与拓展的欧几里得算法 欧几里得(Euclid)与拓展的欧几里得算法 欧几里得算法 原理 实现 拓展的欧几里得算法 原理 递归求解 迭代求解 欧几里得算法 原理 欧几里得算法是一 ...
- CentOS7下使用SonatypeNexus3搭建Docker私有仓库
前置条件:安装docker(如果机器上没有安装的话) //安装一些必要的系统工具: sudo yum install -y yum-utils device-mapper-persistent-dat ...