【第1章】Linux下Zookeeper3.4.11步骤安装与配置文件解读

mac2023-02-02  14

一、官网下载安装包,我的安装版本zookeeper-3.4.11.tar.gz

https://zookeeper.apache.org/releases.html#download

二、拷贝至/software目录下并解压

software是我自定义的文件夹

rz //上传本地磁盘上文件 压缩的zookeeper文件 tar -zxvf zookeeper-3.4.11.tar.gz //解压文件

三、新建自定义zookeeper目录,将解压zookeeper内容拷贝/myzookeeper目录内

mkdir myzookeeper; //新建文件夹myzookeeper

cp -r zookeeper-3.4.11 /usr/local/myzookeeper/ //递归【拷贝】解压文件至新的目录中

验证自定义myzookeeper目录下文件

四、进入conf文件夹,拷贝zoo_sample.cfg改为zoo.cfg

五、zoo.cfg配置文件解读

# The number of milliseconds of each tick tickTime=2000 //zookeeper服务器心跳时间,单位毫秒(2s) # The number of ticks that the initial # synchronization phase can take initLimit=10 //Leader允许初始化连接是最长能忍受多少个心跳的时间间隔数 总时间长度10*2000=20s # The number of ticks that can pass between # sending a request and getting an acknowledgement //响应超过syncLimit * tickTime=5*2000=10s,Leader认为Follwer死掉,从服务器列表中删除Follwer syncLimit=5 //同步通信时限(集群中Leader与Follower之间的最大响应时间单位) # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/tmp/zookeeper //数据文件目录+数据持久化路径,保存内存数据库快照信息的位置 # the port at which the clients will connect clientPort=2181 //客户端访问端口号2181,即服务端启动的端口号 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # 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.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1

六、开启服务+客户端连接(CentOS7.0系统)

开启服务

注意启动zookeeper服务之前需要安装好java环境!

echo $JAVA_HOME //检验JAVA环境 cd /usr/local/myzookeeper/zookeeper-3.4.11/bin //切换到bin目录 ./zkServer.sh start //启动zookeeper ps -ef|grep zookeeper //方式一:检验zookeeper服务是否启动

netstat -anp|grep 2181 //方式二:检验zookeeper服务是否启动

echo ruok|nc 127.0.0.1 2181//方式三:检验zookeeper服务是否启动 【ruok-四字命令!!!!】

如果nc命令没有安装,则需要安装!

(1)CentOS6.8下面nc命令的安装

/media/CentOS_6.8_Final/Packages // 路径 rpm -ivh nc-1.84-24.el6.x86_64.rpm // 命令

(2)CentOS7下面nc命令的安装

/run/media/root/CentOS 7 x86_64/Packages //路径 rpm -ivh nmap-ncat-6.40-7.el7.x86_64//命令

关闭服务

启动客户端


 ☝上述分享来源个人总结,如果分享对您有帮忙,希望您积极转载;如果您有不同的见解,希望您积极留言,让我们一起探讨,您的鼓励将是我前进道路上一份助力,非常感谢!我会不定时更新相关技术动态,同时我也会不断完善自己,提升技术,希望与君同成长同进步!

☞本人博客:https://coding0110lin.blog.csdn.net/  欢迎转载,一起技术交流吧!

最新回复(0)