博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Zookeeper 3.4.x安装和配置--Linux篇
阅读量:6496 次
发布时间:2019-06-24

本文共 4555 字,大约阅读时间需要 15 分钟。

hot3.png

阅读目录:

1. 关闭防火墙和Selinux

2. 安装所需环境JDK

3. 下载Zookeeper 3.4.x版本

4. 配置并启动Zookeeper

5. 验证并配置自启动

6. 说明

1. 关闭防火墙和Selinux

        Linux的防火墙是咱们新手的噩梦,很多情况会出现能ping通,但是访问不了Web页面。所以开始就干掉它!

    1.1 关闭防火墙

    [root@localhost ~]# /etc/init.d/iptables stop    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]    iptables: Flushing firewall rules:                         [  OK  ]    iptables: Unloading modules:                               [  OK  ]

    1.2 开机自动关闭防火墙

    [root@localhost ~]# chkconfig iptables off

    1.3 查看Selinux状态

    [root@localhost ~]# sestatus    SELinux status: enabled     SELinuxfs mount: /sys/fs/selinux     SELinux root directory: /etc/selinux     Loaded policy name: targeted     Current mode: enforcing     Mode from config file: enforcing     Policy MLS status: enabled     Policy deny_unknown status: allowed     Max kernel policy version: 28

    1.4 关闭selinux

    [root@localhost ~]# vim /etc/selinux/config 

修改 SELINUX=disabled 

注:永久开启->改成:SELINUX=enforcing

2. 安装所需环境JDK

    直接参考本文:

3. 下载Zookeeper 3.4.x版本

    注:创建两个目录存放log日志和data数据

    [root@localhost /]# mkdir /usr/local/zookeeper    [root@localhost /]# mkdir /usr/local/zookeeper/data    [root@localhost /]# mkdir /usr/local/zookeeper/dataLog

    3.1 下载Zookeeper 3.4.x

    [root@localhost /]# cd /usr/local/zookeeper    [root@localhost zookeeper]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz

    3.2 解压

    [root@localhost zookeeper]# tar -zxvf zookeeper-3.4.11.tar.gz

4. 配置并启动Zookeeper

    4.1 进入Zookeeper 3.4.x 的配置文件夹

    [root@localhost zookeeper]# cd /usr/local/zookeeper/zookeeper-3.4.11/conf

    4.2 备份配置文件(做修改用)

    [root@localhost conf]# mv zoo_sample.cfg zoo.cfg

    4.3 修改配置文件zoo.cfg

    [root@localhost conf]# vim zoo.cfg

    增加标红的两行

# The number of ticks that can pass between 

# 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 
# 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=/tmp/zookeeper
# 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
#
# 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=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

dataDir=/usr/local/zookeeper/data

dataLogDir=/usr/local/zookeeper/dataLog

    4.4 配置zookeeper环境变量

    [root@localhost conf]# vim /etc/profile

    在文本末最后一行添加如下代码:

export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.11

export PATH=$ZOOKEEPER_HOME/bin:$PATH

保存退出。

    4.5 使配置立即生效

    [root@localhost conf]# source /etc/profile

    4.6 启动Zookeeper

    [root@localhost conf]# /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh start     ZooKeeper JMX enabled by default    Using config: /usr/local/zookeeper/zookeeper-3.4.11/bin/../conf/zoo.cfg    Starting zookeeper ... STARTED

5. 验证并配置自启动

    5.1 验证

    [root@localhost conf]# /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh status    ZooKeeper JMX enabled by default    Using config: /usr/local/zookeeper/zookeeper-3.4.11/bin/../conf/zoo.cfg    Mode: standalone

    5.2 创建编辑自启动文件

    [root@localhost conf]# vim /etc/rc.d/init.d/zookeeper

#!/bin/bash  

#chkconfig:2345 10 90  
#description:zookeeper  
#processname:zookeeper  
export JAVA_HOME=/usr/java/jdk1.8.0_144
case $1 in
        start) su root /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh start;;
        stop) su root /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh stop;;
        status) su root /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh status;;
        restart) su /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh restart;;
        *) echo "require start|stop|status|restart" ;;
esac

    5.3 授予文件权限

    [root@localhost conf]# chmod +x /etc/rc.d/init.d/zookeeper

    5.4 添加到开机自启

    [root@localhost conf]# cd /etc/rc.d/init.d/    [root@localhost conf]# chkconfig --add zookeeper

6. 说明

    说明:本次使用

       操作系统:CentOS 6.8 64位

       Zookeeper版本:3.4.11

    注:如遇到下载链接失效,可以尝试访问:

转载于:https://my.oschina.net/loubobooo/blog/1626469

你可能感兴趣的文章
Filter案例用户自动登录学习笔记
查看>>
阿里云内网和公共NTP服务器
查看>>
c++ 正则表达式邮箱
查看>>
C 提高1 内存四区 变量本质 栈开口方向 指针铁律1
查看>>
QT windows平台安装
查看>>
Outlook 2003 邮件不能显示图片
查看>>
1+1*2+1*2*3+1*2*3*n数列的求和算法
查看>>
异常模拟测试 -- 场景抽象及解决方案
查看>>
Gradle之旅-can not find tools.jar问题解决
查看>>
JavaScript_navigator
查看>>
apache配置文件详解
查看>>
linux下echo的使用总结
查看>>
EDM营销学堂:高效提升营销邮件点击率的技巧
查看>>
ORACLE 11G静默安装配置分解
查看>>
为什么大家不相信国产虚拟化技术?
查看>>
华为首提“业务驱动基础架构”(SDI)
查看>>
Word2010使用技巧之一:熟悉功能区
查看>>
Citrix XenDektop 7 实施十 创建License Server
查看>>
RookeyFrame 通用页面 加载数据 原理
查看>>
hbuilder APP服务器端(C#)推送
查看>>