1. 程式人生 > >linux下面Zookeeper的單機模式(standalone)

linux下面Zookeeper的單機模式(standalone)

rar oracl time nts .com ima sock data png

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:[email protected]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:[email protected]97] - Client environment:host.name=izwz9ejuib213391pbtkhiz 2017-09-21 23:20:45,873 - INFO [main:[email protected]97] - Client environment:java.version=1.8.0_141 2017-09-21 23:20:45,874 - INFO [main:[email protected]97] - Client environment:java.vendor=Oracle Corporation 2017-09-21 23:20:45,874 - INFO [main:[email protected]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:[email protected]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:[email protected]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:[email protected]97] - Client environment:java.io.tmpdir=/tmp 2017-09-21 23:20:45,874 - INFO [main:[email protected]97] - Client environment:java.compiler=<NA> 2017-09-21 23:20:45,874 - INFO [main:[email protected]97] - Client environment:os.name=Linux 2017-09-21 23:20:45,875 - INFO [main:[email protected]97] - Client environment:os.arch=amd64 2017-09-21 23:20:45,875 - INFO [main:[email protected]97] - Client environment:os.version=3.10.0-514.26.2.el7.x86_64 2017-09-21 23:20:45,875 - INFO [main:[email protected]97] - Client environment:user.name=sg 2017-09-21 23:20:45,875 - INFO [main:[email protected]97] - Client environment:user.home=/home/sg 2017-09-21 23:20:45,875 - INFO [main:[email protected]97] - Client environment:user.dir=/home/sg/ruanjian/zookeeper-3.3.6/bin 2017-09-21 23:20:45,876 - INFO [main:[email protected]379] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=[email protected] 2017-09-21 23:20:45,895 - INFO [main-SendThread():[email protected]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):[email protected]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):[email protected]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模式就配置完成了

集群的模式 我下次再學習下 然後記錄上來!

linux下面Zookeeper的單機模式(standalone)