linux下安装zookeeper
linux发行版:CentOS Linux release 7.6.1810 (Core)
zookeeper版本:Zookeeper version: 3.4.8–1, built on 02/06/2016 03:18 GMT
参考
https://blog.youkuaiyun.com/Dongguabai/article/details/83215303
https://blog.youkuaiyun.com/xzg1109/article/details/79099309
https://blog.youkuaiyun.com/qingfengxd1/article/details/92806428
https://blog.youkuaiyun.com/she_lock/article/details/80435176
先抛日志,后续整理:
[root@localhost app]# mv zookeeper2181/ zookeeper
[root@localhost app]# cd /home/app/zookeeper/
[root@localhost zookeeper]# ll
总用量 1556
drwxr-xr-x. 2 root root 170 8月 21 18:35 bin
-rw-r--r--. 1 root root 83235 2月 6 2016 build.xml
-rw-r--r--. 1 root root 88625 2月 6 2016 CHANGES.txt
drwxr-xr-x. 2 root root 92 8月 21 18:35 conf
drwxr-xr-x. 10 root root 130 8月 21 18:35 contrib
drwxr-xr-x. 2 root root 4096 8月 21 18:35 dist-maven
drwxr-xr-x. 6 root root 4096 8月 21 18:35 docs
-rw-r--r--. 1 root root 1953 2月 6 2016 ivysettings.xml
-rw-r--r--. 1 root root 3498 2月 6 2016 ivy.xml
drwxr-xr-x. 4 root root 266 8月 21 18:35 lib
-rw-r--r--. 1 root root 11938 2月 6 2016 LICENSE.txt
-rw-r--r--. 1 root root 171 2月 6 2016 NOTICE.txt
-rw-r--r--. 1 root root 1770 2月 6 2016 README_packaging.txt
-rw-r--r--. 1 root root 1585 2月 6 2016 README.txt
drwxr-xr-x. 5 root root 47 8月 21 18:35 recipes
drwxr-xr-x. 8 root root 191 8月 21 18:35 src
-rw-r--r--. 1 root root 1360961 2月 6 2016 zookeeper-3.4.8.jar
-rw-r--r--. 1 root root 819 2月 6 2016 zookeeper-3.4.8.jar.asc
-rw-r--r--. 1 root root 33 2月 6 2016 zookeeper-3.4.8.jar.md5
-rw-r--r--. 1 root root 41 2月 6 2016 zookeeper-3.4.8.jar.sha1
[root@localhost zookeeper]# mkdir data
[root@localhost zookeeper]# mkdir logs
[root@localhost zookeeper]# ll
总用量 1556
drwxr-xr-x. 2 root root 170 8月 21 18:35 bin
-rw-r--r--. 1 root root 83235 2月 6 2016 build.xml
-rw-r--r--. 1 root root 88625 2月 6 2016 CHANGES.txt
drwxr-xr-x. 2 root root 115 11月 20 11:02 conf
drwxr-xr-x. 10 root root 130 8月 21 18:35 contrib
drwxr-xr-x. 2 root root 6 11月 20 11:02 data
drwxr-xr-x. 2 root root 4096 8月 21 18:35 dist-maven
drwxr-xr-x. 6 root root 4096 8月 21 18:35 docs
-rw-r--r--. 1 root root 1953 2月 6 2016 ivysettings.xml
-rw-r--r--. 1 root root 3498 2月 6 2016 ivy.xml
drwxr-xr-x. 4 root root 266 8月 21 18:35 lib
-rw-r--r--. 1 root root 11938 2月 6 2016 LICENSE.txt
drwxr-xr-x. 2 root root 6 11月 20 11:02 logs
-rw-r--r--. 1 root root 171 2月 6 2016 NOTICE.txt
-rw-r--r--. 1 root root 1770 2月 6 2016 README_packaging.txt
-rw-r--r--. 1 root root 1585 2月 6 2016 README.txt
drwxr-xr-x. 5 root root 47 8月 21 18:35 recipes
drwxr-xr-x. 8 root root 191 8月 21 18:35 src
-rw-r--r--. 1 root root 1360961 2月 6 2016 zookeeper-3.4.8.jar
-rw-r--r--. 1 root root 819 2月 6 2016 zookeeper-3.4.8.jar.asc
-rw-r--r--. 1 root root 33 2月 6 2016 zookeeper-3.4.8.jar.md5
-rw-r--r--. 1 root root 41 2月 6 2016 zookeeper-3.4.8.jar.sha1
[root@localhost zookeeper]# cd conf/
[root@localhost conf]# cp zoo.cfg zoo.cfg20191120
[root@localhost conf]# ll
总用量 20
-rw-r--r--. 1 root root 535 2月 6 2016 configuration.xsl
-rw-r--r--. 1 root root 2161 2月 6 2016 log4j.properties
-rw-r--r--. 1 root root 922 11月 20 11:01 zoo.cfg
-rw-r--r--. 1 root root 922 2月 6 2016 zoo.cfg20191120
-rw-r--r--. 1 root root 922 2月 6 2016 zoo_sample.cfg
[root@localhost conf]# vi zoo.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=/home/app/zookeeper/data
dataLogDir=/home/app/zookeeper/log
# 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
~
~
~
"zoo.cfg" 29L, 967C written
[root@localhost conf]# vi /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
export JAVA_HOME=/usr/local/java/jdk1.8.0_144
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export ZOOKEEPER=/home/app/zookeeper
export PATH=$PATH:$ZOOKEEPER/bin
"/etc/profile" 86L, 2064C written
[root@localhost conf]# source /etc/profile
[root@localhost conf]# echo $PATH
/usr/local/java/jdk1.8.0_144/bin:/usr/local/java/jdk1.8.0_144/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/home/app/zookeeper/bin
[root@localhost conf]# zkServer.sh start
-bash: /home/app/zookeeper/bin/zkServer.sh: 权限不够
[root@localhost conf]# cd /home/app/zookeeper/
[root@localhost zookeeper]# ll
总用量 1556
drwxr-xr-x. 2 root root 170 8月 21 18:35 bin
-rw-r--r--. 1 root root 83235 2月 6 2016 build.xml
-rw-r--r--. 1 root root 88625 2月 6 2016 CHANGES.txt
drwxr-xr-x. 2 root root 115 11月 20 11:04 conf
drwxr-xr-x. 10 root root 130 8月 21 18:35 contrib
drwxr-xr-x. 2 root root 6 11月 20 11:02 data
drwxr-xr-x. 2 root root 4096 8月 21 18:35 dist-maven
drwxr-xr-x. 6 root root 4096 8月 21 18:35 docs
-rw-r--r--. 1 root root 1953 2月 6 2016 ivysettings.xml
-rw-r--r--. 1 root root 3498 2月 6 2016 ivy.xml
drwxr-xr-x. 4 root root 266 8月 21 18:35 lib
-rw-r--r--. 1 root root 11938 2月 6 2016 LICENSE.txt
drwxr-xr-x. 2 root root 6 11月 20 11:02 logs
-rw-r--r--. 1 root root 171 2月 6 2016 NOTICE.txt
-rw-r--r--. 1 root root 1770 2月 6 2016 README_packaging.txt
-rw-r--r--. 1 root root 1585 2月 6 2016 README.txt
drwxr-xr-x. 5 root root 47 8月 21 18:35 recipes
drwxr-xr-x. 8 root root 191 8月 21 18:35 src
-rw-r--r--. 1 root root 1360961 2月 6 2016 zookeeper-3.4.8.jar
-rw-r--r--. 1 root root 819 2月 6 2016 zookeeper-3.4.8.jar.asc
-rw-r--r--. 1 root root 33 2月 6 2016 zookeeper-3.4.8.jar.md5
-rw-r--r--. 1 root root 41 2月 6 2016 zookeeper-3.4.8.jar.sha1
[root@localhost zookeeper]# cd bin
[root@localhost bin]# ll
总用量 1508
-rw-r--r--. 1 root root 232 2月 6 2016 README.txt
-rw-r--r--. 1 root root 1937 2月 6 2016 zkCleanup.sh
-rw-r--r--. 1 root root 1056 2月 6 2016 zkCli.cmd
-rw-r--r--. 1 root root 1534 2月 6 2016 zkCli.sh
-rw-r--r--. 1 root root 1628 2月 6 2016 zkEnv.cmd
-rw-r--r--. 1 root root 2696 2月 6 2016 zkEnv.sh
-rw-r--r--. 1 root root 1089 2月 6 2016 zkServer.cmd
-rw-r--r--. 1 root root 6773 2月 6 2016 zkServer.sh
-rw-r--r--. 1 root root 1504321 1月 10 2018 zookeeper.out
[root@localhost bin]# chmod -R 777 ../bin
[root@localhost bin]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/app/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost bin]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/app/zookeeper/bin/../conf/zoo.cfg
Mode: standalone
[root@localhost bin]# zkCli.sh
Connecting to localhost:2181
2019-11-20 11:13:35,260 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.8--1, built on 02/06/2016 03:18 GMT
2019-11-20 11:13:35,264 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost
2019-11-20 11:13:35,264 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_144
2019-11-20 11:13:35,266 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2019-11-20 11:13:35,267 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/local/java/jdk1.8.0_144/jre
2019-11-20 11:13:35,267 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/home/app/zookeeper/bin/../build/classes:/home/app/zookeeper/bin/../build/lib/*.jar:/home/app/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/app/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/home/app/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/home/app/zookeeper/bin/../lib/log4j-1.2.16.jar:/home/app/zookeeper/bin/../lib/jline-0.9.94.jar:/home/app/zookeeper/bin/../zookeeper-3.4.8.jar:/home/app/zookeeper/bin/../src/java/lib/*.jar:/home/app/zookeeper/bin/../conf:.:/usr/local/java/jdk1.8.0_144/lib:/usr/local/java/jdk1.8.0_144/jre/lib
2019-11-20 11:13:35,269 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2019-11-20 11:13:35,270 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2019-11-20 11:13:35,270 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
2019-11-20 11:13:35,270 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2019-11-20 11:13:35,270 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2019-11-20 11:13:35,270 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-957.el7.x86_64
2019-11-20 11:13:35,270 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2019-11-20 11:13:35,270 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2019-11-20 11:13:35,270 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/home/app/zookeeper/bin
2019-11-20 11:13:35,272 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@67424e82
Welcome to ZooKeeper!
2019-11-20 11:13:35,296 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2019-11-20 11:13:35,377 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2019-11-20 11:13:35,399 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x16e86ccb1300000, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] [root@localhost bin]# ps -ef|grep zookeeper
root 11688 1 0 11:13 pts/2 00:00:01 /usr/local/java/jdk1.8.0_144/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /home/app/zookeeper/bin/../build/classes:/home/app/zookeeper/bin/../build/lib/*.jar:/home/app/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/app/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/home/app/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/home/app/zookeeper/bin/../lib/log4j-1.2.16.jar:/home/app/zookeeper/bin/../lib/jline-0.9.94.jar:/home/app/zookeeper/bin/../zookeeper-3.4.8.jar:/home/app/zookeeper/bin/../src/java/lib/*.jar:/home/app/zookeeper/bin/../conf:.:/usr/local/java/jdk1.8.0_144/lib:/usr/local/java/jdk1.8.0_144/jre/lib -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /home/app/zookeeper/bin/../conf/zoo.cfg
root 12017 9641 0 11:18 pts/2 00:00:00 grep --color=auto zookeeper
[root@localhost bin]#