1.安装java环境
1.1创建目录
root@ubuntu2004:~# mkdir -p /data/{soft,server}
root@ubuntu2004:~# tree /data/
/data/
├── server
└── soft
1.2配置jdk(参考我的博客介绍怎样安装以及配置jdk)
root@ubuntu2004:/data/soft# tar xf jdk-8u121-linux-x64.tar.gz -C /data/server/
root@ubuntu2004:/data/soft# cd /data/server/
root@ubuntu2004:/data/server# ls
jdk1.8.0_121
root@ubuntu2004:/data/server# ln -s jdk1.8.0_121/ java
root@ubuntu2004:/data/server# ls
java jdk1.8.0_121
1.3配置变量
root@ubuntu2004:~# echo 'export JAVA_HOME=/data/server/java' >> /etc/profile
root@ubuntu2004:~# echo 'export JRE_HOME=$JAVA_HOME/jre' >> /etc/profile
root@ubuntu2004:~# echo 'export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar' >> /etc/profile
root@ubuntu2004:~# echo 'export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH' >> /etc/profile
root@ubuntu2004:~# source /etc/profile
1.4检查jdk安装效果
root@ubuntu2004:~# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
root@ubuntu2004:~# tree -L 1 /data/server/java/
/data/server/java/
├── COPYRIGHT
├── LICENSE
├── README.html
├── THIRDPARTYLICENSEREADME-JAVAFX.txt
├── THIRDPARTYLICENSEREADME.txt
├── bin
├── db
├── include
├── javafx-src.zip
├── jre
├── lib
├── man
├── release
└── src.zip
6 directories, 8 files
2.安装zookeeper
2.1下载zookeeper
root@ubuntu2004:/data/server# cd /data/server/
root@ubuntu2004:/data/server#wget http://archive.apache.org/dist/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz
root@ubuntu2004:/data/server#wget http://archive.apache.org/dist/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz.asc
2.2配置下载操作
#校验软件安全
gpg --verify apache-zookeeper-3.7.0-bin.tar.gz.asc
#对比 MD5 码一致后进行解压安装
tar zxvf apache-zookeeper-3.7.0-bin.tar.gz -C /data/server
cd /data/server
ln -s apache-zookeeper-3.7.0-bin zookeeper
echo 'export PATH=/data/server/zookeeper/bin:$PATH' > /etc/profile.d/zk.sh
source /etc/profile.d/zk.sh
2.3查看配置
#查看配置模板文件
root@ubuntu2004:/data/server# cat zookeeper/conf/zoo_sample.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
root@ubuntu2004:/data/server# grep -ni "^[A-Z]" zookeeper/conf/zoo_sample.cfg
2:tickTime=2000
5:initLimit=10
8:syncLimit=5
12:dataDir=/tmp/zookeeper
14:clientPort=2181
2.4复制模板文件
root@ubuntu2004:/data/server/zookeeper#cp conf/zoo_sample.cfg conf/zoo.cf
2.4启动服务
root@ubuntu2004:/data/server/zookeeper# bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /data/server/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
root@ubuntu2004:/data/server/zookeeper# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 127.0.0.1:6010 0.0.0.0:*
LISTEN 0 50 *:2181 *:*
#zookeeper端口为2181