04.local_gateway和network相关设置
文章目錄
- 1. cluster restart的一些相關(guān)設(shè)置
- 1. gateway.expected_nodes:
- 2. gateway.expected_master_nodes:
- 3. gateway.expected_data_nodes:
- 4. gateway.recover_after_time:
- 5.gateway.recover_after_nodes:
- 6.gateway.recover_after_master_nodes:
- 7. gateway.recover_after_data_nodes:
- 2. network相關(guān)設(shè)置
- 2. transport的設(shè)置
1. cluster restart的一些相關(guān)設(shè)置
??es local gateway是一個(gè)功能模塊,負(fù)責(zé)在整個(gè)集群重新啟動(dòng)時(shí)存儲(chǔ)cluster state和shard 數(shù)據(jù)。主要作用是控制整個(gè)集群重啟后的恢復(fù)時(shí)機(jī)。
試想下這種場(chǎng)景:
集群中有9個(gè)節(jié)點(diǎn),假設(shè)都為master eligible 節(jié)點(diǎn)。那么集群重啟后需要滿(mǎn)足5個(gè)節(jié)點(diǎn)連接,就可以選舉出master。并可以進(jìn)行recovery操作(將replica copy變?yōu)閜rimary copy并且reallocate replica)。
如果接下來(lái)剩余的節(jié)點(diǎn)陸續(xù)啟動(dòng)并加入集群,此時(shí)recovery或者在進(jìn)行中,或者已經(jīng)完成,因?yàn)檫@些節(jié)點(diǎn)已經(jīng)存在了正在recovery的數(shù)據(jù),就會(huì)造成不必要的recovery(當(dāng)然es有自己的優(yōu)化算法,比如如果recovery的shard在節(jié)點(diǎn)離開(kāi)集群后,留在集群中的對(duì)應(yīng)的shard沒(méi)有數(shù)據(jù)變更,那么此節(jié)點(diǎn)的shard與集群中其他節(jié)點(diǎn)的shard是sync的,就會(huì)終止recovery操作)。
當(dāng)節(jié)點(diǎn)加入集群后,又會(huì)造成不必要的Rebalance操作。為了解決這個(gè)問(wèn)題,引入了gateway相關(guān)的配置。主要有如下參數(shù):
上面這幾個(gè)參數(shù)是hard limit。必須要滿(mǎn)足的。下來(lái)幾個(gè)參數(shù)是在滿(mǎn)足上面幾個(gè)參數(shù)要求的基礎(chǔ)上生效。
1. gateway.expected_nodes:
The number of (data or master) nodes that are expected to be in the cluster. Recovery of local shards will start as soon as the expected number of nodes have joined the cluster. Defaults to 0。
設(shè)置當(dāng)指定數(shù)量的data或者master節(jié)點(diǎn)加入集群后,才進(jìn)行恢復(fù)操作。默認(rèn)值為0。此參數(shù)應(yīng)該要大于等于上面的gateway.recover_after_nodes參數(shù)值。
2. gateway.expected_master_nodes:
The number of master nodes that are expected to be in the cluster. Recovery of local shards will start as soon as the expected number of master nodes have joined the cluster. Defaults to 0。
設(shè)置當(dāng)指定數(shù)量的master節(jié)點(diǎn)加入集群后,才進(jìn)行恢復(fù)操作。默認(rèn)值為0。此參數(shù)應(yīng)該要大于等于上面的gateway.recover_after_master_nodes參數(shù)值。
3. gateway.expected_data_nodes:
The number of data nodes that are expected to be in the cluster. Recovery of local shards will start as soon as the expected number of data nodes have joined the cluster. Defaults to 0。
設(shè)置當(dāng)指定數(shù)量的data節(jié)點(diǎn)加入集群后,才進(jìn)行恢復(fù)操作。默認(rèn)值為0。此參數(shù)應(yīng)該要大于等于上面的gateway.recover_after_data_nodes參數(shù)值。
4. gateway.recover_after_time:
If the expected number of nodes is not achieved, the recovery process waits for the configured amount of time before trying to recover regardless. Defaults to 5m if one of the expected_nodes settings is configured.
如果上面的expected相關(guān)的三個(gè)參數(shù)不滿(mǎn)足,那么會(huì)等待一定的時(shí)間,默認(rèn)是5min。 如果5分鐘之后還沒(méi)有達(dá)到上面的條件那么只要滿(mǎn)足下面的任何一個(gè)條件后就會(huì)進(jìn)行recovery.
5.gateway.recover_after_nodes:
Recover as long as this many data or master nodes have joined the cluster.
設(shè)置當(dāng)指定數(shù)量的data或者master(node.master: true)節(jié)點(diǎn)加入集群后才開(kāi)始進(jìn)行恢復(fù)操作。即使在此之前已選舉出了master節(jié)點(diǎn)。
6.gateway.recover_after_master_nodes:
Recover as long as this many master nodes have joined the cluster.
設(shè)置當(dāng)指定數(shù)量的master(node.master: true)節(jié)點(diǎn)加入集群后才進(jìn)行恢復(fù)操作。即使在此之前已選舉出了master節(jié)點(diǎn)。
7. gateway.recover_after_data_nodes:
Recover as long as this many data nodes have joined the cluster.
設(shè)置當(dāng)指定數(shù)量的data節(jié)點(diǎn)加入集群后才進(jìn)行恢復(fù)操作。即使在此之前已選舉出了master節(jié)點(diǎn)。
gateway相關(guān)參數(shù)僅適用于集群完全重啟。如果只是節(jié)點(diǎn)重啟可使用延遲恢復(fù)參數(shù)進(jìn)行設(shè)置
同時(shí),如果一個(gè)node重新join到cluster當(dāng)中,那些在當(dāng)前node上存在但是cluster中并不存在的shard會(huì)直接被加入到cluster當(dāng)中去,這種情況只是發(fā)生在所有的master都掛掉了,新啟動(dòng)了一個(gè)node座位master,這個(gè)時(shí)候他沒(méi)有相關(guān)的cluster數(shù)據(jù),這樣的話(huà)集群的恢復(fù)更加容易一些。
2. network相關(guān)設(shè)置
這一篇內(nèi)容不多,主要是講網(wǎng)絡(luò)相關(guān)的設(shè)置
其中network.host可以分為兩部分
network.bind_host: 綁定的ip,可以有多個(gè)
network.publish_host: 往集群中其他node publish的ip,只能有一個(gè)
后面可以試驗(yàn)一下,如果直接將network.host 設(shè)置為 0.0.0.0會(huì)有什么樣的效果
2. transport的設(shè)置
transport模塊用于集群內(nèi)節(jié)點(diǎn)之間的內(nèi)部通信。從一個(gè)節(jié)點(diǎn)到另一個(gè)節(jié)點(diǎn)的每個(gè)調(diào)用都使用transport模塊(例如,當(dāng)一個(gè)節(jié)點(diǎn)處理HTTP GET請(qǐng)求,而實(shí)際上應(yīng)由另一個(gè)保存數(shù)據(jù)的節(jié)點(diǎn)處理時(shí))。傳輸模塊還用于Elasticsearch Java API中的TransportClient。
傳輸機(jī)制本質(zhì)上是完全異步的,這意味著沒(méi)有阻塞線程在等待響應(yīng)。使用異步通信的好處是首先解決了C10k問(wèn)題,同時(shí)也是分散(廣播)/收集操作(例如Elasticsearch中的搜索)的理想解決方案。
transport.port : 默認(rèn)9300-9400
transport.publish_port : 這個(gè)默認(rèn)情況下和transport.port保持一致,是其他節(jié)點(diǎn)請(qǐng)求當(dāng)前節(jié)點(diǎn)時(shí)使用的當(dāng)前node的port,只有在節(jié)點(diǎn)使用了代理的時(shí)候可能需要特殊配置這個(gè)值。
transport.host: transport bind和publish使用的host,默認(rèn)是network.host
transport.bind_host: 單獨(dú)設(shè)置bind host,默認(rèn)是 transport.host
transport.publish_host: 單獨(dú)設(shè)置publish host,默認(rèn)是 transport.host
transport.connect_timeout: 新的connection create的超時(shí)時(shí)間,默認(rèn)是30s
transport.compress: 默認(rèn)是false,在node之間通信的時(shí)候進(jìn)行壓縮
transport.ping_schedule: 定時(shí)ping以防連接不可用,默認(rèn)為5s,可以通過(guò)設(shè)置tcp的keep-alive來(lái)更好的保持tcp連接的活性。
參考這里
總結(jié)
以上是生活随笔為你收集整理的04.local_gateway和network相关设置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 03.shard_allocation_
- 下一篇: 05.global_index_sett