下载zk

wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz

解压

tar -zxvf apache-zookeeper-3.7.0-bin.tar.gz

copy配置成3份

# 进入zk的conf目录
cd conf# copy1
cp zoo.cfg zoo1.cfg# copy2
cp zoo.cfg zoo2.cfg# copy3
cp zoo.cfg zoo3.cfg
zoo1.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=/usr/local/zk/zookeeper/data/zk1
dataLogDir=/usr/local/zk/zookeeper/log/log1
# the port at which the clients will connect#客户端连接 zk 服务器的端口,zk 监听这个端口,接受客户端请求
clientPort=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## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
quorumListenOnAllIPs=true
server.1=47.103.72.160:2887:3887
server.2=47.103.72.160:2888:3888
server.3=47.103.72.160:2889:3889
#server.a=b:c:d , a:表示第几号服务器,b:服务器的ip地址,
#c:集群中与 leader 交换信息的端口,d:当 leader 服务器挂了,通过这个端口来重新选举 leader
#因为是在同一台机器上搭建的伪集群,所有 c,d 都不能一样
zoo2.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=/usr/local/zk/zookeeper/data/zk2
dataLogDir=/usr/local/zk/zookeeper/log/log2
# the port at which the clients will connect
clientPort=2182
# 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## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
quorumListenOnAllIPs=true
server.1=47.103.72.160:2887:3887
server.2=47.103.72.160:2888:3888
server.3=47.103.72.160:2889:3889
zoo3.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=/usr/local/zk/zookeeper/data/zk3
dataLogDir=/usr/local/zk/zookeeper/log/log3
# the port at which the clients will connect
clientPort=2183
# 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## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
quorumListenOnAllIPs=true
server.1=47.103.72.160:2887:3887
server.2=47.103.72.160:2888:3888
server.3=47.103.72.160:2889:3889

修改clientPort属性 (客户端连接 zk 服务器的端口,zk 监听这个端口,接受客户端请求)

修改dataDir属性(数据保存地址)

修改dataLogDir属性(日志保存地址)

server.n (集群地址,n 是dataDir目录下的myid文件中内容,用来标记该服务器在集群中的地址)

日志路径创建3份

# 进入log
cd log# 创建zk1日志目录
mkdir log1# 创建zk2日志目录
mkdir log2# 创建zk3日志目录
mkdir log4

数据路径创建3份

# 进入data
cd data# 创建zk1保存数据目录
mkdir zk1
cd zk1
vim myid
输入:1
保存退出# 创建zk2保存数据目录
mkdir zk2
cd zk2
vim myid
输入:2
保存退出# 创建zk3保存数据目录
mkdir zk3
cd zk3
vim myid
输入:3
保存退出

zk命令

cd bin# 启动
sh zkServer.sh start zoo1.cfg
sh zkServer.sh start zoo2.cfg
sh zkServer.sh start zoo3.cfg# 状态
sh zkServer.sh status zoo1.cfg
sh zkServer.sh status zoo2.cfg
sh zkServer.sh status zoo3.cfg# 关闭
sh zkServer.sh stop zoo1.cfg
sh zkServer.sh stop zoo2.cfg
sh zkServer.sh stop zoo3.cfg

zookeeper同一台服务器创建伪集群相关推荐

  1. zookeeper的单实例和伪集群部署

    原文链接: http://gudaoyufu.com/?p=1395 zookeeper工作方式 ZooKeeper 是一个开源的分布式协调服务,由雅虎创建,是 Google Chubby 的开源实现 ...

  2. Zookeeper单例搭建与伪集群搭建

    Zookeeper单例搭建与伪集群搭建 搭建方式 单机安装 伪集群搭建 搭建方式 单机模式-- 运行在一台机器上 集群模式-- 运行在多个机器上形成"集合体" 伪集群模式-- 一台 ...

  3. RHEL下安装配置基于2台服务器的MYSQL集群

    一.介绍 ======== 这篇文档旨在介绍如何在RHEL下安装配置基于2台服务器的MySQL集群.并且实现任意一台服务器出现问题或宕机时MySQL依然能够继续运行. 注意! 虽然这是基于2台服务器的 ...

  4. 2台mysql集群_如何安装配置基于2台服务器的MySQL集群

    这篇文章旨在介绍如何安装配置基于2台服务器的MySQL集群.并且实现任意一台服务器出现问题或宕机时MySQL依然能够继续运行. 注意!虽然这是基于2台服务器的MySQL集群,但也必须有额外的第三台服务 ...

  5. zookeeper 在 windows 下配置伪集群环境

    安装启动zookeeper 在 Apache zookeeper 官网下载 https://www.apache.org/dyn/closer.cgi/zookeeper/ 下载后解压,我使用的是3. ...

  6. mysql集群2台linux_安装配置基于两台服务器的MySQL集群(2)

    以下为引用的内容: # mkdir /usr/src/mysql-mgm # cd /usr/src/mysql-mgm # tar -zxvf mysql-max-4.1.9-pc-linux-gn ...

  7. 多台服务器搭建Spark集群

    一.设备条件      * 阿里云服务器(Master)     1 * 本机(Slave)                  1 二.软件条件       jdk 1.8:https://www.o ...

  8. 单台服务器做redis集群

    本实验需要centos7一台 2核2g即可 下载redis包 wget http://download.redis.io/releases/redis-4.0.9.tar.gz 修改redis.con ...

  9. 腾讯云~kafka伪集群搭建

    文章目录 一.zookeeper伪集群搭建 1. 下载安装包 2. 解压安装包 3. 创建目录 4. 修改配置文件 5. 修改dataDir,clientPort两个配置项 5. 在data目录下创建 ...

最新文章

  1. 华为201万年薪招毕业生!来自这些高校
  2. 让SAP云平台上的Web应用使用destination服务
  3. python 如何判断一个函数执行完成_三步搞定 Python 中的文件操作
  4. 010.第一个回声服务器可能遇到的问题——connect函数
  5. pyhthon Opencv截取视频中的图片
  6. python把文件中的邮箱分类 保存到相应的文件里面
  7. Python:bs4的使用
  8. 实验四|Python 企业偿债能力分析
  9. No.11软件工程的过程管理
  10. Android 10.0 PackageManagerService(四)APK安装流程-[Android取经之路]
  11. g729源码分析-开篇
  12. 程序员最爱的11个在线社区,你去过几个?
  13. 网上流传“魔方文化启示录”
  14. uIP TCP Server 运行机制分析
  15. JPG图片在线翻译的操作方法
  16. 基于单片机的电流检测仿真设计(#0041)
  17. 运维如何学习、自我提升价值?
  18. Python中字符串转义字符的用法----退格符\b
  19. OpenCV/OpenCL/OpenGL区别
  20. 探索Kubernetes HPA

热门文章

  1. 下一次农业革命,微生物或为突破口
  2. TEE综述:植物—土壤反馈(PSF):自然和农业科学间的桥梁
  3. 过年了,少喝点酒,多喝点茶—绿茶不仅仅是你想的那么简单
  4. 你想要的宏基因组-微生物组知识全在这(190101)
  5. R语言使用R基础安装中的glm函数构建乳腺癌二分类预测逻辑回归模型、分类预测器(分类变量)被自动替换为一组虚拟编码变量、summary函数查看检查模型、使用table函数计算混淆矩阵评估分类模型性能
  6. R语言使用pROC包绘制ROC曲线实战:roc函数计算AUC值、plot.roc函数绘制ROC曲线、添加置信区间、为回归模型中的每个因子绘制ROC曲线并在同一个图中显示出来
  7. R语言NaN函数实战(计数、替换、删除)
  8. 机器学习类别/标称(categorical)数据处理:序号编码(Ordinal Encoding)
  9. 随机森林(Random Forest)和梯度提升树(GBDT)有什么区别?
  10. 基因组序列及注释数据下载