ุฃูุชุฑุญ ุฃู ุชุชุนุฑู ุนูู ูู ุดูุฑุฉ ู
ุญุงุถุฑุฉ "Hadoop. ZooKeeper" ู
ู ุณูุณูุฉ "ุทุฑู ุงูู
ุนุงูุฌุฉ ุงูู
ูุฒุนุฉ ููู
ูุงุช ูุจูุฑุฉ ู
ู ุงูุจูุงูุงุช ูู Hadoop"
ู
ุง ูู ZooKeeper ุ ู
ูุงูู ูู ุงููุธุงู
ุงูุจูุฆู Hadoop. ุงูุญูููุฉ ุญูู ุงูุญูุณุจุฉ ุงูู
ูุฒุนุฉ. ู
ุฎุทุท ูุธุงู
ุชูุฒูุน ููุงุณู. ุชุนููุฏ ุชูุณูู ุงููุธู
ุงูู
ูุฒุนุฉ. ู
ุดุงูู ุงูุชูุณูู ุงููู
ูุฐุฌูุฉ. ุงูู
ุจุงุฏุฆ ุงูู
ุฌุณุฏุฉ ูู ุชุตู
ูู
ZooKeeper. ูู
ูุฐุฌ ุจูุงูุงุช ZooKeeper. ุฃุนูุงู
Znode. ุงูุฌูุณุงุช. ูุงุฌูุฉ ุจุฑู
ุฌุฉ ุชุทุจููุงุช ุงูุนู
ูู ุงูุจุฏุงุฆููู (ุงูุชูููู ุ ุนุถููุฉ ุงูู
ุฌู
ูุนุฉ ุ ุฃููุงู ุจุณูุทุฉ ุ ุงูุชุฎุงุจ ุงููุงุฆุฏ ุ ุงูููู ุจุฏูู ุชุฃุซูุฑ ุงููุทูุน). ZooKeeper ุงูุนู
ุงุฑุฉ. ZooKeeper DB. ZAB. ู
ุนุงูุฌ ุงูุทูุจ.
![](https://habrastorage.org/webt/d6/nt/gh/d6ntghuoqpmwijijxq6pqpok3ja.png)
ุงูููู
ุฏุนููุง ูุชุญุฏุซ ุนู ZooKeeper. ูุฐุง ุงูุดูุก ู
ููุฏ ุฌุฏุง ุฅูู ุ ู
ุซู ุฃู ู
ูุชุฌ Apache Hadoop ุ ูุฏูู ุดุนุงุฑ. ูุตูุฑ ุฑุฌู.
, , , . . - - . . ZooKeeper โ , . , , .
, , . , MapReduce , , . , , . MapReduce - , . MapReduce , , , . , ZooKeeper.
, Hadoop, Yahoo! Apache. HBase. JIRA HBase, , - , . . . ZooKeeper, , , , . , Hadoop. , , , .
![](https://habrastorage.org/webt/dk/xj/fr/dkxjfrpa7_fxoqk1auvhpbgnsp8.png)
, - , . , , . , , ZooKeeper, . . โ , . HDFS, MapReduce , . , ZooKeeper. - , .
![](https://habrastorage.org/webt/bn/ix/cd/bnixcd_ckkmi6n1r3bbf72aov2u.png)
? , , , . , , , , , , - , . TCP, , . TCP . . - . . , , . , - , , . .
, , latency. , . Latency โ - , , .
. โ . -, , , . , . . . , , . .
. , - . , - Hadoop. . , . , - , , . - . .
, , -, . , , cat . โ Vim . , . Vim , , , - . , , .
![](https://habrastorage.org/webt/pf/su/wv/pfsuwvkmov1vq4btyqzy6hb5xxa.png)
, .
, , , . โ ? , . , ? , , - . - , , - , - . , -, - , ?
, . , โ , - .
, , , - , โ ? - race condition, , , - ? - . .
โ . , , , .
, , , , . , , , . - , , , . , , . . . . - , , .
ZooKeeper. โ , , , .
![](https://habrastorage.org/webt/pa/sf/zu/pasfzusbu-gxo_oxofbricmwouy.png)
, . , โ HDFS, HBase. -, , slave-. , , , .
![](https://habrastorage.org/webt/yc/pb/me/ycpbmexvjmnz7vuyrozluhpoly8.png)
โ Coordination Service, . . , - backup stanby , . , . backup. - , , backup. Coordination Service. , .
![](https://habrastorage.org/webt/8v/ol/le/8volleu6wy80szuhxqf1b3hhenw.png)
โ , . , . - , . , - slaves, , , . .
![](https://habrastorage.org/webt/6z/jz/2t/6zjz2tjemw2dgjdzxxarmfl6opc.png)
, , -slaves, . , . , Cassandra, .
, . .
![](https://habrastorage.org/webt/yc/pb/me/ycpbmexvjmnz7vuyrozluhpoly8.png)
- , , , , . โ , , , . - , . . .
![](https://habrastorage.org/webt/6z/jz/2t/6zjz2tjemw2dgjdzxxarmfl6opc.png)
(), , , .
![](https://habrastorage.org/webt/qj/bd/_t/qjbd_tnxhumozic_ueyyvvp4xps.png)
โ partial failures. , , - , , , , , . . .
, . โ , . . , .
ZooKeeper , .
![](https://habrastorage.org/webt/6l/6h/_x/6l6h_xkevwleavsoecxm7linliu.png)
, , , , , . , shared-nothing. , , , , , .
, shared memory . context switch, . . , , .
![](https://habrastorage.org/webt/um/0e/tm/um0etmingw64sjft3v5hiwysqjo.png)
, , , . - . , , , , , , . , , , , . , .
. , , , , . . , .
. , , .
? , ? , , , . -, , - , - . - , , - . , . . , , .
โ group membership. - , โ , . , , , , . , , .
โ leader election, , . โ , - , . , , . , , , .
โ mutually exclusive access. . , , - , , , . - . , , -. , , locks.
ZooKeeper . , .
![](https://habrastorage.org/webt/fj/zt/u2/fjztu2nonj0i9xe1envfkbsvjuu.png)
. - , - . , , - . .
.
- , , .
![](https://habrastorage.org/webt/5r/-f/3d/5r-f3d7ghdws2k2yi3vv375zwrq.png)
ZooKeeper . โ standalone, . . , . โ 100 , , 100 . , ZooKeeper. high availability. ZooKeeper . , . , . โ , , โ . , .
. , , . .
, - . - . , , , . . โ . โ -? . watch mechanism, , - . .
![](https://habrastorage.org/webt/rs/jl/z3/rsjlz3jzg4w3_vhtc6kgyoz_xug.png)
Client โ , ZooKeeper.
Server โ ZooKeeper.
Znode โ ZooKeeper. znode ZooKeeper , .
. โ update/write, - . .
, , , ZooKeeper.
![](https://habrastorage.org/webt/tf/ep/bz/tfepbzajm_bud5qwcc1up53ijbc.png)
ZooKeeper . , . , . znodes.
znode - , , , 10 . znode - .
![](https://habrastorage.org/webt/zm/_m/fx/zm_mfx7wc8iunuaqapzel6dahce.png)
Znode . . znode , .
. โ ephemeral flag. Znode - . , . , . , - . , .
โ sequential flag. znode. , 1_5. , p_1, โ p_2. , , , , โ sequential.
znode. , .
![](https://habrastorage.org/webt/qo/_3/60/qo_3608vuognqyooseeanj4ewl0.png)
โ watch flag. , - . , . ZooKeeper , . , - . , - , .
, . , , .
![](https://habrastorage.org/webt/a0/vn/id/a0vnidpmcwg2mtbtzt-xsuntuxu.png)
. , , . - .
- . , - . , , .
![](https://habrastorage.org/webt/_h/2p/69/_h2p69kphpvui-e64ipeu5jltqe.png)
, API . , , create znode . znode, . - , . . znode.
โ . , , znode . , znode, , , , .
, ยซ-1ยป.
![](https://habrastorage.org/webt/no/e2/ma/noe2mab1z9m4rd7oxbxbwx9sgqw.png)
โ znode. true, , false.
flag watch, .
flag , . .
โ getData. , znode . flag watch. , . , , .
![](https://habrastorage.org/webt/hb/vu/ai/hbvuaik-im4k3ehaleek-dwlh7q.png)
SetData. version. , znode .
ยซ-1ยป, .
โ getChildren. znode, . , flag watch.
sync , , .
, , , write, - , , , . , , , , .
![](https://habrastorage.org/webt/23/je/2-/23je2-bbh7o8lm3zjs2fnfpffts.png)
. . , .
, , update/write, . create, setData, sync, delete. read โ exists, getData, getChildren.
![](https://habrastorage.org/webt/fl/cz/kt/flczktmxj49x7lx3qkibb_dkm8q.png)
, . , -. . , . . ZooKeeper? , ? , , , , ?
ZooKeeper . , znode. , , . , . , , .
getData . true. - , , , , . , - , true. , .
SetData. , ยซ-1ยป, . . , , , . , . , , , . , , , - . , , . , , . .
![](https://habrastorage.org/webt/cn/ck/sp/cnckspqdauy5itjgusrjljmem4k.png)
โ group membership. , , . , . -, - , .
? workers create. . sequential , . children , , .
![](https://habrastorage.org/webt/ts/bd/44/tsbd44ytlcykj7vzfqehyeycbwm.png)
![](https://habrastorage.org/webt/ye/ge/-y/yege-yxj37hbdasqb9bvxteri-u.png)
, Java-. , main. , . host, , . . . โ .
? API, . . ZooKeeper. hosts. , , 5 . , connectedSignal. , . , - . persistent. , , . . . , . , close , . , - , ZooKeeper .
![](https://habrastorage.org/webt/oh/xi/qq/ohxiqqq4xozdhtyb4-mwp_onehm.png)
- ? . , - , . , , lock1. , , lock . , getData , . . , watcher , , . . , lock, , lock , , . . . , . lock , , - .
![](https://habrastorage.org/webt/ao/cq/ac/aocqacdongzzqimzxmqmw1kxioq.png)
, . , . ? , . . , . . - , . , .
- , , , . , . - , , .
, , herd effect, . . , , , , , .
![](https://habrastorage.org/webt/my/_0/8y/my_08yqstcwj-unfsf1q1e-d38s.png)
, . , lock, hert effect. , id lock. , lock , , , , lock. , lock. , id, lock, . , .
id, lock, watcher , - . . . lock. , id lock, . , lock, - .
![](https://habrastorage.org/webt/16/rr/r2/16rrr2bzgkw5re7lhm9wr0buoqu.png)
ZooKeeper? 4 . โ Request. ZooKeeper Atomic Broadcast. Commit Log, . In-memory Replicated DB, . . , .
, Request Processor. In-memory .
![](https://habrastorage.org/webt/vj/2c/k2/vj2ck2jxvhnb0ntcbt03x5yhcfm.png)
. instances ZooKeeper .
, Commit log. , , , log . .
![](https://habrastorage.org/webt/fd/74/qu/fd74quoerpox0yjrt_09spie4rq.png)
ZooKeeper Atomic Broadcast โ , .
ZAB ZooKeeper. , - . , . , . , , , . . broadcasting , .
write request. , transactional update. .
ูููุง ุชุฌุฏุฑ ุงูุฅุดุงุฑุฉ ุฅูู ุฃู ุงุณุชูู
ุงููุฉ ุงูุชุญุฏูุซุงุช ููุนู
ููุฉ ููุณูุง ู
ุถู
ููุฉ. ู
ุง ูุฐุงุ ูุฐุง ุงูุดูุก ุ ุฅุฐุง ุชู
ุชูููุฐู ู
ุฑุชูู ุ ูุณูููู ูู ููุณ ุงูุญุงูุฉ ุ ุฃู ุฃู ุงูุทูุจ ููุณู ูู ูุชุบูุฑ ู
ู ูุฐุง. ูุชุญุชุงุฌ ุฅูู ุงูููุงู
ุจุฐูู ุญุชู ูู ุญุงูุฉ ุงูุณููุท ุ ูู
ููู ุฅุนุงุฏุฉ ุชุดุบูู ุงูุนู
ููุฉ ุ ูุจุงูุชุงูู ุชู
ุฑูุฑ ุงูุชุบููุฑุงุช ุงูุชู ุณูุทุช ูู ุงูููุช ุงูุญุงูู. ูู ูุฐู ุงูุญุงูุฉ ุ ุณุชุตุจุญ ุญุงูุฉ ุงููุธุงู
ูู
ุง ูู ุ ุฃู ูุง ููุจุบู ุฃู ุชููู ุณูุณูุฉ ู
ู ููุณ ุ ุนูู ุณุจูู ุงูู
ุซุงู ุ ุนู
ููุงุช ุงูุชุญุฏูุซ ุ ุชุคุฏู ุฅูู ุญุงูุงุช ููุงุฆูุฉ ู
ุฎุชููุฉ ูููุธุงู
.
![](https://habrastorage.org/webt/7f/xw/xf/7fxwxflasc4yu-f8apjaevjbcbu.png)
![](https://habrastorage.org/webt/ef/yv/hu/efyvhukzczm1tkfco8xiq2bmd7g.png)
![](https://habrastorage.org/webt/7k/gh/5c/7kgh5cwld4b2ypqrlq1zg0xgtiw.png)
![](https://habrastorage.org/webt/yv/ub/kw/yvubkwfx3stvk57zk-k4dumwu2y.png)
![](https://habrastorage.org/webt/0s/dw/ws/0sdwwshhw2dhjm96ivcijchkdfw.png)
![](https://habrastorage.org/webt/m3/hq/cu/m3hqcubpqamx7zzx8-mgv75oqku.png)
![](https://habrastorage.org/webt/m4/cw/6n/m4cw6nycqsyijmvk6mwqrgqlu2c.png)
![](https://habrastorage.org/webt/ou/hl/hz/ouhlhzglfwydds7-tghtibk29pa.png)