Zookeeper部署

Zookeeper部署

1:环境

系统 IP 配置
CentOS7.9 10.0.0.10 2C2G

2:软件下载

# 日常软件下载
yum install -y net-tools lrzsz wget 

# zookeeper下载
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz --no-check-certificate

# java下载
yum install -y java-1.8.0

3:配置Zookeeper并启动单机版

[root@virtual_host ~]# tar xf apache-zookeeper-3.7.0-bin.tar.gz 
[root@virtual_host ~]# ls
anaconda-ks.cfg  apache-zookeeper-3.7.0-bin  apache-zookeeper-3.7.0-bin.tar.gz
[root@virtual_host ~]# cd apache-zookeeper-3.7.0-bin/
[root@virtual_host apache-zookeeper-3.7.0-bin]# ls
bin  conf  docs  lib  LICENSE.txt  NOTICE.txt  README.md  README_packaging.md
[root@virtual_host apache-zookeeper-3.7.0-bin]# cd conf
[root@virtual_host conf]# cat << eof>>zoo.cfg 
tickTime=2000
dataDir=/opt/zk/data
dataLogDir=/opt/zk/logs
clientPort=4180
eof

# 参数说明:
tickTime: zookeeper中使用的基本时间单位, 毫秒值.
dataDir: 数据目录. 可以是任意目录.
dataLogDir: log目录, 同样可以是任意目录. 如果没有设置该参数, 将使用和dataDir相同的设置.
clientPort: 监听client连接的端口号.	

至此, zookeeper的单机模式已经配置好了. 启动server只需运行脚本:
# 运行脚本启动
[root@virtual_host conf]# cd ../bin/
[root@virtual_host bin]# ./zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /root/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

# 查看zookeeper状态
[root@virtual_host bin]# ./zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /root/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg
Client port found: 4180. Client address: localhost. Client SSL: false.
Mode: standalone

# 查看端口占用
[root@virtual_host bin]# netstat -nplt | grep 4180 
tcp6       0      0 :::4180                 :::*                    LISTEN      12779/java

# 测试连接
[root@virtual_host ~]# zk-1/bin/zkCli.sh --server localhost:4180
/usr/bin/java
Connecting to localhost:2181
posted @ 2022-02-02 15:46  Layzer  阅读(18)  评论(0编辑  收藏  举报