zookeeper 安装

1. 下载安装文件zookeeper-3.4.6.tar.gz

镜像地址1: http://apache.fayea.com/zookeeper/

镜像地址2: http://mirrors.hust.edu.cn/apache/zookeeper/


2. copy到虚拟机的centos系统桌面

3. 新建/usr/loca/zookeeper文件夹

[root@localhost ~]# mkdir -pv /usr/local/zookeeper

4.拷贝文件到指定文件夹

[root@localhost ~]# cd /root/Desktop/

[root@localhost ~]# cp ./zookeeper-3.4.6.tar.gz /usr/local/zookeeper

5. 解压

[root@localhost ~]# tar -zxvf jdk-8u121-linux-x64.tar.gz

6. 配置环境变量

[root@localhost ~]#cd /etc/

[root@localhost ~]#cp ./profile ./profile.bak -- 把文件备份一下

[root@localhost ~]#vi /etc/profile -- 编辑此配置文件

在文件末尾添加此段内容: -- 开始和--中间的一段.(注意,尽量保持环境变量名全大写,下划线隔开. 保持规范)

-- 开始

export ZOOKEEPER_INSTALL=/usr/local/zookeeper/zookeeper-3.4.6/

export PATH=$PATH:$ZOOKEEPER_INSTALL/bin

-- 结束

7. 配置文件修改

[root@localhost zookeeper-3.4.6]# cd /usr/local/zookeeper/zookeeper-3.4.6/conf/ -- 进入文件所在路径

[root@localhost conf]# cp zoo_sample.cfg zoo.cfg -- 将zoo.sample.cfg拷贝出一份zoo.cfg出来. 文件名强制

8. 文件内容如下

[root@localhost conf]# vi zoo.cfg -- 按i进入编辑模式. 修改完成之后, esc退出编辑模式, 大写字母Z双击即可保存.

# 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 -- 这里要设置一下文件路径 路径必须存在,不存在的话就新建一个

dataLogDir=/tmp/zookeeper/log -- 日志路径 路径必须存在,不存在的话就新建一个,(新建文件夹文件)

# the port at which the clients will connect

clientPort=2181 -- 如果是多机器的话,在clientPort处添加服务器的ip

# 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

修改完之后 通过 > # cat zoo.cfg 查看配置情况.

9. 开启服务,关闭服务, 查看

[root@localhost bin]# cd /usr/local/zookeeper/zookeeper.3.4.6/bin/ ---跳转到 bin 下

a.停止服务

[root@localhost bin]# ./zkServer.sh stop -- 停止服务

JMX enabled by default

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

Stopping zookeeper ... STOPPED

b.开启服务

[root@localhost bin]# ./zkServer.sh start -- 开启服务

JMX enabled by default

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

Starting zookeeper ... STARTED

c.查看状态

[root@localhost bin]# ./zkServer.sh status -- 查看状态,不一定显示成功

JMX enabled by default

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

Mode: standalone

[root@localhost bin]# ./zkCli.sh -- 客户端启动, 可以查看启动状态和日志

Connecting to localhost:2181

参考

你可能感兴趣的:(zookeeper 安装)