`

[转载]ZooKeeper集群部署管理详细版

 
阅读更多
1. 约定:
a. ZooKeeper Server,[server1]的ip为192.168.1.201,[server2]的ip为192.168.1.202,[server3]的ip为192.168.1.203。
b. [zk_dir]表示ZooKeeper的根目录,假设为/home/user/zookeeper
c. [zk_data]表示ZooKeeper数据文件存放地址,假设为/home/user/zk_data
d. [zk_trlog]表示ZooKeeper的Transaction Log目录,假设为/home/user/zk_trlog
e. [zk_logs]表示ZooKeeper的一半log目录,假设为/home/user/zk_logs
2. 服务端环境要求:
a. Linux或者其他类UNIX系统(Windows及Mac OS只能作为开发环境,不能做生产环境)
b. JDK 1.6或更高
c. Server管理需要netcat或者telnet
3. 获得ZooKeeper发行版:
访问:http://hadoop.apache.org/zookeeper/releases.html,目前ZooKeeper的最新版本为3.3.1版本(2010年5月17日发行)
4. 修改配置文件:
因为ZooKeeper的配置文件设计目标是可供所有机器使用的通用配置文件,因此可以现在一台机器上写完,然后复制到其他server上。在[zk_dir]/conf下新建zoo.cfg文件,详细参数说明参见附录,这里给出一个配置文件的例子:
# BASIC SETTINGS
 
# The number of milliseconds of each tick
tickTime=2000
 
# the port at which the clients will connect
clientPort=2181
 
# the directory where the snapshot is stored.
dataDir=/home/user/zk_logs/zk_data
 
# the directory where the transaction log is stored
dataLogDir=/home/user/zk_logs/zk_trog
 
# BASIC SETTINGS END
 
##########################################################
 
# CLUSTER SETTINGS
 
# 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
 
# CLUSTER SERVER CONFIG
server.1=192.168.1.201:2888:3888
server.2=192.168.1.202:2888:3888
server.3=192.168.1.203:2888:3888
 
# CLUSTER SETTINGS END
其中的# CLUSTER SERVER CONFIG部分为集群的三台机器的ip
5. 为每台服务器设置id:
在[server1]的[zk_data]目录下新建myid文件,纯文本ASCII编码文件即可,内容为1,也就是配置文件中server.x中的x的值。其他两台机器上依此类推,也新建内容为自己id的myid文件。
6. 配置log文件信息:
ZooKeeper采用log4j记录日志,log4j.properties文件在[zk_dir]/conf目录下,编辑[zk_dir]/conf/log4j.properties文件,按需要配置,这里给出一个在文件里记录DEBUG, INFO, ERROR等级,并且文件每天重命名一次的例子:
#
# ZooKeeper Logging Configuration
#
 
log4j.rootLogger=INFO, DEBUG, ERROR
 
# DEBUG
log4j.appender.DEBUG=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DEBUG.Threshold=DEBUG
log4j.appender.DEBUG.layout=org.apache.log4j.PatternLayout
log4j.appender.DEBUG.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n
log4j.appender.DEBUG.datePattern='.'yyyy-MM-dd'.log'
log4j.appender.DEBUG.append=true
log4j.appender.DEBUG.File=/home/user/zk_logs/zk_debug.log
 
# INFO
log4j.appender.INFO=org.apache.log4j.DailyRollingFileAppender
log4j.appender.INFO.Threshold=INFO
log4j.appender.INFO.layout=org.apache.log4j.PatternLayout
log4j.appender.INFO.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n
log4j.appender.INFO.datePattern='.'yyyy-MM-dd'.log'
log4j.appender.INFO.append=true
log4j.appender.INFO.File=/home/user/zk_logs/zk_error.log
 
# ERROR
log4j.appender.ERROR=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ERROR.Threshold=ERROR
log4j.appender.ERROR.layout=org.apache.log4j.PatternLayout
log4j.appender.ERROR.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n
log4j.appender.ERROR.datePattern='.'yyyy-MM-dd'.log'
log4j.appender.ERROR.append=true
log4j.appender.ERROR.File=/home/user/zk_logs/zk_error.log
7. Server简单管理命令:
现在可以启动ZooKeeper服务器了:
# Server启动命令
$ [zk_dir]/bin/zkServer.sh start
# Server重启
$ [zk_dir]/bin/zkServer.sh restart
# Server停止
$ [zk_dir]/bin/zkServer.sh stop
# Server基本状态查看,需要netcat
$ [zk_dir]/bin/zkServer.sh status
8. ZooKeeper的管理命令:
需要使用telnet或者netcat连接到ZooKeeper Server的clientPort端口,命令均为4个字母,命令及功能如下:
conf
3.3.0新增: 打印server配置文件内容
cons
3.3.0新增:列出连接到本Server的Client的完整连接及Session信息。包括分组发送/接收信息,session id,操作延时,最后一个操作的执行等
crst
3.3.0新增: 重置所有连接/session
dump
Lists the outstanding sessions and ephemeral nodes. 只在leader server上有效。
envi
屏幕打印server的环境变量
ruok
测试server是否处于无错状态。 如果状态健康则返回”imok”,否则无任何结果。
A response of “imok” does not necessarily indicate that the server has joined the quorum, just that the server process is active and bound to the specified client port. Use “stat” for details on state wrt quorum and client connection information.
srst
Reset server statistics.
srvr
3.3.0新增: Lists full details for the server.
stat
Lists brief details for the server and connected clients.
wchs
3.3.0新增: Lists brief information on watches for the server.
wchc
3.3.0新增: Lists detailed information on watches for the server, by session. This outputs a list of sessions(connections) with associated watches (paths). Note, depending on the number of watches this operation may be expensive (ie impact server performance), use it carefully.
wchp
3.3.0新增: Lists detailed information on watches for the server, by path. This outputs a list of paths (znodes) with associated sessions. Note, depending on the number of watches this operation may be expensive (ie impact server performance), use it carefully.
 
分享到:
评论

相关推荐

    Zookeeper集群部署3.5.5.docx

    以下是Zookeeper集群部署3.5.5的详细知识点: 一、前提条件 * 关闭防火墙,以确保集群的安全和可靠性。 二、安装和配置Zookeeper * 解压缩Zookeeper安装包,并创建数据文件和目录文件在Zookeeper的跟目录下。 * ...

    zookeeper集群部署文档.txt

    zookeeper是现在大数据领域不可或缺的组件,它用于Hadoop生态圈多个组件的HA配置,协调各个节点有序进行工作,在这里,我将一步一步教你搭建生产使用的zookeeper集群。

    Zookeeper集群搭建.doc

    需要三台机器安装zookeeper集群:安装JDK环境、安装部署zookeeper集群、启动zookeeper集群、修改配置

    zookeeper、kafka集群部署

    zookeeper配置、集群部署 kafka配置、集群部署 Window平台下

    搭建zookeeper集群

    搭建zookeeper集群的详细操作;搭建zookeeper集群的详细操作;

    zookeeper linux集群搭建流程

    zookeeper linux 搭建流程,zookeeper linux 搭建流程zookeeper linux 搭建流程zookeeper linux 搭建流程。

    zookeeper集群安装.doc

    在这个文档中,我们将详细介绍如何安装和配置Zookeeper集群。 1. 基础环境准备 在安装Zookeeper之前,需要准备三台服务器,每台服务器需要安装Java环境。我们将使用JDK 8u141 Linux x64版本,上传到三台服务器,...

    liunx安装zookeeper及集群部署

    该文档主要是描述了在liunx下如何搭建zookeeper以及zookeeper集群的部署方法,还有就是我们如何在dubbo分布式中如何配置的说明。亲测集群可用,并完全运用到我司项目的生产环境上,安全稳定,未出问题。

    快速部署单机zookeeper集群(win环境)

    本文不讲zookeeper集群原理,只谈部署步骤。 默认读者已对zookeeper有最基本的认知,纯粹作为部署笔记,方便回忆。 另外本文是基于Windows部署的,Linux的步骤是基本相同的(只是启动脚本位置不同)。

    linux下zookeeper集群环境搭建详细图文教程.docx

    linux下zookeeper集群环境搭建详细图文教程,简单易使用

    Linux下Zookeeper集群的安装

    Linux下Zookeeper集群的安装

    zookeeper-3.4.13集群一键部署工具

    一键部署工具实现功能如下: 1、支持单节点部署 2、支持伪集群部署 3、支持分布式集群部署 4、支持数据目录、端口参数灵活...说明:工具使用非常简单,只需要修改变量文件,一分钟就可以快速帮你部署zookeeper集群。

    zookeeper集群配置详解

    zookeeper集群配置详解 详细描述在linux集群环境中搭建zookeeper的步骤

    hadoop+hbase+zookeeper集群配置流程及文件

    hadoop集群配置流程以及用到的配置文件,hadoop2.8.4、hbase2.1.0、zookeeper3.4.12

    zookeeper集群搭建脚本

    此附件是快速搭建zookeeper集群的脚本,方便灵活,减少了自己一大堆复杂的操作,像运行服务一样执行几条start,stop等命令即可轻松完成集群搭建。

    zookeeper集群.rar

    Windows搭建zookeeper集群,解压即用。zookeeper的版本是3.5.5,自用非常方便。

    storma集群安装手册(包含zookeeper集群安装和storm集群安装)

    本文档包括storm集群部署的整体过程:JDK部署,zookeeper集群部署,storm集群部署

    Zookeeper单机部署和集群部署文档.pdf

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。 本文档为单机部署和集群部署,带详细目录。

    zookeeper集群模式部署.pdf

    zookeeper集群模式部署.pdf

Global site tag (gtag.js) - Google Analytics