zoukankan      html  css  js  c++  java
  • 5、linux上安装zookeeper

    1.基本信息
    版本 3.4.6
    安装机器 三台机器
    账号 hadoop
    源路径 /opt/software/zookeeper-3.4.6.tar.gz
    目标路径

    /opt/zookeeper -> /opt/zookeeper-3.4.6/

    依赖关系
    2.安装过程

    1).使用hadoop账户,通过tar -xxvf命令将zookeeper-${version}.tar.gz解压缩至目的安装目录,并设置软连接。

    [root@bgs-5p173-wangwenting opt]# su hadoop
    [hadoop@bgs-5p173-wangwenting opt]$ cd /opt/software
    [hadoop@bgs-5p173-wangwenting software]$ tar -zxvf zookeeper-${version}.tar.gz -C /opt/
    [hadoop@bgs-5p173-wangwenting software]$  cd /opt/
    [hadoop@bgs-5p173-wangwenting opt]$  ln -s /opt/zookeeper-${version}   /opt/zookeeper

    修改zoo.cfg配置文件。

    [hadoop@bgs-5p173-wangwenting zookeeper]# cd /opt/zookeeper/conf
    [hadoop@bgs-5p173-wangwenting conf]$ cp zoo_sample.cfg   zoo.cfg
    [hadoop@bgs-5p173-wangwenting conf]$ vim zoo.cfg

    2).在zoo.cfg文件中添加如下配置:

    dataDir=/opt/zookeeper/data
    dataLogDir=/opt/zookeeper/log
    server.1=bgs-5p173-wangwenting:2888:3888
    server.2=bgs-5p174-wangwenting:2888:3888
    server.3=bgs-5p175-wangwenting:2888:3888

    3).创建data目录和log目录,并在data目录下创建文件,命名为myid:

    [hadoop@bgs-5p173-wangwenting conf]$ mkdir /opt/zookeeper/data
    [hadoop@bgs-5p173-wangwenting conf]$ mkdir /opt/zookeeper/log
    [hadoop@bgs-5p173-wangwenting conf]$ vim  /opt/zookeeper/data/myid
    在myid文件中写入1(同理在另外两台机器中写23
    1

    4).配置zookeeper运行的环境变量。

    [hadoop@bgs-5p173-wangwenting conf]$ vim /etc/profile
    添加下面的内容:
    export ZK_HOME=/opt/hadoop/zookeeper
    export PATH=$ZK_HOME/bin:$PATH
    配置成功后,执行source /etc/profile使配置生效
    [hadoop@bgs-5p173-wangwenting conf]$ source /etc/profile

    5).将安装包从bgs-5p173-wangwenting服务器复制到bgs-5p174-wangwenting,bgs-5p175-wangwenting两台机器,并配置环境变量:

    [hadoop@bgs-5p173-wangwenting conf]$  scp -r /opt/zookeeper-3.4.6  hadoop@bgs-5p174-wangwenting:/opt
    [hadoop@bgs-5p173-wangwenting conf]$  scp -r /opt/zookeeper-3.4.6  hadoop@bgs-5p175-wangwenting:/opt
    在bgs-5p174-wangwenting和bgs-5p175-wangwenting上分别执行
    [hadoop@bgs-5p174-wangwenting conf]$ ln -s /opt/zookeeper-3.4.6 /opt/zookeeper
    [hadoop@bgs-5p175-wangwenting conf]$ ln -s /opt/zookeeper-3.4.6 /opt/zookeeper
    在bgs-5p174-wangwenting和bgs-5p175-wangwenting上分别修改/opt/zookeeper/data/myid文件,bgs-5p174-wangwenting中的myid改为2bgs-5p175-wangwenting中的改为3
    [hadoop@bgs-5p174-wangwenting conf]$ vim /opt/zookeeper/data/myid
    2
    [hadoop@bgs-5p175-wangwenting conf]$ vim /opt/zookeeper/data/myid
    3
    在bgs-5p174-wangwenting和bgs-5p175-wangwenting上分别步骤4配置zookeeper运行的环境变量

    6).在三台机器上分别执行zookeeper命令:$ zkServer.sh start

    [hadoop@bgs-5p173-wangwenting conf]$  zkServer.sh start
    [hadoop@bgs-5p174-wangwenting conf]$  zkServer.sh start
    [hadoop@bgs-5p175-wangwenting conf]$  zkServer.sh start

    7).检查每台机器的zookeeper状态:$ zkServer.sh status

    若输出结果是leader 或者follower, 三台机器中有一台是leader 和2 个follower, 说明安装成功了。

    [hadoop@bgs-5p173-wangwenting conf]$  zkServer.sh status
    [hadoop@bgs-5p174-wangwenting conf]$  zkServer.sh status
    [hadoop@bgs-5p175-wangwenting conf]$  zkServer.sh status

    8).检查zkCli命令是否能够执行成功:

    [hadoop@bgs-5p173-wangwenting conf]$ zkCli.sh -server bgs-5p173-wangwenting:2181,bgs-5p174-wangwenting:2181,bgs-5p175-wangwenting:2181

    若能成功连接,说明安装启动成功了

  • 相关阅读:
    SVN tags使用
    switch case执行顺序
    excel 15位身份证转18位
    .net core options 依赖注入的方式
    DICOM 相关概念了解
    Dicom文件基本操作
    asp.net core 3 使用nlog日志组件,使用$ {basedir}保存位置不对,记录下怎么解决
    asp.net core 动态更新 appsetting.json方法
    asp.net core appsetting.json 绑定读取
    centos 安装 nginx 及配置 的坑
  • 原文地址:https://www.cnblogs.com/wyl9527/p/6395410.html
Copyright © 2011-2022 走看看