前端做网站需要学什么,qq的seo综合查询,安全的小网站,网站建设淄博佳铉网络0、环境
java#xff1a;1.8zookeeper#xff1a;3.5.6
1、下载
zookeeper下载点击这里。
2、安装
下载完成后解压#xff0c;放到你想放的目录里。先看一下zookeeper的目录结构#xff0c;如下图#xff1a; 进入conf目录#xff0c;复制zoo_sample.cfg#xff0…0、环境
java1.8zookeeper3.5.6
1、下载
zookeeper下载点击这里。
2、安装
下载完成后解压放到你想放的目录里。先看一下zookeeper的目录结构如下图 进入conf目录复制zoo_sample.cfg并重新命名zoo.cfg。我们来看一下zoo.cfg的内容
# The number of milliseconds of each tick
tickTime2000
# The number of ticks that the initial
# synchronization phase can take
initLimit10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir/Users/jackie/zkdata
#dataLogDir/Users/jackie/dev/zookeeper-3.5.6/tmp/logs
# the port at which the clients will connect
clientPort2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns60
#
# 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.snapRetainCount3
# Purge task interval in hours
# Set to 0 to disable auto purge feature
#autopurge.purgeInterval1
能看到大部分都是注释我们在这里关注两个参数
dataDir这个参数是数据保存的目录改成你想要放的目录。clientPort: 这是客户端连接的端口保证没被占用即可。
3、启动
./zkServer.sh start我使用的是mac如果是Windows机器使用.cmd文件启动。启动成功后控制台如下图 大家注意命令后有个start指令zookeeper还有其他参数供使用我列出常用的
start启动zookeeper服务。stop停止zookeeper服务。status获取zookeeper服务运行的状态。restart重启服务。start-foreground: 前台启动服务
我们一起看一下status参数的效果 Ok 单机的zookeeper就搭建完成了。
4、zookeeper集群搭建
我们利用单台电脑搭建一个伪集群。这个集群总共包含三个节点。下来我们先搭建第一个。
4.1、修改 zoo.cfg文件 从图中的红框可以看到总共有三处需要更改
dataDir: 每一个节点需要有不同的数据目录clientPort每个节点需要不同的端口server.X: X代表节点的id。server. id ip : port1 : port2。port1是leader与follower心跳检测与数据同步的端口。port2是leader选举过程中用于投票的端口。在同一台机器上都需要保持不同。admin.serverPort: zk管理端服务端口可以通过http://localhost:8081/commands访问到。
4.2、创建myid文件
找到1节点的数据目录创建myid文件输入内容“1”。如果你的节点id不是1写你自己的id。 注意这个id取值范围在1~255必须是整数别乱写。
4.3、测试
按照步骤1和2分别对3个节点配置。配置完成后挨个启动zk服务。 第三个节点就不看了看到上面的Mode了吗节点2现在是Leader。 好了今天就到这了啦。