服务器单台:4C8G
官网下载地址:
https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.6.1/apache-zookeeper-3.6.1-bin.tar.gz
关闭selinux
sed -i '7s#enforcing#disabled#g' /etc/selinux/config
setenforce 0
关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
优化下载源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
安装所需软件包
yum install wget vim -y
下载zookeeper
wget https://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.6.1/apache-zookeeper-3.6.1-bin.tar.gz
解压到/usr/local下
tar xf apache-zookeeper-3.6.1-bin.tar.gz -C /usr/local/
下载Java
网址:https://www.oracle.com/java/technologies/javase-jdk14-downloads.html
wget https://download.oracle.com/otn-pub/java/jdk/14.0.1+7/664493ef4a6946b186ff29eb326336a2/jdk-14.0.1_linux-x64_bin.tar.gz?AuthParam=1592647377_1b13524ed11ea1e651cf2709e0d61ce2
下载的文件有点…
[root@localhost ~]# ls
anaconda-ks.cfg apache-zookeeper-3.6.1-bin.tar.gz jdk-14.0.1_linux-x64_bin.tar.gz?AuthParam=1592647377_1b13524ed11ea1e651cf2709e0d61ce2
重命名下凑合能用
mv jdk-14.0.1_linux-x64_bin.tar.gz\?AuthParam\=1592647377_1b13524ed11ea1e651cf2709e0d61ce2 jdk-14.0.1_linux-x64_bin.tar.gz
解压
tar xf jdk-14.0.1_linux-x64_bin.tar.gz -C /usr/local/
添加环境变量
vim /etc/profile
文件末尾加入(JAVA_HOME则为java解压的目录)
# java
export JAVA_HOME=/usr/local/jdk-14.0.1
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
source /etc/profile
# 执行命令检查
[root@localhost local]# java -version
java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
安装Java完成
修改zookeeper配置
cd /usr/local/apache-zookeeper-3.6.1-bin/conf
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg
# 文件末尾加入:
server.1=localhost:2888:3888
# localhost可改为本机IP
cd ..
./bin/zkServer.sh start
检查是否启动
[root@localhost apache-zookeeper-3.6.1-bin]# ./bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.6.1-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone
添加环境变量
[root@localhost conf]# vim /etc/profile
#追加
# zookeeper
export ZK_HOME=/usr/local/apache-zookeeper-3.6.1-bin
export PATH=$PATH:${ZK_HOME}/bin
[root@localhost conf]# source /etc/profile
# 检查状态 如下则启动成功
[root@localhost conf]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/apache-zookeeper-3.6.1-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone