Ubuntu18.04.1 Zookeeper配置安装

  1. Zookeeper3.4.13 下载链接
  2. tar -zxvf zookeeper-3.4.13.tar.gz
  3. 可执行文件都在bin/目录下,配置都在conf/目录下
  4. view the config file conf/zoo_sample.cfg the simplest config
# The number of milliseconds of each tick
#ZK中的一个时间单元。ZK中所有时间都是以这个时间单元为基础,进行整数倍配置的。例如,session的最小超时时间是2*tickTime。
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
#Follower在启动过程中,会从Leader同步所有最新数据,然后确定自己能够对外服务的起始状态。Leader允许F在 initLimit 时间
#内完成这个工作。通常情况下,我们不用太在意这个参数的设置。如果ZK集群的数据量确实很大了,F在启动的时候,从
#Leader上同步数据的时间也会相应变长,因此在这种情况下,有必要适当调大这个参数了。(No Java system property)
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
#在运行过程中,Leader负责与ZK集群中所有机器进行通信,例如通过一些心跳检测机制,来检测机器的存活状态。如果L发出心
#跳包在syncLimit之后,还没有从F那里收到响应,那么就认为这个F已经不在线了。注意:不要把这个参数设置得过大,否则可
#能会掩盖一些问题。(No Java system property)
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
#事务日志输出目录。尽量给事务日志的输出配置单独的磁盘或是挂载点,这将极大的提升ZK性能。  
#(No Java system property)
dataDir=/tmp/zookeeper
# the port at which the clients will connect
#客户端连接server的端口,即对外服务端口,一般设置为2181吧。
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
  1. cp zoo_sample.cfg zoo.cfg
  2. error
/zookeeper-3.4.13/bin# sh zkCli.sh -server 127.0.0.1:2181
zkCli.sh: 81: /home/jackray/Public/soft/zookeeper-3.4.13/bin/zkEnv.sh: Syntax error: "(" unexpected (expecting "fi")

错误原因:
 Ubuntu的默认shell为dash
解决方法:
  将dash 改为 bash
view

zookeeper-3.4.13/bin# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 11月  4 12:03 /bin/sh -> dash

modify

root@PC:~$ ln -sf bash /bin/sh

review

zookeeper-3.4.13/bin# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 11月 21 18:01 /bin/sh -> bash
  1. sh zkCli.sh -server 127.0.0.1:2181
  2. error
2018-11-21 18:04:57,992 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1166] - Socket error occurred: localhost/127.0.0.1:2181: Connection refused
2018-11-21 18:04:59,093 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
  1. sudo netstat -anp | grep 2181
    the port is not used by other app but…
/zookeeper-3.4.13/bin#  sudo netstat -anp | grep 2181
/zookeeper-3.4.13/bin# 
  1. start =_=
/zookeeper-3.4.13/bin# sh zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/jackray/Public/soft/zookeeper-3.4.13/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
  1. status
/zookeeper-3.4.13/bin# sh zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/jackray/Public/soft/zookeeper-3.4.13/bin/../conf/zoo.cfg
Mode: standalone
  1. restart
bin/zkServer.sh restart

config link
zoo.cfd link
error link

猜你喜欢

转载自blog.csdn.net/ppwwp/article/details/84326545