1、下载源码

zookeeper 需要jdk的支持,需要先安装jdk

官网下载地址: http://mirrors.hust.edu.cn/apache/zookeeper/ 选择最新的版本进行下载

这里选择3.4.10进行下载:

  1. wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz

下载完成后执行以下命令进行解压:

  1. tar -zxvf zookeeper-3.4.10.tar.gz

2、配置Zookeeper

 

解压之后,在zookeeper目录下创建以下目录:

  1. [fendo@localhost ~]$ cd zookeeper-3.4.10/
  2. [fendo@localhost zookeeper-3.4.10]$ mkdir data
  3. [fendo@localhost zookeeper-3.4.10]$ mkdir logs

将zookeeper-3.4.10/conf目录下的zoo_sample.cfg文件拷贝一份,命名为zoo.cfg

  1. [fendo@localhost conf]$ cp zoo_sample.cfg zoo.cfg

然后修改zoo.cfg文件

  1. vim zoo.cfg

修改成如下

  1. # The number of milliseconds of each tick
  2. tickTime=2000
  3. # The number of ticks that the initial
  4. # synchronization phase can take
  5. initLimit=10
  6. # The number of ticks that can pass between
  7. # sending a request and getting an acknowledgement
  8. syncLimit=5
  9. # the directory where the snapshot is stored.
  10. # do not use /tmp for storage, /tmp here is just
  11. # example sakes.
  12. dataDir=/home/fendo/zookeeper-3.4.10/data
  13. dataLogDir=/home/fendo/zookeeper-3.4.10/logs
  14. # the port at which the clients will connect
  15. clientPort=2181
  16. # the maximum number of client connections.
  17. # increase this if you need to handle more clients
  18. #maxClientCnxns=60
  19. 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)

  1. vim myid

fendo用户下修改.bash_profile,增加zookeeper配置:

  1. vim /home/fendo/.bash_profile
  1. # zookeeper env export
  2. ZOOKEEPER_HOME=/home/fendo/zookeeper-3.4.10 export
  3. PATH=$ZOOKEEPER_HOME/bin:$PATH

使配置文件生效

  1. source /home/fendo/.bash_profile

关闭防火墙

切换到root用户下,执行以下命令:

  1. systemctl stop firewalld.service

3、测试Zookeeper

 

启动并测试zookeeper(要用普通用户启动,不要用root):

  1. #使用fendo用户到/home/fendo/zookeeper-3.4.10/bin目录中执行
  2. ./zkServer.sh start
  3. #查看进程
  4. jps
  5. 其中,QuorumPeerMain是zookeeper进程,启动正常。
  6. #查看状态
  7. ./zkServer.sh status
  8. #服务器输出信息
  9. tail -500f zookeeper.out
  10. #停止zookeeper进程
  11. ./zkServer.sh stop

设置zookeeper服务开机启动

  1. # 切换到/etc/rc.d/init.d/目录下
  2. cd /etc/rc.d/init.d
  3. # 创建zookeeper文件
  4. touch zookeeper
  5. #更新权限
  6. chmod +x zookeeper
  7. #编辑文件,在zookeeper里面输入如下内容
  8. #!/bin/bash
  9. #chkconfig:2345 20 90
  10. #description:zookeeper
  11. #processname:zookeeper
  12. export JAVA_HOME=/user/local/java/jdk1.7.0_79
  13. export PATH=$JAVA_HOME/bin:$PATH
  14. case $1 in
  15. start)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh start;;
  16. stop)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh stop;;
  17. status)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh status;;
  18. restart)su root /home/fendo/zookeeper-3.4.10/bin/zkServer.sh restart;;
  19. *)  echo "require start|stop|status|restart"  ;;
  20. esac

然后我们就可以用service zookeeper start/stop来启动停止zookeeper服务了

使用命令把zookeeper添加到开机启动里面

  1. chkconfig zookeeper on
  2. chkconfig --add zookeeper

添加完成之后接这个使用chkconfig --list 来看看我们添加的zookeeper是否在里面。

