ZooKeeper教程(一)----Centos7下安装ZooKeeper(单机版)
1、下载源码
官网下载地址: http://mirrors.hust.edu.cn/apache/zookeeper/ 选择最新的版本进行下载

这里选择3.4.10进行下载:
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz

下载完成后执行以下命令进行解压:
tar -zxvf zookeeper-3.4.10.tar.gz
2、配置Zookeeper
解压之后,在zookeeper目录下创建以下目录:
- [fendo@localhost ~]$ cd zookeeper-3.4.10/
- [fendo@localhost zookeeper-3.4.10]$ mkdir data
- [fendo@localhost zookeeper-3.4.10]$ mkdir logs
将zookeeper-3.4.10/conf目录下的zoo_sample.cfg文件拷贝一份,命名为zoo.cfg
[fendo@localhost conf]$ cp zoo_sample.cfg zoo.cfg
然后修改zoo.cfg文件
vim zoo.cfg
修改成如下
- # 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=/home/fendo/zookeeper-3.4.10/data
- dataLogDir=/home/fendo/zookeeper-3.4.10/logs
- # 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
- server.1=192.168.84.130:2888:3888

其中:
2888端口号是zookeeper服务之间通信的端口。
3888是zookeeper与其他应用程序通信的端口。
然后在dataDir=/home/fendo/zookeeper-3.4.10/data下创建myid文件(编辑myid文件,并在对应的IP的机器上输入对应的编号。如在zookeeper上,myid 文件内容就是1。如果只在单点上进行安装配置,那么只有一个server.1)
vim myid
fendo用户下修改.bash_profile,增加zookeeper配置:
vim /home/fendo/.bash_profile
- # zookeeper env export
- ZOOKEEPER_HOME=/home/fendo/zookeeper-3.4.10 export
- PATH=$ZOOKEEPER_HOME/bin:$PATH

使配置文件生效
source /home/fendo/.bash_profile
关闭防火墙
切换到root用户下,执行以下命令:
systemctl stop firewalld.service
3、测试Zookeeper
启动并测试zookeeper(要用普通用户启动,不要用root):
- #使用fendo用户到/home/fendo/zookeeper-3.4.10/bin目录中执行
- ./zkServer.sh start
- #查看进程
- jps
- 其中,QuorumPeerMain是zookeeper进程,启动正常。
- #查看状态
- ./zkServer.sh status
- #服务器输出信息
- tail -500f zookeeper.out
- #停止zookeeper进程
- ./zkServer.sh stop
设置zookeeper服务开机启动
- # 切换到/etc/rc.d/init.d/目录下
- cd /etc/rc.d/init.d
- # 创建zookeeper文件
- touch zookeeper
- #更新权限
- chmod +x zookeeper
- #编辑文件,在zookeeper里面输入如下内容
- #!/bin/bash
- #chkconfig:2345 20 90
- #description:zookeeper
- #processname:zookeeper
- export JAVA_HOME=/user/local/java/jdk1.7.0_79
- export PATH=$JAVA_HOME/bin:$PATH
- case $1 in
- start)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh start;;
- stop)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh stop;;
- status)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh status;;
- restart)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh restart;;
- *) echo "require start|stop|status|restart" ;;
- esac

然后我们就可以用service zookeeper start/stop来启动停止zookeeper服务了
使用命令把zookeeper添加到开机启动里面
- chkconfig zookeeper on
- chkconfig --add zookeeper
添加完成之后接这个使用chkconfig --list 来看看我们添加的zookeeper是否在里面。

ZooKeeper教程(一)----Centos7下安装ZooKeeper(单机版)的更多相关文章
- centos7下安装zookeeper&zookeeper集群的搭建
一.centos7下安装zookeeper 1.zookeeper 下载地址 https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/ 2.安装步骤 ...
- Linux(Centos7)下安装 zookeeper docker版 集群
为了省去麻烦的软件安装,现在开发环境需要的软件越来越习惯于docker安装了,先看下安装后的截图,开发环境正在启动的容器 1.首先系统需要先支持docker …… 由于之前安装几次都没有做流程记录,在 ...
- Centos7下安装ZooKeeper
1.下载源码 zookeeper 需要jdk的支持,需要先安装jdk 官网下载地址: http://mirrors.hust.edu.cn/apache/zookeeper/ 选择最新的版本进行下载 ...
- centos7上安装zookeeper
centos7上安装zookeeper 1 准备工作 1.准备服务器,本次安装采用 centos7系统.内存2G.存储60G的虚拟机服务器一台: 2.服务器安装java环境: 参考文章<cent ...
- Windows下安装ZooKeeper
Windows下安装ZooKeeper 一.简介 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组 ...
- Linux下安装Zookeeper
Zookeeper是一个协调服务,可以用它来作为配置维护.名字服务.分布式部署: 下面,我来分享一下在Linux下安装Zookeeper的整个步骤,让大家少走弯路. 一.Zookeeper下载 [ro ...
- 如何在Centos7上安装zookeeper 多实例
一.如何在Centos7上安装zookeeper 多实例 cd /usr/local/src/ wget https://mirrors.tuna.tsinghua.edu.cn/apache/zoo ...
- Storm(1)-centos7下安装单机版Strom
1.所需软件: jdk8.zookeeper.storm 2.安装zookeeper单机版 下载:http://zookeeper.apache.org/releases.html#download ...
- Win10下安装zookeeper
Win10下安装zookeeper 注册中心zookeeper的安装 0.去Apache官网下载zookeeper http://zookeeper.apache.org/ 2.找到解压路径的conf ...
随机推荐
- i.mx6 Android6.0.1分析input子系统:测试
getevent与sendevent工具 Android系统提供了getevent与sendevent两个工具供开发者从设备节点中直接读取输入事件或写入输入事件. 在这里,我们测试音量加和音量减按键 ...
- Android组件--意图(Intent)
1. 隐示调用和显示调用 参考资料:http://blog.csdn.net/harvic880925/article/details/38399723 1.概念 1). 显式意图: 能从intent ...
- DateTime compare
DateTime t1 = new DateTime(100); DateTime t2 = new DateTime(20); if (DateTime.Compare(t1, t2) > 0 ...
- Rsyslog+ELK日志分析系统
转自:https://www.cnblogs.com/itworks/p/7272740.html Rsyslog+ELK日志分析系统搭建总结1.0(测试环境) 因为工作需求,最近在搭建日志分析系统, ...
- 注解完成spring json返回数据格式配置
import com.fasterxml.jackson.databind.ObjectMapper;import com.fasterxml.jackson.databind.module.Simp ...
- C# 批量 json 读取
// 方法一 //string test = "[{ 'CreateUser': 'CN=koujirou nishikawaOMHBK','CreateUserJ': '西川 公二郎'}, ...
- Bash on windows从14.0升级到ubuntu16.04
升级参考:https://www.zhihu.com/question/49411626 解决中文乱码问题参考:http://www.lofter.com/tag/ubuntu%E5%AD%90%E7 ...
- [LeetCode]Letter Combinations of a Phone Number题解
Letter Combinations of a Phone Number: Given a digit string, return all possible letter combinations ...
- 您只能在 HTML 输出流中使用 document.write,啥意思
JavaScript :写入到HTML输出语法 注意:只能在HTML输出中使用,如果在文档已经加载后使用(比如在函数中) 会覆盖到整个文档 <!DOCTYPE html> <htm ...
- 理解position:relative
前言:position有5个属性:static.absolute.relative.fixed和inherit.本篇博客主要介绍relative属性,因为似乎很多人对这个属性的理解很模糊,而且不清楚r ...