# 主机规划
zk-node-01 192.168.83.21
zk-node-02 192.168.83.22
zk-node-03 192.168.83.22
# 机器名设置
hostnamectl set-hostname zk-node-01
# 设置IP
## 修改配置文件
vi /etc/sysconfig/network-scripte/ifcfg-ens33
### 配置如下:
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="28298bdd-7c9c-4117-bc1a-727304eb569e"
DEVICE="ens33"
ONBOOT="yes"
IPV6_PRIVACY="no"
IPADDR=192.168.83.21
NETMASK=255.255.255.0
GATEWAY=192.168.83.2
DNS1=8.8.8.8
DNS2=114.114.114.114
## 重新生效网络配置
service network restart
# 安装jdk
vi /etc/profile
export JAVA_HOME=/root/soft/jdk1.8.0_261
export CLASSPATH=.:$JAVA_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin
# 下载 zookeeper-3.4.6.tar.gz
##打开官网 找到下载地址:
## 解压包zookeeper
tar xf zookeeper-3.4.14.tar.gz
## 将解压的包移动到/opt/myprogram/zookeeper 中
mkdir -p /opt/myprogram/zookeeper
mv zookeeper-3.4.14 /opt/myprogram/zookeeper
# 配置zookeeper的系统环境变量
## 修改profile文件
vi /etc/profile
export ZOOKEEPER_HOME=/opt/myprogram/zookeeper-3.4.14
export PATH=$PATH:$ZOOKEEPER_HOME/bin
## 生效配置文件
source /etc/profile
# 配置zoo.cfg文件
mkdir -p /var/myprogramdata/zookeeper
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
## 文件地址:
dataDir=/var/myprogramdata/zookeeper
## 集群列表:
server.1=192.168.83.21:2888:3888
server.2=192.168.83.22:2888:3888
server.3=192.168.83.23:2888:3888
# 配置myid文件
服务器1:
echo 1 > /var/myprogramdata/zookeeper/myid
服务器2:
echo 2 > /var/myprogramdata/zookeeper/myid
服务器3:
echo 3 > /var/myprogramdata/zookeeper/myid
# 关闭防火墙
systemctl stop firewalld.service
# 运行
zkServer.sh start
# 查看状态
zkServer.sh status