Zookeeper(一):安装和配置
Zookeeper(一):安装和配置
那是光啊 发表于5个月前
Zookeeper(一):安装和配置
  • 发表于 5个月前
  • 阅读 3
  • 收藏 0
  • 点赞 0
  • 评论 0

标题:腾讯云 新注册用户域名抢购1元起>>>   

  1. 安装环境 Centos7.2 64位 JDK 1.8.0_144 64位 Zookeeper 3.4.10

  2. 安装zookeeper需要java环境。

[root@localhost ~]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
[root@localhost ~]#

可以看这个链接输入链接说明

  1. 下载Zookeeper安装包 首先进入我的安装包目录,这个目录自建的
[root@localhost ~]# cd /package/
[root@localhost package]# ls
jdk-8u144-linux-x64.rpm 

接着下载Zookeeper的安装包

[root@localhost package]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
--2017-08-25 15:49:08--  https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.6.177, 2402:f000:1:416:101:6:6:177
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.6.177|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35042811 (33M) [application/octet-stream]
Saving to: ‘zookeeper-3.4.10.tar.gz’

100%[==================================================================================================================================>] 35,042,811   897KB/s   in 28s  

然后解压安装包

[root@localhost package]#  tar -zxvf zookeeper-3.4.10.tar.gz
...
[root@localhost package]# mv zookeeper-3.4.10 /software/zookeeper
[root@localhost package]# cd /software/zookeeper/
[root@localhost zookeeper]# ls
bin        contrib     docs             lib          NOTICE.txt            recipes               zookeeper-3.4.10.jar.asc
build.xml  data        ivysettings.xml  LICENSE.txt  README_packaging.txt  src                   zookeeper-3.4.10.jar.md5
conf       dist-maven  ivy.xml          log          README.txt            zookeeper-3.4.10.jar  zookeeper-3.4.10.jar.sha1
[root@localhost zookeeper]# 

修改zookeeper的cfg配置文件

[root@localhost zookeeper]# mv conf/zoo_sample.cfg  conf/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=/software/zookeeper/data
#日志目录
dataLogDir=/software/zookeeper/log
# 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

修改/bin/zkEnv.sh,在ZOOKEEPER_PREFIX添加

ZOO_LOG_DIR=$ZOOKEEPER_PREFIX/log

再修改下ZOO_LOG4J_PROP,以让日志不是输出到zookeeper.out,而是写入到日志文件,将:ZOO_LOG4J_PROP="INFO,CONSOLE",改成:ZOO_LOG4J_PROP="INFO,ROLLINGFILE"

将Zookeeper_home添加进环境变量 vim /etc/profile

#zookeeper
export ZOOKEEPER_HOME=/software/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin

export JAVA_HOME JAVA_BIN PATH CLASSPATH ZOOKEEPER_HOME

执行source /etc/profile 使profile 文件即可生效

启动Zookeeper

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

查看Zookeeper状态

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

standalone表示单机

停止Zookeeper

[root@localhost zookeeper]# zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /software/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[root@localhost zookeeper]# 
标签: zookeeper
共有 人打赏支持
粉丝 0
博文 11
码字总数 15628
×
那是光啊
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: