在mac OSX中安裝啟動zookeeper(採用brew安裝方式)
阿新 • • 發佈:2019-02-18
前言
專案需要,所以,在mac OSX中安裝了一下zookeeper。
安裝
- 檢視
brew info zookeeper
$ brew info zookeeper
zookeeper: stable 3.4.12 (bottled), HEAD
Centralized server for distributed coordination of services
https://zookeeper.apache.org/
- 安裝
brew install zookeeper
$ brew install zookeeper
==> Downloading https://homebrew.bintray.com/bottles/zookeeper-3.4 .12.high_sierr
######################################################################## 100.0%
==> Pouring zookeeper-3.4.12.high_sierra.bottle.tar.gz
==> Caveats
To have launchd start zookeeper now and restart at login:
brew services start zookeeper
Or, if you don't want/need a background service you can just run:
zkServer start
- 安裝後,在
/usr/local/etc/zookeeper/
已經有了預設配置
$ ls /usr/local/etc/zookeeper/
- 檢視預設配置檔案
$ less -N /usr/local/etc/zookeeper/zoo.cfg
預設內容如下:
$less -N /usr/local/etc/zookeeper/zoo.cfg
1 # The number of milliseconds of each tick
2 tickTime=2000
3 # The number of ticks that the initial
4 # synchronization phase can take
5 initLimit=10
6 # The number of ticks that can pass between
7 # sending a request and getting an acknowledgement
8 syncLimit=5
9 # the directory where the snapshot is stored.
10 # do not use /tmp for storage, /tmp here is just
11 # example sakes.
12 dataDir=/usr/local/var/run/zookeeper/data
13 # the port at which the clients will connect
14 clientPort=2181
15 # the maximum number of client connections.
16 # increase this if you need to handle more clients
17 #maxClientCnxns=60
18 #
19 # Be sure to read the maintenance section of the
20 # administrator guide before turning on autopurge.
21 #
22 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
23 #
24 # The number of snapshots to retain in dataDir
25 #autopurge.snapRetainCount=3
26 # Purge task interval in hours
27 # Set to "0" to disable auto purge feature
28 #autopurge.purgeInterval=1
啟動服務
執行命令zkServer
$ zkServer
ZooKeeper JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Usage: ./zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}
$ zkServer status
ZooKeeper JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Error contacting service. It is probably not running.
$ zkServer start
ZooKeeper JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Starting zookeeper ... STARTED
檢視zookeeper執行及狀態
安裝後,可以看到zookeeper提供了zkCli等工具進行.
$ zkServer status
ZooKeeper JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Error contacting service. It is probably not running.
192:~ maerfeifei$ zkServer start
ZooKeeper JMX enabled by default
Using config: /usr/local/etc/zookeeper/zoo.cfg
Starting zookeeper ... STARTED
192:~ maerfeifei$ zkCli
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is enabled
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0]