1.下載jdk1.8和zookeeper3.6.0的安裝包
1.1 jdk官網(wǎng)下載地址:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
1.2 zk官網(wǎng)下載地址:https://archive.apache.org/dist/zookeeper/zookeeper-3.6.0/apache-zookeeper-3.6.0-bin.tar.gz
2.上傳到linux服務器
//安裝上傳工具sz
yum install -y lrzsz
//創(chuàng)建安裝目錄
mkdir /opt/xiaoqiaobian
cd /opt/xiaoqiaobian
//執(zhí)行上傳命令
rz
//選擇安裝包進行上傳
3.上傳后解壓安裝
//3.1解壓jdk和zookeeper
tar -zxvf jdk-8u161-linux-x64.tar.gz
tar -zxvf apache-zookeeper-3.6.0-bin.tar.gz
//3.4給解壓后的文件目錄重命名
mv jdk1.8.0_161 jdk1.8
4.修改環(huán)境變量
//4.1設置環(huán)境變量
vi /etc/profile
//4.2在最下面添加以下信息
#set java environment
export JAVA_HOME=/opt/xiaoqiaobian/jdk1.8
export CLASSPATH=$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
#set zookeeper environment
export ZOOKEEPER_HOME=/opt/xiaoqiaobian/apache-zookeeper-3.6.0-bin
export PATH=$PATH:$ZOOKEEPER_HOME/bin
//4.3命令讓修改生效
source /etc/profile
5.zookeeper配置
//5.1創(chuàng)建data和logs目錄
cd apache-zookeeper-3.6.0-bin
mkdir data
mkdir logs
//5.2修改配置文件
cd conf
mv zoo_sample.cfg zoo.cfg
vi zoo.cfg
//5.3zoo.cfg配置如下
ticketTime=2000
clientPort=2181
dataDir=/opt/xiaoqiaobian/apache-zookeeper-3.6.0-bin/data
dataLogDir=/opt/xiaoqiaobian/apache-zookeeper-3.6.0-bin/logs
6.測試成功
//6.1查看jdk版本號
java -version
/*
[root@hecs-x-medium-2-linux-20200705142322 java]# java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
*/
//6.2查看zk
cd /opt/xiaoqiaobian/apache-zookeeper-3.6.0-bin/bin
./zkServer.sh start
ps -ef|grep zookeeper
/*
[root@centos bin]# ps -ef|grep zookeeper
root 17724 1 3 23:33 pts/0 00:00:01 /opt/xiaoqiaobian/jdk1.8/bin/java -
Dzookeeper.log.dir=/opt/xiaoqiaobian/apache-zookeepe-3.6.0-bin/bin/../logs -
Dzookeeper.log.file=zookeeper-root-server-VM-0-8-centos.log -
Dzookeeper.root.logger=INFO,CONSOLE -XX:+HeapDumpOnOutOfMemoryError -
XX:OnOutOfMemoryError=kill -9 %p -cp /opt/xiaoqiaobian/apache-
zookeeper-3.6.0-bin/bin/..
*/