zookeeper 集群安装

准备

这里安装的是可生产用的 zookeeper 集群,非伪分布式集群。提前准备三台服务器。并且都已经安装 jdk 1.8。其 IP 映射如下:

192.168.56.101 worker-01        worker-01.joyxj.com
192.168.56.102 worker-02        worker-02.joyxj.com
192.168.56.103 worker-03        worker-03.joyxj.com

下载、解压和创建数据目录

wget http://mirror.bit.edu.cn/apache/zookeeper/stable/apache-zookeeper-3.5.5-bin.tar.gz
tar -zxvf apache-zookeeper-3.5.5-bin.tar.gz
mv apache-zookeeper-3.5.5-bin zzookeeper-3.5.5
mkdir -p /var/lib/zookeeper

三台服务器上都需要执行操作。

配置

拷贝一份配置文件 zoo_sample.cfg,重命名为 zoo.cfg。配置以下内容:

# 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=/var/lib/zookeeper
# 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
#
# 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

# 配置集群信息,下面的worker-*也可以用 IP 替代。
server.1=worker-01:2888:3888
server.2=worker-02:2888:3888
server.3=worker-03:2888:3888

上述步骤三台服务器上均需要操作。

配置myid

这一步的操作每台服务器上不致。

  1. 在worker-01服务器上的操作:

     echo  "1" > /var/lib/zookeeper/myid
    
  2. 在worker-02服务器上的操作:

     echo  "2" > /var/lib/zookeeper/myid
    
  3. 在worker-03服务器上的操作:

     echo  "3" > /var/lib/zookeeper/myid
    

以上写入 /var/lib/zookeeper/myid 的值分别对应配置集群时的 server 后面的值。
比如:对于 worker-01 这台服务器,其配置的对应关系是 server.1=worker-01:2888:3888,所以写入/var/lib/zookeeper/myid 的值是 1

启动

执行命令 sh bin/zkServer.sh start 分别启动三台服务器。启动后可以用 sh bin/zkServer.sh status 查看服务器的状态。


   转载规则


《zookeeper 集群安装》 孤独如梦 采用 知识共享署名 4.0 国际许可协议 进行许可。
 上一篇
redis 快速安装及配置开机自启动 redis 快速安装及配置开机自启动
前言本文介绍单机 redis 的安装及配置开机自启动,操作系统为 Centos 7。 下载和解压缩下载最新的稳定版 ridis (5.0.5) , 下载地址:http://download.redis.io/releases/redis-5
2019-07-11
下一篇 
【Elasticsearch 系列】 Elasticsearch 基本概念 【Elasticsearch 系列】 Elasticsearch 基本概念
前言本文主要介绍 Elasticsearch 的几个基本概念,包括 Index: 索引 Type: 分类 Document: 文档 Node: 节点 Shard: 分片 文档文档特点 Elasticsearch 是面向文档的,文
2019-07-09
  目录