010-CentOS6.9安装Zookeeper3.4.10

1 确保系统安装了jdk,然后下载zookeeper3.4.10到/packages 

cd /packages

wget http://mirror.bit.edu.cn/apache/zookeeper/current/zookeeper-3.4.10.tar.gz

2 解压zookeeper 

mkdir /usr/zookeeper 

tar -zxvf /packages/zookeeper-3.4.10.tar.gz -C /usr/zookeeper

3 进入zookeeper配置目录,拷贝原来的示例名称配置文件为正式名称的配置文件 

cd /usr/zookeeper/zookeeper-3.4.10/conf

cp zoo_sample.cfg zoo.cfg

4 配置zoo.cfg 文件 做以下修改 

mkdir /usr/zookeeper/zookeeper-3.4.10/log

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=/usr/zookeeper/zookeeper-3.4.10

dataLogDir=/usr/zookeeper/zookeeper-3.4.10/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

保存退出

5 配置环境变量

export ZOOKEEPER_INSTALL=/usr/zookeeper/zookeeper-3.4.10

export PATH=$PATH:$ZOOKEEPER_INSTALL/bin

6 启动 zookeeper

/usr/zookeeper/zookeeper-3.4.10/bin/zkServer.sh start

显示以下内容

ZooKeeper JMX enabled by default

Using config: /usr/zookeeper/zookeeper-3.4.10/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

7 测试

/usr/zookeeper/zookeeper-3.4.10/bin/zkCli.sh -server 192.168.230.159:2181

连接成功,出现

[zk: 192.168.230.159:2181(CONNECTED) 0] 

如果是本地连接,那么不需要 -server 192.168.230.159:2181,默认是本地

注意:如果出现拒绝连接,请检查如下:

1、防火墙是否关闭  systemctl stop firewalld

2、需要将192.168.230.159 映射到本地 /etc/hosts文件中,否则无法连接

3 检查目录  /var/lib/zookeeper/  是否有myid



我们的交流基地,“JAVA互联网技术交流:789650498”欢迎小伙伴们一起来交流:

010-CentOS6.9安装Zookeeper3.4.10_第1张图片

你可能感兴趣的:(010-CentOS6.9安装Zookeeper3.4.10)