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目录下创建以下目录:

  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

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

然后修改zoo.cfg文件

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)

vim myid

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

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

使配置文件生效

source /home/fendo/.bash_profile

关闭防火墙

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

systemctl stop firewalld.service

3、测试Zookeeper

 

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

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

设置zookeeper服务开机启动

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

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

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

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

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

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. Centos7下安装ZooKeeper

    1.下载源码 zookeeper 需要jdk的支持,需要先安装jdk 官网下载地址: http://mirrors.hust.edu.cn/apache/zookeeper/ 选择最新的版本进行下载 ...

  4. centos7上安装zookeeper

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

  5. Windows下安装ZooKeeper

    Windows下安装ZooKeeper   一.简介 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组 ...

  6. Linux下安装Zookeeper

    Zookeeper是一个协调服务,可以用它来作为配置维护.名字服务.分布式部署: 下面,我来分享一下在Linux下安装Zookeeper的整个步骤,让大家少走弯路. 一.Zookeeper下载 [ro ...

  7. 如何在Centos7上安装zookeeper 多实例

    一.如何在Centos7上安装zookeeper 多实例 cd /usr/local/src/ wget https://mirrors.tuna.tsinghua.edu.cn/apache/zoo ...

  8. Storm(1)-centos7下安装单机版Strom

    1.所需软件: jdk8.zookeeper.storm 2.安装zookeeper单机版 下载:http://zookeeper.apache.org/releases.html#download ...

  9. Win10下安装zookeeper

    Win10下安装zookeeper 注册中心zookeeper的安装 0.去Apache官网下载zookeeper http://zookeeper.apache.org/ 2.找到解压路径的conf ...

随机推荐

  1. ubuntu上安装R的时候遇到的问题总结

    首先感谢这两篇博客的指导,第一篇是关于报错的总结,第二篇是第一篇中没有提到的错误,也就是我在安装的时候出现的错误. 1.下载R包 (去官网选择一个离你最近的镜像网址,我的是清华提供的镜像下载速度比较快 ...

  2. 事件绑定的快捷方式 利on进行事件绑定的几种情况

    [事件绑定快捷方式]$("button:first").click(function(){ alert(1); }); [使用on绑定事件] ① 使用on进行单事件绑定 $(&qu ...

  3. tomcat的8088端口被占用

    打开Dos:windows->输入cmd(想必这个都会) 在黑窗口中输入指令:netstat -ano | findstr 8080       指令的意思是找出占用8080端口的进程pid 再 ...

  4. emit 方法表翻译

      Name Description Add Adds two values and pushes the result onto the evaluation stack.添加两个值并将结果推送到评 ...

  5. win10下设置IIS、安装php7.2

    开启IIS及相关功能: 控制面板——程序和功能——启用或关闭Windows功能——勾选Internet Information Service——万维网服务——性能和功能——勾选CGI 开启成功后在 ...

  6. Linux安装之后需要进行的一些步骤

    查看IP 首先安装后需要查看ip用SSH或者XSHELL来连接Linux,查看ip代码 ifconfig 需要执行 sudo yum install net-tools 命令安装之后 就可以看到ip了 ...

  7. 关于springmvc中常用的注解,自己也整理一下

    1.@Controller 在springMVC中@controller主要用在控制层的类上,之前只知道用注解开发的时候必须加一个@controller ,今天看了别的大佬整理的才知道为什么这么用,控 ...

  8. 对JDK、JRE和JVM的一些浅薄理解

    JDK:JDK(Java Development Kit),顾名思义是java程序的开发包,任何java程序想要运行都需要相应版本的JDK,可以到oracle下载(下载之后自带JRE和编译工具等,无需 ...

  9. Shared——The best front-end hacking cheatsheets — all in one place.

    原文地址:https://medium.freecodecamp.org/modern-frontend-hacking-cheatsheets-df9c2566c72a The best front ...

  10. DOM基础操作(二)

    插入操作 1.appendChild(child); 这个是父级调用的方法,它会将child元素插入到父级里面,而且是放到逻辑后面的位置上.   div.appendChild(comment);   ...