博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ubuntu18.04 搭建zookeeper单机版集群
阅读量:4352 次
发布时间:2019-06-07

本文共 1886 字,大约阅读时间需要 6 分钟。

一台电脑启动三个虚拟机比较折腾,这里就用一台虚拟机模拟一下zk集群。

1.后台下载安装包到 /opt目录

sudo wget -b http://archive.apache.org/dist/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz \-o /opt/archive/zookeeper.download.log -P /opt

解压、链接、配置环境变量

tar -zxf /opt/zookeeper-3.4.9.tar.gz -C /opt;ln -s /opt/zookeeper-3.4.9 /opt/zk;echo -e '\nZK_HOME=/opt/zk\nPATH=\$PATH:\$ZK_HOME\bin\n' >> /etc/profile;

2.创建数据及日志目录并修改权限

# 同时为创建3*2=6个目录sudo mkdir /data/{zk1,zk2,zk3}/{data,logs}# 修改权限为当前用户所有sudo chown -R $USER:$GROUPS /data/{zk1,zk2,zk3}

3.复制并修改配置文件

cp /opt/zk/conf/zoo_sample.cfg /data/zk1/zoo.cfg

4.配置文件

# 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 acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.# 存储快照的目录,不要使用/tmp目录dataDir=/data/zk1/datadataLogDir=/data/zk1/logs# the port at which the clients will connectclientPort=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# 心跳端口,数据端口;选举完成后,每个节点打开数据端口;只有主节点打开心跳端口,接受心跳数据# server.N 和 myid 是对应的server.1=bogon:2888:3888server.2=bogon:2889:3889server.3=bogon:2890:3890

  

5.批量操作脚本

for zk in {1,2,3}do    myid=/data/zk${zk}/data/myid    if [ ! -e "$myid" ];then        echo $zk > $myid    fi    zkServer.sh $1 /data/zk${zk}/zoo.cfgdone

转载于:https://www.cnblogs.com/zhengwenqiang/p/9004814.html

你可能感兴趣的文章
Python简介
查看>>
voa 2015 / 4 / 13
查看>>
搭建一个Flv视频播放服务器
查看>>
rownum和order by的执行顺序问题
查看>>
hive学习(三) hive的分区
查看>>
Android搜索自动提示功能 AutocompleteTextView
查看>>
PLSQL Developer 客户端没有TNS监听,无法连接数据库
查看>>
跨域iframe高度自适应(兼容IE/FF/OP/Chrome)
查看>>
第三次作业
查看>>
JS_高程3.基本概念(6)函数
查看>>
CentOS下配置防火墙 配置nat转发服务
查看>>
Django(二)
查看>>
Remove Duplicates from Sorted List II
查看>>
根据访问ip的地区跳转到指定地址
查看>>
List集合分页显示
查看>>
取石子。。。nyoj---23
查看>>
java POI读取excel 并保存在数据库中
查看>>
【Python】 字符串的相关小知识点
查看>>
Java注解基础概念总结
查看>>
实验2
查看>>