当前位置:首页 > linux > 正文内容

zookeeper安装

root5年前 (2021-12-13)linux1460

Zookeeper 是一个分布式应用程序协调服务,主要用来写到分布式服务的上下线,主从问题,选举主节点等。

下载新版 zookeeper:apache-zookeeper-3.7.0-bin

1、解压后修改配置文件,进入 conf 目录,将 zoo_sample.cfg 复制为 zoo.cfg 后,修改配置内容:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/home/jqy/apps/apache-zookeeper-3.7.0-bin/zkdata
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
server.1=192.168.56.106:2888:3888
server.2=192.168.56.107:2888:3888
server.3=192.168.56.108:2888:3888

192.168.56.106 ip 以实际ip为准

dataDir 以实际的存储为准


2、在dataDir路径下创建myid文件

myid 文件内写入节点编号,192.168.56.106 机器写入 1, 192.168.56.107 机器写入 2, 192.168.56.108 机器写入 3.


3、启动 zookeeper。三台机器都配置完成后,分别在每台机器的 apache-zookeeper-3.7.0-bin 目录下执行 ./bin/zkServer.sh start,然会使用 ./bin/zkServer.sh status 查看是否启动成功


zookeeper有三个端口

2181、3888、2888

2181:对cline端提供服务

3888:选举leader使用

2888:集群内机器通讯使用(Leader监听此端口)

集群为大于等于3个基数,如 3、5、7....,不宜太多,集群机器多了选举和数据同步耗时时长长,不稳定。目前觉得,三台选举+N台observe很不错

扫描二维码推送至手机访问。

版权声明:本文由一叶知秋发布,如需转载请注明出处。

本文链接:https://www.zhiqiu.top/?id=177

分享给朋友:

相关文章

linux 安装某些C源码程序,出现的依赖问题

configure:error:no acceptable C compiler found in $PATH这里提示是缺少C的编译器这个时候需要安装C的编译器但是我冬日大神告诉我还要点别的省的出问题。执行下面搞定:apt ins...

supervisor的安装使用

一、supervisor简介Supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启。它是通过fork/exec的方式把这些被管理的进程当作supe...

设置linux时间自动同步世界标准时间

因为主机时间没有自动同步有9.8s的误差。导致了出现负时间的问题首先手动校准时间ntpdate cn.pool.ntp.org开启时间自动更新服务systemctl start ntpd查看服务状态systemctl status ntpd...

shell获取当前文件路径

curPath=$(readlink -f "$(dirname "$0")") echo $curPath    #或者 curPath=$(dirname $(readli...

Python2 的Popen在docker中执行会挂起主进程

python2.7因业务需求。要把程序放入到docker容器中但是在docker执行的时候程序出现异常缓慢的情况检查函数执行情况发现当第一个线程执行到popen的时候会导致所有线程的挂起p1 = subprocess.P...

git 忽略文件不起作用 .gitignore

git rm -r --cached . git add .   git commit -m "update .gitignore"  git status查看是否是"working di...