linux下面Zookeeper的单机模式(standalone)

1、下载 zk下载地址 http://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/

我用的是http://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.3.6/

2、下载至本地 然后sz 从本地上传到服务器

sz 

ls

tar xvf zookeeper-3.3.6.tar.gz

3、解压后开始配置Zookeeper,进入到配置文件的目录

cd  zookeeper-3.3.6/conf/ 

将目录下面的 zoo_sample.cfg修改为zoo.cfg,mv zoo_sample.cfg  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 dataDir=/tmp/zookeeper  
11 # the port at which the clients will connect  
12 clientPort=2181  

这些信息都不用去改!

4、启动Zookeeper服务器进程

cd  zookeeper-3.3.6/  
cd bin/
ls
$ ./zkCli.sh -server 127.0.0.1:2181

执行完毕是这样:
Connecting to 127.0.0.1:2181
2017-09-21 23:20:45,871 - INFO  [main:Environment@97] - Client environment:zookeeper.version=3.3.6-1366786, built on 07/29/2012 06:22 GMT
2017-09-21 23:20:45,873 - INFO  [main:Environment@97] - Client environment:host.name=izwz9ejuib213391pbtkhiz
2017-09-21 23:20:45,873 - INFO  [main:Environment@97] - Client environment:java.version=1.8.0_141
2017-09-21 23:20:45,874 - INFO  [main:Environment@97] - Client environment:java.vendor=Oracle Corporation
2017-09-21 23:20:45,874 - INFO  [main:Environment@97] - Client environment:java.home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64/jre
2017-09-21 23:20:45,874 - INFO  [main:Environment@97] - Client environment:java.class.path=/home/sg/ruanjian/zookeeper-3.3.6/bin/../build/classes:/home/sg/ruanjian/zookeeper-3.3.6/bin/../build/lib/*.jar:/home/sg/ruanjian/zookeeper-3.3.6/bin/../zookeeper-3.3.6.jar:/home/sg/ruanjian/zookeeper-3.3.6/bin/../lib/log4j-1.2.15.jar:/home/sg/ruanjian/zookeeper-3.3.6/bin/../lib/jline-0.9.94.jar:/home/sg/ruanjian/zookeeper-3.3.6/bin/../src/java/lib/*.jar:/home/sg/ruanjian/zookeeper-3.3.6/bin/../conf:.:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64/lib/dt.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64/lib/tools.jar
2017-09-21 23:20:45,874 - INFO  [main:Environment@97] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2017-09-21 23:20:45,874 - INFO  [main:Environment@97] - Client environment:java.io.tmpdir=/tmp
2017-09-21 23:20:45,874 - INFO  [main:Environment@97] - Client environment:java.compiler=<NA>
2017-09-21 23:20:45,874 - INFO  [main:Environment@97] - Client environment:os.name=Linux
2017-09-21 23:20:45,875 - INFO  [main:Environment@97] - Client environment:os.arch=amd64
2017-09-21 23:20:45,875 - INFO  [main:Environment@97] - Client environment:os.version=3.10.0-514.26.2.el7.x86_64
2017-09-21 23:20:45,875 - INFO  [main:Environment@97] - Client environment:user.name=sg
2017-09-21 23:20:45,875 - INFO  [main:Environment@97] - Client environment:user.home=/home/sg
2017-09-21 23:20:45,875 - INFO  [main:Environment@97] - Client environment:user.dir=/home/sg/ruanjian/zookeeper-3.3.6/bin
2017-09-21 23:20:45,876 - INFO  [main:ZooKeeper@379] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@433c675d
2017-09-21 23:20:45,895 - INFO  [main-SendThread():ClientCnxn$SendThread@1058] - Opening socket connection to server /127.0.0.1:2181
Welcome to ZooKeeper!
JLine support is enabled
2017-09-21 23:20:46,010 - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@947] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2017-09-21 23:20:46,021 - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@736] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x15ea5017c590001, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: 127.0.0.1:2181(CONNECTED) 0] 

Zookeeper Standalone模式就配置完成了

集群的模式 我下次再学习下 然后记录上来!

 

posted @ 2017-09-21 23:35  彩笔杀手  阅读(1226)  评论(0编辑  收藏  举报