目前在研究dubbo这个国内流行的RPC框架,实现去中心话的微服务需要用到Zookeeper,所以今天来说说如何安装Zookeeper。
Zookeeper的官方下载地址
查看Centos版本:
1 2 3 4 5
| cat /etc/issue
[root@iZwz99xkrnh5xy0cqp8aofZ tomcat] CentOS release 6.9 (Final) Kernel \r on an \m
|
1.下载安装包到/usr/local/src/目录下,并创建安装目录/usr/local/zookeeper。
1 2 3 4
| cd /usr/local/src/
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz mkdir /usr/local/zookeeper
|
2.解压安装包,并将解压后的文件拷贝到/usr/local/zookeeper
1 2
| tar -zxvf zookeeper-3.4.10.tar.gz cp -R /usr/local/zookeeper/zookeeper-3.4.10/* /usr/local/zookeeper
|
3.添加系统变量到/etc/profile
1 2 3
| export ZOOKEEPER_HOME=/usr/local/zookeeper export PATH=$ZOOKEEPER_HOME/bin:$PATH export PATH
|
执行命令 source /etc/profile使配置文件立即生效
4.创建zookeeper配置文件,并作相应的配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| cd /usr/local/zookeeper/conf/ cp zoo_sample.cfg zoo.cfg
tickTime=2000
dataDir=/usr/local/zookeeper/data
dataLogDir=/var/log/zookeeper
clientPort=2181
|
5.zookeeper相关命令
1 2 3 4
| 启动服务:zkServer.sh start 查看状态:zkServer.sh status 关闭服务:zkServer.sh stop 重启服务:zkServer.sh restart
|
至此,zookeeper安装完成