ZooKeeper介绍与环境搭建
ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。由于ZooKeeper的开源特性,后来我们的开发者在分布式锁的基础上,摸索了出了其他的使用方法:配置维护、组服务、分布式消息队列、分布式通知/协调等。
ZooKeeper是可以集群复制的,通过Zab(Zookeeper Atomic Broadcast)协议保持数据一致性,协议主要包括两个阶段:leader selection和Atomic broadcast。集群中有一个leader,通过broadcast更新其余的follower。当leader崩溃或者失去多数follower,则leader会面临重选。
1. 进入到/usr目录,wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
[root@Server1 Downloads]# cd /usr
[root@Server1 usr]# ls
bin etc games include lib lib64 libexec local sbin share src tmp
[root@Server1 usr]# wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
---- ::-- http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
Resolving mirror.bit.edu.cn (mirror.bit.edu.cn)... 202.204.80.77, :da8::::56ff:fea1:
Connecting to mirror.bit.edu.cn (mirror.bit.edu.cn)|202.204.80.77|:... connected.
HTTP request sent, awaiting response... OK
Length: (33M) [application/octet-stream]
Saving to: ‘zookeeper-3.4..tar.gz’ % [====================> ] ,, 494KB/s eta 42s
2.解压缩下载的文件,并重命名为zookeeper文件夹
[root@Server1 usr]# tar -xvf zookeeper-3.4..tar.gz
[root@Server1 usr]# mv zookeeper-3.4. zookeeper
3.修改环境变量,vi /etc/profile,在文件尾部追加如下
export ZOOKEEPER_HOME=/usr/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
4.创建zookeeper配置文件
[root@Server1 zookeeper]# cd conf/
[root@Server1 conf]# ls
configuration.xsl log4j.properties zoo_sample.cfg
[root@Server1 conf]# cp zoo_sample.cfg zoo.cfg
5.配置zookeeper的数据目录和日志目录,把这两个目录存放在/tmp/zookeeper下面
[root@Server1 ~]# cd /tmp
[root@Server1 tmp]# ls
hogsuspend
systemd-private-3ff79a0765994743931501169ad962cf-cups.service-uQcMzj
systemd-private-3ff79a0765994743931501169ad962cf-vmtoolsd.service-aovBEQ
[root@Server1 tmp]# mkdir zookeeper
[root@Server1 tmp]# cd zookeeper/
[root@Server1 zookeeper]# mkdir log
[root@Server1 zookeeper]# mkdir data
[root@Server1 zookeeper]# ls
data log
6.配置zoo.cfg文件如下
# The number of milliseconds of each tick
tickTime=
# The number of ticks that the initial
# synchronization phase can take
initLimit=
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/tmp/zookeeper/data
dataLogDir=/tmp/zookeeper/log
# the port at which the clients will connect
clientPort=
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=
#
# 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=
# Purge task interval in hours
# Set to "" to disable auto purge feature
#autopurge.purgeInterval=
7.启动zookeeper,进入到/usr/zookeeper/bin目录
[root@Server1 bin]# pwd
/usr/zookeeper/bin
[root@Server1 bin]# ls
README.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh
[root@Server1 bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
ZooKeeper介绍与环境搭建的更多相关文章
- zookeeper集群环境搭建详细图文教程
zookeeper集群环境搭建详细图文教程 zhoubang @ 2018-01-02 [文档大纲] 友情介绍 软件环境 注意点 环境安装 1. 新建用于存储安装包以及软件安装的目录 2. 下载安装z ...
- Python介绍及环境搭建
摘自http://www.cnblogs.com/sanzangTst/p/7278337.html Python零基础学习系列之二--Python介绍及环境搭建 1-1.Python简介: Py ...
- [转]ZooKeeper 集群环境搭建 (本机3个节点)
ZooKeeper 集群环境搭建 (本机3个节点) 是一个简单的分布式同步数据库(或者是小文件系统) ------------------------------------------------- ...
- Django 01 django基本介绍及环境搭建
Django 01 django基本介绍及环境搭建 #http服务器 #用来接收用户请求,并将请求转发给web应用框架进行处理 #Web应用框架 #处理完请求后在发送给http服务器,http服务器在 ...
- Linux环境下ZooKeeper集群环境搭建关键步骤
ZooKeeper版本:zookeeper-3.4.9 ZooKeeper节点:3个节点 以下为Linux环境下ZooKeeper集群环境搭建关键步骤: 前提条件:已完成在Linux环境中安装JDK并 ...
- [springboot 开发单体web shop] 1. 前言介绍和环境搭建
前言介绍和环境搭建 简述 springboot 本身是为了做服务化用的,我们为什么要反其道使用它来开发一份单体web应用呢? 在我们现实的开发工作中,还有大量的业务系统使用的是单体应用,特别是对于中小 ...
- App自动化测试-1.App自动化介绍和环境搭建
App自动化测试-1.App自动化介绍和环境搭建 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-b ...
- Maven介绍及环境搭建
Maven介绍及环境搭建 Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建.报告和文档的软件项目管理工具. 下载Maven boot:类加载器框架,Maven使用它加在自 ...
- Maven快速入门(一)Maven介绍及环境搭建
做开发的程序员都知道,在系统开发需要各自各样的框架.工具.其中有一种工具不管你是初级程序员还是高级程序员都必须熟练掌握的,那就是项目管理工具(maven.ant.gradle).接下来就总结Maven ...
随机推荐
- java.lang.RuntimeException Unable to instantiate application Caused by: java
参考:http://blog.csdn.net/xufazhong/article/details/71155528 dependencies { classpath 'com.android.too ...
- 深入理解JavaScript系列(44):设计模式之桥接模式
介绍 桥接模式(Bridge)将抽象部分与它的实现部分分离,使它们都可以独立地变化. 正文 桥接模式最常用在事件监控上,先看一段代码: addEvent(element, 'click', getBe ...
- node.js控制请求处理数量
问题: 现在有一个接口,这个接口用到了无头浏览器,总之是一个比较消耗内存的接口,并发上来后,这个接口会把服务器内存榨干,导致服务器宕机.现在在不加机器的情况下,并发上来后我该怎么做既能处理掉所有请求又 ...
- nodejs中cookie、session的使用
因为http会话的无状态性,为了标记用户的登录状态,便出现了cookie.cookie分为很多种,有普通cookie.签名cookie.json cookie等,这里主要记录下在express应用中如 ...
- Go.网络篇-2
package main import ( "io/ioutil" "os" "io" "log" "net/ ...
- ApplicationContextAware接口
在某些特殊的情况下,Bean需要实现某个功能,但该功能必须借助于Spring容器才能实现,此时就必须让该Bean先获取Spring容器,然后借助于Spring容器实现该功能.为了让Bean获取它所在的 ...
- Apache2.4+PHP7.3 安装及整合教程[Windows]
系统环境:Win10 64位 Apache版本:2.4.37 64位 PHP版本:7.3.1 64位 下载 安装的第一步肯定是下载了,可以直接到我的网盘(密码:18tp)下载,下载完成后将文件解压到你 ...
- MyBaits_查询缓存02_Ehcache二级缓存
一.Ehcache二级缓存的开启 导入jar(https://github.com/mybatis/ehcache-cache/releases) <cache type="org.m ...
- Storm Flow
A Stream represents the core data model in Trident, and can be thought of as a "stream" of ...
- qt 拷贝文件设置进度条
/** * @brief FuncModuleWin::copyFile * @param fromFIleName 优盘里面的文件 * @param toFileName 拷贝到/bin里面的启动文 ...