zookeeper安装和集群搭建
2014-12-30 12:20
405 查看
1:前期准备
官方文档地址:http://zookeeper.apache.org/doc/r3.4.6/zookeeperStarted.html下载:zookeeper-3.4.6.tar.gz
2:单台安转
1、配置zookeeper,解压zookeeper-3.4.6.tar.gz到D:\zookeeper-3.4.6,进入该目录下的conf中,里面包含zoo_sample.cfg和log4j.properties两个文件。修改zoo_sample.cfg为zoo.cfg。其中个字段的含义如下:
字段 | 含义 |
tickTime | Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔。 |
initLimit | Zookeeper 服务器集群中Follower 服务器初始化连接时最长能忍受的心跳时间间隔数。心跳时间超过该间隔数, 表明Follower 服务器连接Leader服务器失败。 |
syncLimit | Leader 与 Follower 之间发送消息时的最大请求/应答时间长度(以心跳数计算)。 |
dataDir | Zookeeper保存数据的目录。 |
dataLogDir | Zookeeper保存日志文件的目录,默认为dataDir。 |
clientPort | 这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。 |
# 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=D:/opt/zookeeper/zookeeper-3.4.6-1/data # 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
2、进入bin目录,执行zkServer.cmd启动zk。可通过netstat -ano查看配置的2181端口是否被监听。也可通过zkCli.cmd -server 127.0.0.1:2181来查看。
3:集群配置
1、本例通过伪集群模式,在一台机器上安装和配置多台zk实例。配置集群除了需要修改上述配置信息外,还需要新增以下配置项:server.1=localhost:1888:1889 server.2=localhost:2888:2889 server.3=localhost:3888:3889server.A=B:C:D:其中 A 是一个数字,表示这个是第几号服务器;B 是这个服务器的 ip 地址;C 表示的是这个服务器与集群中的 Leader 服务器交换信息的端口;D 表示的是万一集群中的 Leader 服务器挂了,需要一个端口来重新进行选举,选出一个新的 Leader,而这个端口就是用来执行选举时服务器相互通信的端口。如果是伪集群的配置方式,由于 B 都是一样,所以不同的 Zookeeper
实例通信端口号不能一样,所以要给它们分配不同的端口号。
2、除了修改 zoo.cfg 配置文件,集群模式下还要配置一个文件 myid,这个文件在 dataDir 目录下,这个文件里面就有一个数据就是 A 的值,Zookeeper 启动时会读取这个文件,拿到里面的数据与 zoo.cfg 里面的配置信息比较从而判断到底是那个 server。
实例:
# 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=D:/****/zookeeper/zookeeper-3.4.6-1/data # 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 server.1=localhost:1888:1889 server.2=localhost:2888:2889 server.3=localhost:3888:38893、执行所有zookeeper根目录下bin/zkServer.cmd
相关文章推荐
- 搭建分布式架构5--ZooKeeper 集群的安装 3ff0
- ZooKeeper此例简单介绍基于docker的zookeeper安装与集群搭建
- HBase 分布式安装搭建/独立Zookeeper集群
- Zookeeper安装以及集群搭建
- zookeeper安装,配置,搭建集群
- 搭建3个节点的hadoop集群(完全分布式部署)--3 zookeeper与hbase安装
- zookeeper集群安装搭建详解
- Zookeeper的安装部署,zookeeper参数配置说明,集群搭建,查看集群状态
- 搭建JEESZ分布式架构6--ZooKeeper 集群的安装
- 搭建分布式架构6--ZooKeeper 集群的安装
- Zookeeper集群的安装搭建
- hadoop集群搭建之三(Hbase、zookeeper安装)
- ZooKeeper此例简单介绍基于docker的zookeeper安装与集群搭建
- 搭建JEESZ分布式架构6--ZooKeeper 集群的安装
- Nginx+Keepalived+Tomcat高可用负载均衡,Zookeeper集群配置,Mysql(MariaDB)搭建,Redis安装,FTP配置
- Zookeeper安装使用以及linux上的分布集群搭建
- Zookeeper 的安装以及集群搭建
- Zookeeper系列(二)安装配置与集群搭建
- 搭建分布式架构6--ZooKeeper 集群的安装
- hadoop集群环境搭建之zookeeper集群的安装部署