Elasticsearch集群學(xué)習(xí)筆記

1、分配感知

主分片不會(huì)被移動(dòng),但是副本分片將被移動(dòng)到擁有不同node.rack 參數(shù)值的節(jié)點(diǎn)。分片的分配是一個(gè)很方便的特性,用來(lái)防止中心點(diǎn)失敗導(dǎo)致的故障。常見(jiàn)的方法是按照地點(diǎn)、機(jī)架,甚至是虛擬機(jī)來(lái)劃分集群的拓?fù)?/p>

基于分片的分配

cluster.routing.allocation.awareness.attributes: rack
node.rack: 1

基于區(qū)域的分配

cluster.routing.allocation.awareness.attributes: zone
cluster.routing.allocation.force.zone.values: us-east, us-west

2、監(jiān)控瓶頸

集群健康A(chǔ)PI的請(qǐng)求

“curl -XGET 'localhost:9200/_cluster/health?pretty';
請(qǐng)求的答復(fù)是這樣的:

    {
     "cluster_name" : "elasticiq",
     "status" : "green",  ←---集群狀態(tài)指示器:方便的集群整體健康指示器
     "timed_out" : false,
     "number_of_nodes" : 2,  ←---集群中節(jié)點(diǎn)的總數(shù)量
     "number_of_data_nodes" : 2,
     "active_primary_shards" : 10,  ←---在集群中,存放數(shù)據(jù)的節(jié)點(diǎn)總數(shù)量
     "active_shards" : 10,  ←---集群中全部索引的主分片總數(shù)量
     "relocating_shards" : 0,  ←---集群中全部索引的所有分片、包括主分片和副本分片的總數(shù)量
     "initializing_shards" : 0,  ←---當(dāng)下正在多個(gè)節(jié)點(diǎn)間移動(dòng)的分片數(shù)量
     "unassigned_shards" : 0  ←---新創(chuàng)建的分片數(shù)量
    }  ←---集群中定義的、卻未能發(fā)現(xiàn)的分片數(shù)量”

慢日志

慢查詢?nèi)罩竞吐饕罩?/p>

curl -XPUT 'http://lzz:9201/_settings/' -d
{
    "index.indexing.slowlog.level": "INFO",
    "index.indexing.slowlog.threshold.index.warn": "10s",
    "index.indexing.slowlog.threshold.index.info": "5s",
    "index.indexing.slowlog.threshold.index.debug": "2s",
    "index.indexing.slowlog.threshold.index.trace": "50ms",
    "index.indexing.slowlog.source": "1000",
    "index.search.slowlog.level": "INFO",
    "index.search.slowlog.threshold.query.warn": "10s",
    "index.search.slowlog.threshold.query.info": "5s",
    "index.search.slowlog.threshold.query.debug": "2s",
    "index.search.slowlog.threshold.query.trace": "50ms",
    "index.search.slowlog.threshold.fetch.warn": "1s",
    "index.search.slowlog.threshold.fetch.info": "800ms",
    "index.search.slowlog.threshold.fetch.debug": "500ms",
    "index.search.slowlog.threshold.fetch.trace": "20ms"
}

在logging.yml文件中,可以配置存放日志輸出的實(shí)際文件,以及其他一些日志功能.

index_search_slow_log_file:
 type: dailyRollingFile
 file: ${path.logs}/${cluster.name}_index_search_slowlog.log
 datePattern: "'.'yyyy-MM-dd"
 layout:
  type: pattern
  conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"

3、線程池

集群中的每個(gè)節(jié)點(diǎn)通過(guò)線程池來(lái)管理CPU和內(nèi)存的使用,ES通過(guò)線程池來(lái)優(yōu)化節(jié)點(diǎn)性能。
線程池有兩種類(lèi)型,分別是fixed和cache,類(lèi)型詳解如下:

fixed

fixed的線程池類(lèi)型保持固定數(shù)量的線程來(lái)處理請(qǐng)求,等待的執(zhí)行的請(qǐng)求則使用后援隊(duì)列。其中配置文件中,threadpool.bulk.queue_size 線程的數(shù)量,默認(rèn)為CPU核數(shù)的5倍。

cache

cache類(lèi)型線程池不限制線程的數(shù)量,只要有等待執(zhí)行的請(qǐng)求,就會(huì)創(chuàng)建一個(gè)新的線程。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。