liunx 下安装Zookeeper

前言:Zookeeper是一个协调服务,可以用它来作为配置维护、名字服务、分布式部署;

1、下载zookeeper,并解压
wget http://mirrors.shuosc.org/apache/zookeeper/stable/zookeeper-3.4.10.tar.gz
2、做软链接:
ln -s /home/xuan/soft/zookeeper-3.4.10 /home/data/zookeeper

3、进入到conf目录,将zoo_samle.cfg重名为为zoo.cfg
mv zoo_samle.cfg zoo.cfg

4、编辑配置文件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=/tmp/zookeeper
dataDir=/usr/zookeeper 
dataLogDir=/usr/zookeeper/log
# the port at which the clients will connect
# clientPort=2181
clientPort=2181
server.1=192.168.1.103:2888:3888
# 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

5、设置环境变量

[root@localhost zookeeper]# export ZOOKEEPER_INSTALL=/home/data/zookeeper
[root@localhost zookeeper]# export PATH=$PATH:$ZOOKEEPER_INSTALL/bin

6、启动zookeeper

[root@localhost bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/data/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost bin]#

7、测试zookeeper

[root@localhost bin]# ./zkCli.sh -server 192.168.1.103:2181
Connecting to 192.168.1.103:2181
2017-11-07 07:28:07,640 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
2017-11-07 07:28:07,642 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=localhost
2017-11-07 07:28:07,642 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.7.0_79
2017-11-07 07:28:07,644 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2017-11-07 07:28:07,644 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/home/xuan/soft/jdk1.7.0_79/jre
2017-11-07 07:28:07,644 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/home/data/zookeeper/bin/../build/classes:/home/data/zookeeper/bin/../build/lib/*.jar:/home/data/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/data/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/home/data/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/home/data/zookeeper/bin/../lib/log4j-1.2.16.jar:/home/data/zookeeper/bin/../lib/jline-0.9.94.jar:/home/data/zookeeper/bin/../zookeeper-3.4.10.jar:/home/data/zookeeper/bin/../src/java/lib/*.jar:/home/data/zookeeper/bin/../conf:.:/home/data/java/lib/dt.jar:/home/data/java/lib/tools.jar
2017-11-07 07:28:07,644 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2017-11-07 07:28:07,644 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2017-11-07 07:28:07,644 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2017-11-07 07:28:07,644 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2017-11-07 07:28:07,644 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2017-11-07 07:28:07,644 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-327.el7.x86_64
2017-11-07 07:28:07,645 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2017-11-07 07:28:07,645 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2017-11-07 07:28:07,645 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/home/xuan/soft/zookeeper-3.4.10/bin
2017-11-07 07:28:07,646 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=192.168.1.103:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@56606032
Welcome to ZooKeeper!
2017-11-07 07:28:07,679 [myid:] - INFO  [main-SendThread(192.168.1.103:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server 192.168.1.103/192.168.1.103:2181. Will not attempt to authenticate using SASL (unknown error)
2017-11-07 07:28:07,684 [myid:] - INFO  [main-SendThread(192.168.1.103:2181):ClientCnxn$SendThread@876] - Socket connection established to 192.168.1.103/192.168.1.103:2181, initiating session
JLine support is enabled
2017-11-07 07:28:07,707 [myid:] - INFO  [main-SendThread(192.168.1.103:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server 192.168.1.103/192.168.1.103:2181, sessionid = 0x15f9712b8590000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值