Centos7下安装ZooKeeper的更多相关文章

  1. centos7下安装zookeeper&zookeeper集群的搭建

    一.centos7下安装zookeeper 1.zookeeper 下载地址 https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/ 2.安装步骤 ...

  2. Linux(Centos7)下安装 zookeeper docker版 集群

    为了省去麻烦的软件安装,现在开发环境需要的软件越来越习惯于docker安装了,先看下安装后的截图,开发环境正在启动的容器 1.首先系统需要先支持docker …… 由于之前安装几次都没有做流程记录,在 ...

  3. ZooKeeper教程(一)----Centos7下安装ZooKeeper(单机版)

    1.下载源码 官网下载地址: http://mirrors.hust.edu.cn/apache/zookeeper/ 选择最新的版本进行下载 这里选择3.4.10进行下载: wget http:// ...

  4. centos7上安装zookeeper

    centos7上安装zookeeper 1 准备工作 1.准备服务器,本次安装采用 centos7系统.内存2G.存储60G的虚拟机服务器一台: 2.服务器安装java环境: 参考文章<cent ...

  5. Linux CentOS7下安装Zookeeper-3.4.10服务(最新)

    Linux CentOS7下安装Zookeeper-3.4.10服务(最新) 2017年10月27日 01:25:26 极速-蜗牛 阅读数:1933   版权声明:本文为博主原创文章,未经博主允许不得 ...

  6. CentOS7 下 安装 supervisor以及使用

    CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...

  7. Linux CentOs7 下安装 redis

    Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装  命令如下 $ yum install gcc-c++ $ wget ht ...

  8. Centos7下安装配置Redsocks

    Redsocks是一个开源的网络程序,代码依赖开源的libevent网络库.Redsocks允许你将所有TCP连接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安装配 ...

  9. CentOS7下安装SVN服务端

    CentOS7下安装SVN服务 1. yum命令即可方便的完成安装# sudo yum install subversion 测试安装是否成功:# svnserve --version 更改svn的默 ...

随机推荐

  1. 带事务管理的spring数据库动态切换

    动态切换数据源理论知识 项目中我们经常会遇到多数据源的问题,尤其是数据同步或定时任务等项目更是如此:又例如:读写分离数据库配置的系统. 1.相信很多人都知道JDK代理,分静态代理和动态代理两种,同样的 ...

  2. java html table 转 excel,给予jdom 和 poi

    maven 引入 <dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artif ...

  3. 互操作性 a C++ library which enables seamless interoperability between C++ and the Python programming language

    https://zh.wikipedia.org/wiki/互操作性 就软件而言,互操作性——这条术语用来描述的是不同的程序(programs)借助于同一套交换格式(exchange formats) ...

  4. [String.Format(转换时间格式)]

    string.Format("{0:d}", System.DateTime.Now);   // 2017/6/2; string.Format("{0:D}" ...

  5. Struts 简单UI标签

    <!-- 服务器标签 : 最终别解析为html标签--> <s:form action="/user_login" method="post" ...

  6. split切割.号的字符串

    excel中的日期为下图所示,利用io读取到后,调试发现值为“12.10.2019”,需要将其转换为“2019-10-12” 用split方法以.号切割时,需要用转移字符“\\.”,代码如下 pack ...

  7. Oracle11g安装出现时未能满足某些最低安装要求

    需要开启C盘共享,才能检测硬件是否满足要求.cmd命令:net share c$=c::或者勾选全部忽略,继续下一步安装. 可参考https://blog.csdn.net/huazicomeon/a ...

  8. web开发常识

    web开发基本常识 服务器(硬件) 维基百科定义: 服务器作为硬件来说,通常是指那些具有较高计算能力,能够提供给多个用户使用的计算机.服务器与PC机的不同点很多,例如PC机在一个时刻通常只为一个用户服 ...

  9. Golang中基础的命令行模块urfave/cli

    前言相信只要部署过线上服务,都知道启动参数一定是必不可少的,当你在不同的网络.硬件.软件环境下去启动一个服务的时候,总会有一些启动参数是不确定的,这时候就需要通过命令行模块去解析这些参数,urfave ...

  10. Python爬虫学习==>第十一章:分析Ajax请求-抓取今日头条信息

    学习目的: 解决AJAX请求的爬虫,网页解析库的学习,MongoDB的简单应用 正式步骤 Step1:流程分析 抓取单页内容:利用requests请求目标站点,得到单个页面的html代码,返回结果: ...