博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZooKeeper安装
阅读量:7064 次
发布时间:2019-06-28

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

ZooKeeper是一种分布式协调服务,用于管理大型主机。在分布式环境中协调和管理服务是一个复杂的过程,ZooKeeper通过其简单的架构和API解决了这个问题。 它是Hadoop和Hbase的重要组件,同时还能使用Java和C的接口。

ZooKeeper典型的应用程序:Apache Hadoop、Apache HBase、Apache Solr

1. 下载ZoopKeeper

使用的版本是 zookeeper-3.4.11.tar.gz

官网:
清华大学镜像节点:

windows下载解压就可以了

Linux安装:

$ wget http://www-eu.apache.org/dist/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz # 下载zookeeper软件压缩包$ tar -zxvf zookeeper-3.4.11.tar.gz # 解压zookper压缩包

2. 修改配置文件

复制 confzoo_sample.cfg 文件,并改名为 zoo.cfg(zookeeper默认使用zoo.cfg配置文件)。主要修改 dataDir、 dataLogDir 两个参数

# The number of milliseconds of each tick# 每次心跳的间隔时间,单位是毫秒# ZK中所有时间都是以这个时间单元为基础,进行整数倍配置的。例如,session的最小超时时间是2*tickTime。tickTime=2000# The number of ticks that the initial synchronization phase can take# Follower在启动过程中,会从Leader同步所有最新数据,然后确定自己能够对外服务的起始状态。Leader允许F在 initLimit 时间内完成这个工作。initLimit=10# The number of ticks that can pass between sending a request and getting an acknowledgement# 在运行过程中,Leader负责与ZK集群中所有机器进行通信,例如通过一些心跳检测机制,来检测机器的存活状态syncLimit=5# the directory where the snapshot is stored. do not use /tmp for storage, /tmp here is just example sakes. # 存储快照文件snapshot的目录。默认情况下,事务日志也会存储在这里。建议同时配置参数dataLogDir, 事务日志的写性能直接影响zk性能。dataDir=D:/dubbo/zookeeper/data# 事务日志输出目录。尽量给事务日志的输出配置单独的磁盘或是挂载点,这将极大的提升ZK性能。dataLogDir=D:/dubbo/zookeeper/dataLog  # the port at which the clients will connect # 客户端连接server的端口,即对外服务端口,一般设置为2181吧。clientPort=2181# the maximum number of client connections.# increase this if you need to handle more clients# 单个客户端与单台服务器之间的连接数的限制,是ip级别的,默认是60,如果设置为0,那么表明不作任何限制。#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

3. 启动ZooKeeper服务

```# windows:./bin/zkServer.cmd  # 启动ZooKeeper服务./bin/zkCli.cmd 127.0.0.1:2181 # 测试连接是否正常./bin/zkCli.sh # 打开ZooKeeper命令行界面(CLI),之后可以对 znode 节点进行操作netstat -aon|findstr "2181" # 查看ZooKeeper端口监听情况# Linux:$ ./bin/zkServer.sh start # 启动ZooKeeper服务器,会有一个QuorumPeerMain进程$ ./bin/zkServer.sh stop  # 停止zookeeper服务器$ ./bin/zkCli.sh 127.0.0.1:2181 # 测试连接是否正常$ ./bin/zkCli.sh # 打开ZooKeeper命令行界面(CLI),之后可以对 znode 节点进行操作$ netstat -anp | grep 2181 # 查看ZooKeeper端口监听情况```

转载地址:http://hbill.baihongyu.com/

你可能感兴趣的文章
android搜索框列表布局,流程及主要步骤思维导图
查看>>
一场惊天跨国跨时区作弊案,除了需要爆表智商,还需要啥?
查看>>
工程师笔记|浅析AI平台的架构设计
查看>>
开店仅1年,为何能在一天实现 “三销冠”
查看>>
人工智能火了,为啥医疗成为最先受益者?
查看>>
雷军带领小米老员工公园步行 称这些人是小米最宝贵财富
查看>>
滴滴公布自查进展:免去黄洁莉顺风车事业部总经理职务
查看>>
中国PPP管理库项目累计投资额13.2万亿元
查看>>
甘肃崆峒古镇“文化赶集”:非遗“上台”贺新春
查看>>
俄罗斯食品来中国“过年”
查看>>
市场监管总局:保健食品应标注不具疾病预防治疗功能
查看>>
GitHub 上开源的区块链项目 90% 死亡了
查看>>
澳网张帅首夺大满贯 女双携斯托瑟挑落卫冕冠军
查看>>
“平潭-高雄”货运直航开通 三大优势凸显
查看>>
“共度欢乐春节”摄影图片展在阿斯塔纳开幕
查看>>
新光大ArtPark9亮相 以“艺术”再造生活方式
查看>>
关于Python数据分析,这里有一条高效的学习路径
查看>>
三亚:严查“先登记支付房款、后补交社保或个税”行为
查看>>
神级程序猿用HTML5代码画出恐龙求欢图,想象力太丰富!
查看>>
谋势、聚力、强生态,用友三十而立
查看>>