ZooKeeper-瀹夎
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ZooKeeper-瀹夎相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/apach' title='apach'>apach htm ini rpo tac ror pid add
涓嬭浇
涓嬭浇鍦板潃 zookeeper锛屽缓璁笅杞?bin 缁撳熬鐨則ar鍖呫€?/p>
鍦?readme.md 涓彲浠ョ湅鍒?/p>
apache-zookeeper-[version].tar.gz Contains all the source files which can be built by running: mvn clean install To generate an aggregated apidocs for zookeeper-server and zookeeper-jute: mvn javadoc:aggregate (generated files will be at target/site/apidocs) apache-zookeeper-[version]-bin.tar.gz Contains all the jar files required to run ZooKeeper Full documentation can also be found in the docs folder
涓嶄互 bin 缁撳熬鐨勯渶瑕?nbsp;mvn clean install锛屾垜璇曡繃杩欎釜 tar 鍖咃紝楹荤儲...
鍗曟満瀹夎
瑙e帇 tar 鍖?/p>
杩涘叆 zookeeper 鐩綍锛屽缓绔?data 鏂囦欢澶?/p>
杩涘叆conf锛屼慨鏀?span style="background-color: #00ffff;">閰嶇疆鏂囦欢
鍒濆鐨勯厤缃枃浠舵槸 zoo_sample.cfg锛寊ookeeper 榛樿浣跨敤 zoo.cfg锛屽彲浠ユ柊寤轰竴涓?zoo.cfg锛屼篃鍙互鎶?nbsp;zoo_sample cp 鎴?zoo
tickTime=2000 initLimit=10 syncLimit=5 dataDir=/usr/local/kafka/apache-zookeeper-3.5.5-bin/data clientPort=2181
tickTime锛歾k 鏈嶅姟鍣ㄤ箣闂存垨鑰呭鎴风涓庢湇鍔″櫒涔嬮棿蹇冭烦鐨勬椂闂撮棿闅旓紝姣
initLimit锛?/p>
dataDir锛歾k 鏁版嵁瀛樺偍璺緞
clientPort锛歾k 鏈嶅姟鍣ㄧ洃鍚殑绔彛
閰嶇疆瀹屾垚锛屽氨鍙互鍚姩鏈嶅姟鍣?/span>浜嗭紝姝e父鎯呭喌涓嬭緭鍑哄涓?/p>
浣嗘槸涓婇潰骞朵笉鑳借鏄庢湇鍔″櫒宸茬粡鍚姩锛屽彲浠?span style="background-color: #00ffff;">鏌ョ湅鏈嶅姟鍣ㄧ姸鎬?/span> 鎴戜滑鍙戠幇骞舵湭鎴愬姛鍚姩銆?/p>
姝ゆ椂锛岄渶瑕佹煡鐪嬫棩蹇?/p>
鎵撳紑鏃ュ織锛屽彲浠ョ湅鍒?Error锛屾彁绀?杩炰笉涓?8080 绔彛锛屾垜鎯冲埌鏄笉鏄?8080 琚崰鐢ㄤ簡锛屾煡浜嗕竴涓嬫灉鐒?/p>
缁撴潫璇ヨ繘绋嬶紝閲嶆柊鍚姩鏈嶅姟鍣紝OK浜?/p>
杈撳嚭濡備笂浠h〃鍚姩鎴愬姛銆?/p>
鍋滄鏈嶅姟鍣?/span> 鎬濊€?/span> zookeeper 鍦ㄥ摢閲岀敤鍒?8080 绔彛浜嗗憿锛熷湪 AdminServe 涓壘鍒颁簡杩欎釜閰嶇疆 瑙e喅杩欎釜闂鐨勬柟娉曟湁涓夌锛?/p>
1. 淇敼绔彛 涓ょ鏂瑰紡锛氬惎鍔ㄦ椂澧炲姞閰嶇疆椤?nbsp; -Dzookeeper.admin.serverPort=浣犵殑绔彛鍙凤紱鍦?zoo.cfg 涓鍔犻厤缃?nbsp;admin.serverPort=娌℃湁琚崰鐢ㄧ殑绔彛鍙?/span> 2. 鍒犻櫎 jetty 3. 鍋滅敤杩欎釜鏈嶅姟锛屽湪鍚姩鏃跺鍔犻厤缃」 -Dzookeeper.admin.enableServer=false 鏈嶅姟鍣ㄥ惎鍔ㄥ悗锛屽氨鍙互鍚姩瀹㈡埛绔?/span>杩涚▼娴嬭瘯浜?/p>
鍑虹幇濡備笅鐣岄潰 杈撳叆 help 鏌ョ湅鍛戒护 鍒涘缓鑺傜偣锛岃祴鍊硷紝鍙栧€硷紝鍒犻櫎锛屾煡鐪嬫牴鑺傜偣 鐢变簬鍙湁涓€鍙版湇鍔″櫒锛屾湰娆″畨瑁呬吉鍒嗗竷寮忛泦缇わ紝涓庡垎甯冨紡瀹夎杩囩▼闆峰悓銆?/p>
浼泦缇?/span>鏄寚鐢ㄤ竴鍙版湇鍔″櫒鐨勫涓鍙fā鎷熷鍙版湇鍔″櫒锛岀敤澶氫釜閰嶇疆鏂囦欢鍚姩澶氫釜 zookeeper 瀹炰緥銆?/p>
涓庨泦缇ゅ畨瑁?span style="background-color: #00ffff;">涓嶅悓鐐?/span>锛?/p>
1. 鐢变簬鍦ㄤ竴鍙版湇鍔″櫒涓婏紝zookeeper 鏈嶅姟鍣ㄧ洃鍚殑绔彛涓嶈兘鐩稿悓锛屽嵆 clientPort 涓嶇浉鍚岋紝鑰岄泦缇ゅ彲浠ョ浉鍚?/p>
2. 鏁版嵁瀛樺偍璺緞涓嶅悓锛屽嵆 dataDir 涓嶇浉鍚岋紱涔熸湁蹇呰鎶?dataLogDir 鍚姩鏃ュ織鍒嗗紑瀛樺偍锛屽綋鐒?log 璺緞鐩稿悓涔熷彲浠?/p>
3. server.x 涓?myid 锛歴erver.x 涓殑 x 绛変簬 myid 鏂囦欢閲岀殑鏁板瓧銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆€銆愯繖涓や釜鍦ㄥ崟涓湇鍔″櫒瀹夎涓槸娌℃湁鐨勩€?/p>
銆€銆€// myid 鏂囦欢涓彧鍐欎簡涓€涓暟瀛楋紝浠h〃璇ヨ妭鐐瑰湪闆嗙兢涓殑瑙掕壊 id锛宮yid 鏂囦欢闇€瑕佹墜鍔ㄥ垱寤恒€€ 銆€銆€// server.x 瀵瑰簲鏈嶅姟鍣?IP 鍜岀鍙o紝鍚屼竴鍙版湇鍔″櫒涓婇渶瑕佽繛涓や釜绔彛锛屼笖涓嶅悓 server 绔彛涓嶈兘鐩稿悓 瀹夎杩囩▼ 绗竴姝ワ紝鏂板缓3涓厤缃枃浠?zoo1.cfg锛?zoo2.cfg锛?zoo3.cfg zoo1.cfg 閰嶇疆濡備笅 鍏朵腑3涓厤缃枃浠剁殑 dataDir 涓嶈兘鐩稿悓锛宒ataLogDir 涔熶笉瑕佺浉鍚岋紱 鍚庨潰鐨?server.x 蹇呴』鍐欙紝3涓厤缃枃浠朵竴鏍凤紱 绗簩姝ワ紝寤虹珛 dataDir 鍜?nbsp;dataLogDir 瀵瑰簲鐨勮矾寰?/p>
绗笁姝?/span>锛屽湪姣忎釜 dataDir 涓嬪垱寤?myid 鏂囦欢锛屽苟鍐欏叆涓€涓暟瀛楋紝瀵瑰簲 server.x 涓殑 x銆€銆€銆€銆€銆愭敞鎰忓繀椤绘妸姣忎釜鏈嶅姟鐨?myid 閮藉厛鍐欏ソ锛屼笉鑳藉啓涓€涓惎鍔ㄤ竴涓€?/p>
绗洓姝ワ紝鍚姩 zookeeper 鏈嶅姟锛屾瘡涓湇鍔℃寚瀹氫笉鍚岀殑閰嶇疆鏂囦欢 鍚姩绗竴涓?zookeeper 鏈嶅姟鏃讹紝鍙戠敓閿欒浜嗭紝杩欏叾瀹炴槸姝e父鐜拌薄 鍥犱负 zookeeper 鏈嶅姟鐨勬瘡涓疄渚嬮兘鎷ユ湁鍏ㄥ眬閰嶇疆淇℃伅锛屼粬浠湪鍚姩鏃朵細闅忔椂闅忓湴閫変妇 leader锛屼篃灏辨槸 瑕佷笌鍏朵粬 zookeeper 瀹炰緥杩涜閫氫俊锛岃€屾鏃跺叾浠栫殑 zookeeper 鏈嶅姟杩樻病鍚姩锛岃嚜鐒舵棤娉曢€氫俊锛屾晠鎶ラ敊 姝ゆ椂鎴戜滑蹇界暐姝ら敊璇紝鐩存帴鎶?3 涓湇鍔″叏閮ㄥ惎鍔?/p>
鐒跺悗妫€鏌ョ姸鎬侊紝鍙戠幇涓€鍒囨甯镐簡銆?/p>
骞朵笖鏄剧ず浜?涓讳粠鍏崇郴銆?/p>
鍙傝€冭祫鏂欙細 https://blog.csdn.net/qq_27868061/article/details/91383759銆€銆€zookeeper3.5.5瀹夎 https://www.jianshu.com/p/f6c96b2d4b6a銆€銆€centos7 zookeeper3.5.5 瀹夎 https://www.cnblogs.com/crazylqy/p/7119030.html銆€銆€瀹夎zookeeper锛堝崟鏈猴紝浼泦缇わ級 https://www.cnblogs.com/songfayuan/articles/7290175.html銆€銆€ZooKeeper鍚姩鍗犵敤8080绔彛 以上是关于ZooKeeper-瀹夎的主要内容,如果未能解决你的问题,请参考以下文章 Zookeeper -- 初识ZookeeperZookeeper的安装和配置Zookeeper命令操作(Zookeeper数据模型 Zookeeper服务端 / 客户端常用命令)[root@localhost apache-zookeeper-3.5.5-bin]# bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/kafka/apache-zookeeper-3.5.5-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost apache-zookeeper-3.5.5-bin]# bin/zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/kafka/apache-zookeeper-3.5.5-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Error contacting service. It is probably not running.
netstat -anp | grep 8080
[root@localhost apache-zookeeper-3.5.5-bin]# bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/kafka/apache-zookeeper-3.5.5-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost apache-zookeeper-3.5.5-bin]# bin/zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/kafka/apache-zookeeper-3.5.5-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone[root@localhost apache-zookeeper-3.5.5-bin]# bin/zkServer.sh stop
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/kafka/apache-zookeeper-3.5.5-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
<ul>
<li><p><em>admin.enableServer</em> : (Java system property: <strong>zookeeper.admin.enableServer</strong>) Set to "false" to disable the AdminServer. By default the AdminServer is enabled.</p></li>
<li><p><em>admin.serverAddress</em> : (Java system property: <strong>zookeeper.admin.serverAddress</strong>) The address the embedded Jetty server listens on. Defaults to 0.0.0.0.</p></li>
<li><p><em>admin.serverPort</em> : (Java system property: <strong>zookeeper.admin.serverPort</strong>) The port the embedded Jetty server listens on. Defaults to 8080.</p></li>
<li><p><em>admin.idleTimeout</em> : (Java system property: <strong>zookeeper.admin.idleTimeout</strong>) Set the maximum idle time in milliseconds that a connection can wait before sending or receiving data. Defaults to 30000 ms.</p></li>
<li><p><em>admin.commandURL</em> : (Java system property: <strong>zookeeper.admin.commandURL</strong>) The URL for listing and issuing commands relative to the root URL. Defaults to "/commands".</p></li>
</ul>
[root@localhost apache-zookeeper-3.5.5-bin]# bin/zkCli.sh
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0]
[zk: localhost:2181(CONNECTED) 0] help
ZooKeeper -server host:port cmd args
addauth scheme auth
close
config [-c] [-w] [-s]
connect host:port
create [-s] [-e] [-c] [-t ttl] path [data] [acl]
delete [-v version] path
deleteall path
delquota [-n|-b] path
get [-s] [-w] path
getAcl [-s] path
history
listquota path
ls [-s] [-w] [-R] path
ls2 path [watch]
printwatches on|off
quit
reconfig [-s] [-v version] [[-file path] | [-members serverID=host:port1:port2;port3[,...]*]] | [-add serverId=host:port1:port2;port3[,...]]* [-remove serverId[,...]*]
redo cmdno
removewatches path [-c|-d|-a] [-l]
rmr path
set [-s] [-v version] path data
setAcl [-s] [-v version] [-R] path acl
setquota -n|-b val path
stat [-w] path
sync path
[zk: localhost:2181(CONNECTED) 17] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 18] create /mykey1
Created /mykey1
[zk: localhost:2181(CONNECTED) 19] create /mykey2
Created /mykey2
[zk: localhost:2181(CONNECTED) 20] set /mykey1 3
[zk: localhost:2181(CONNECTED) 21] get /mykey1
3
[zk: localhost:2181(CONNECTED) 22] ls /
[mykey1, mykey2, zookeeper]
[zk: localhost:2181(CONNECTED) 23] delete /mykey1
[zk: localhost:2181(CONNECTED) 24] ls /
[mykey2, zookeeper]
闆嗙兢瀹夎
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/zk1/data
clientPort=2182
dataLogDir=/usr/local/zookeeper/zk1/logs
server.1=localhost:2287:3387
server.2=localhost:2288:3388
server.3=localhost:2289:3389
[root@localhost apache-zookeeper-3.5.5-bin]# bin/zkServer.sh start conf/zoo1.cfg
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: conf/zoo1.cfg
Starting zookeeper ... STARTED
[root@localhost apache-zookeeper-3.5.5-bin]# bin/zkServer.sh status conf/zoo1.cfg
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: conf/zoo1.cfg
Client port found: 2191. Client address: localhost.
Error contacting service. It is probably not running.[root@localhost apache-zookeeper-3.5.5-bin]# bin/zkServer.sh status conf/zoo1.cfg
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: conf/zoo1.cfg
Client port found: 2191. Client address: localhost.
Mode: follower
[root@localhost apache-zookeeper-3.5.5-bin]# bin/zkServer.sh status conf/zoo2.cfg
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: conf/zoo2.cfg
Client port found: 2192. Client address: localhost.
Mode: leader