Elasticsearch配置文件詳解
elasticsearch.yml基本配置說(shuō)明
一、基本配置
elasticsearch的config文件夾里面有兩個(gè)配置文 件:elasticsearch.yml和logging.yml,第一個(gè)是es的基本配置文件,第二個(gè)是日志配置文件捺疼,es也是使用log4j來(lái)記錄日志的婚被,所以logging.yml里的設(shè)置按普通log4j配置文件來(lái)設(shè)置就行了公你。下面主要講解下elasticsearch.yml這個(gè)文件中可配置的東西慌植。
只是挑些重要的配置選項(xiàng)進(jìn)行注釋,其實(shí)自帶的已經(jīng)有非常細(xì)致的英文注釋了!
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules.htm
################################### Cluster ###################################
# 代表一個(gè)集群,集群中有多個(gè)節(jié)點(diǎn),其中有一個(gè)為主節(jié)點(diǎn),這個(gè)主節(jié)點(diǎn)是可以通過(guò)選舉產(chǎn)生的,主從節(jié)點(diǎn)是對(duì)于集群內(nèi)部來(lái)說(shuō)的.
# es的一個(gè)概念就是去中心化,字面上理解就是無(wú)中心節(jié)點(diǎn),這是對(duì)于集群外部來(lái)說(shuō)的,
# 因?yàn)閺耐獠縼?lái)看es集群,在邏輯上是個(gè)整體,你與任何一個(gè)節(jié)點(diǎn)的通信和與整個(gè)es集群通信是等價(jià)的
cluster.name: elasticsearch
配置es的集群名稱,默認(rèn)是elasticsearch曙咽,es會(huì)自動(dòng)發(fā)現(xiàn)在同一網(wǎng)段下的es蛔趴,
如果在同一網(wǎng)段下有多個(gè)集群,就可以用這個(gè)屬性來(lái)區(qū)分不同的集群例朱,cluster.name就成為同一個(gè)集群的標(biāo)識(shí)孝情。
node.name: "Franz Kafka"
節(jié)點(diǎn)名,默認(rèn)隨機(jī)指定一個(gè)name列表中名字洒嗤,該列表在es的jar包中config文件夾里name.txt文件中箫荡,
其中有很多作者添加的有趣名字,節(jié)點(diǎn)名稱同理,可自動(dòng)生成也可手動(dòng)配置渔隶。
node.master: true
指定該節(jié)點(diǎn)是否有資格被選舉成為node羔挡,默認(rèn)是true,es是默認(rèn)集群中的第一臺(tái)機(jī)器為master间唉,
如果這臺(tái)機(jī)掛了就會(huì)重新選舉master绞灼。
node.data: true
指定該節(jié)點(diǎn)是否存儲(chǔ)索引數(shù)據(jù),默認(rèn)為true呈野。
1. # 配置文件中給出了三種配置高性能集群拓?fù)浣Y(jié)構(gòu)的模式,如下:
2. # 1. 如果你想讓節(jié)點(diǎn)從不選舉為主節(jié)點(diǎn),只用來(lái)存儲(chǔ)數(shù)據(jù),可作為負(fù)載器
3. # node.master: **false**
4. # node.data: **true**
5. # node.ingest: **false**
6.
7. # 2. 如果想讓節(jié)點(diǎn)成為主節(jié)點(diǎn),且不存儲(chǔ)任何數(shù)據(jù),并保有空閑資源,可作為協(xié)調(diào)器
8. # node.master: **true**
9. # node.data: **false**
10. # node.ingest: **false**
11.
12. # 3. 如果想讓節(jié)點(diǎn)既不稱為主節(jié)點(diǎn),又不成為數(shù)據(jù)節(jié)點(diǎn),那么可將他作為搜索器,從節(jié)點(diǎn)中獲取數(shù)據(jù),生成搜索結(jié)果等
13. # node.master: **false**
14. # node.data: **false**
15. # node.ingest: **true** (可不指定默認(rèn)開(kāi)啟)
16.
17. # 4. 僅作為協(xié)調(diào)器
18. # node.master: **false**
19. # node.data: **false**
20. # node.ingest: **false**
index.number_of_shards: 5
設(shè)置默認(rèn)索引分片個(gè)數(shù)低矮,默認(rèn)為5片。
index.number_of_replicas: 1
設(shè)置默認(rèn)索引副本個(gè)數(shù)被冒,默認(rèn)為1個(gè)副本军掂。
1. # 配置文件中提到的最佳實(shí)踐是,如果服務(wù)器夠多,可以將分片提高,盡量將數(shù)據(jù)平均分布到大集群中去
2. # 同時(shí),如果增加副本數(shù)量可以有效的提高搜索性能
3. # 需要注意的是,"number_of_shards" 是索引創(chuàng)建后一次生成的,后續(xù)不可更改設(shè)置
4. # "number_of_replicas" 是可以通過(guò)API去實(shí)時(shí)修改設(shè)置的
path.conf: /path/to/conf
設(shè)置配置文件的存儲(chǔ)路徑,默認(rèn)是es根目錄下的config文件夾昨悼。
path.data: /path/to/data
設(shè)置索引數(shù)據(jù)的存儲(chǔ)路徑蝗锥,默認(rèn)是es根目錄下的data文件夾,可以設(shè)置多個(gè)存儲(chǔ)路徑率触,用逗號(hào)隔開(kāi)终议,例:
path.data: /path/to/data1,/path/to/data2
path.work: /path/to/work
設(shè)置臨時(shí)文件的存儲(chǔ)路徑,默認(rèn)是es根目錄下的work文件夾葱蝗。
path.logs: /path/to/logs
設(shè)置日志文件的存儲(chǔ)路徑痊剖,默認(rèn)是es根目錄下的logs文件夾
path.plugins: /path/to/plugins
設(shè)置插件的存放路徑,默認(rèn)是es根目錄下的plugins文件夾
bootstrap.memory_lock:
服務(wù)器發(fā)生系統(tǒng)swapping的時(shí)候ES節(jié)點(diǎn)的性能會(huì)非常差垒玲,也會(huì)影響節(jié)點(diǎn)的穩(wěn)定性。
所以要不惜一切代價(jià)來(lái)避免swapping找颓。swapping會(huì)導(dǎo)致Java GC的周期延遲從毫秒級(jí)惡化到分鐘合愈,
更嚴(yán)重的是會(huì)引起節(jié)點(diǎn)響應(yīng)延遲甚至脫離集群。
這個(gè)參數(shù)的目的是當(dāng)你無(wú)法關(guān)閉系統(tǒng)的swap的時(shí)候,建議把這個(gè)參數(shù)設(shè)為true佛析。
防止在內(nèi)存不夠用的時(shí)候益老,elasticsearch的內(nèi)存被交換至交換區(qū),導(dǎo)致性能驟降寸莫。
bootstrap.mlockall: true
設(shè)置為true來(lái)鎖住內(nèi)存捺萌。因?yàn)楫?dāng)jvm開(kāi)始swapping時(shí)es的效率會(huì)降低,所以要保證它不swap膘茎,
可以把ES_MIN_MEM和 ES_MAX_MEM兩個(gè)環(huán)境變量設(shè)置成同一個(gè)值桃纯,并且保證機(jī)器有足夠的內(nèi)存分配給es。
同時(shí)也要允許elasticsearch的進(jìn)程可以鎖住內(nèi)存披坏,linux下可以通過(guò)`ulimit -l unlimited`命令态坦。
network.bind_host: 192.168.0.1
設(shè)置綁定的ip地址,可以是ipv4或ipv6的棒拂,默認(rèn)為0.0.0.0伞梯。
network.publish_host: 192.168.0.1
設(shè)置其它節(jié)點(diǎn)和該節(jié)點(diǎn)交互的ip地址,如果不設(shè)置它會(huì)自動(dòng)判斷帚屉,值必須是個(gè)真實(shí)的ip地址谜诫。
network.host: 192.168.0.1
這個(gè)參數(shù)是用來(lái)同時(shí)設(shè)置bind_host和publish_host上面兩個(gè)參數(shù)。
transport.tcp.port: 9300
設(shè)置節(jié)點(diǎn)間交互的tcp端口攻旦,默認(rèn)是9300喻旷。
transport.tcp.compress: true
設(shè)置是否壓縮tcp傳輸時(shí)的數(shù)據(jù),默認(rèn)為false敬特,不壓縮掰邢。
http.port: 9200
設(shè)置對(duì)外服務(wù)的http端口,默認(rèn)為9200伟阔。
http.max_content_length: 100mb
設(shè)置內(nèi)容的最大容量辣之,默認(rèn)100mb
http.enabled: false
是否使用http協(xié)議對(duì)外提供服務(wù),默認(rèn)為true皱炉,開(kāi)啟怀估。
1. ###################### 使用head等插件監(jiān)控集群信息,需要打開(kāi)以下配置項(xiàng) ###########
2. # http.cors.enabled: **true**
3. # http.cors.allow-origin: "*"
4. # http.cors.allow-credentials: **true**
1. # 下面的配置控制怎樣以及何時(shí)啟動(dòng)一整個(gè)集群重啟的初始化恢復(fù)過(guò)程
2. # (當(dāng)使用shard gateway時(shí),是為了盡可能的重用local data(本地?cái)?shù)據(jù)))
gateway.type: local
gateway的類型合搅,默認(rèn)為local即為本地文件系統(tǒng)多搀,可以設(shè)置為本地文件系統(tǒng),分布式文件系統(tǒng)灾部,Hadoop的HDFS康铭,和amazon的s3服務(wù)器。
gateway.recover_after_nodes: 1
集群中N個(gè)節(jié)點(diǎn)啟動(dòng)后進(jìn)行數(shù)據(jù)恢復(fù)赌髓,默認(rèn)為1从藤。
gateway.recover_after_time: 5m
設(shè)置初始化恢復(fù)過(guò)程的超時(shí)時(shí)間,超時(shí)時(shí)間從上一個(gè)配置中配置的N個(gè)節(jié)點(diǎn)啟動(dòng)后算起催跪,默認(rèn)是5分鐘。
gateway.expected_nodes: 2
設(shè)置這個(gè)集群中節(jié)點(diǎn)的數(shù)量夷野,默認(rèn)為2懊蒸,一旦這N個(gè)節(jié)點(diǎn)啟動(dòng),就會(huì)立即進(jìn)行數(shù)據(jù)恢復(fù)悯搔。
1. # 下面這些配置允許在初始化恢復(fù),副本分配,再平衡,或者添加和刪除節(jié)點(diǎn)時(shí)控制節(jié)點(diǎn)間的分片分配
2. # 設(shè)置一個(gè)節(jié)點(diǎn)的并行恢復(fù)數(shù)
cluster.routing.allocation.node_initial_primaries_recoveries: 4
初始化數(shù)據(jù)恢復(fù)時(shí)骑丸,并發(fā)恢復(fù)線程的個(gè)數(shù),默認(rèn)為4妒貌。
cluster.routing.allocation.node_concurrent_recoveries: 2
添加刪除節(jié)點(diǎn)或負(fù)載均衡時(shí)并發(fā)恢復(fù)線程的個(gè)數(shù)通危,默認(rèn)為4。
indices.recovery.max_size_per_sec: 0
設(shè)置數(shù)據(jù)恢復(fù)時(shí)限制的帶寬苏揣,如入100mb黄鳍,默認(rèn)為0,即無(wú)限制平匈。
indices.recovery.concurrent_streams: 5
設(shè)置這個(gè)參數(shù)來(lái)限制從其它分片恢復(fù)數(shù)據(jù)時(shí)最大同時(shí)打開(kāi)并發(fā)流的個(gè)數(shù)框沟,默認(rèn)為5。
discovery.zen.minimum_master_nodes: 1
設(shè)置這個(gè)參數(shù)來(lái)保證集群中的節(jié)點(diǎn)可以知道其它N個(gè)有master資格的節(jié)點(diǎn)增炭。默認(rèn)為1忍燥,對(duì)于大的集群來(lái)說(shuō),可以設(shè)置大一點(diǎn)的值(2-4)
discovery.zen.ping.timeout: 3s
設(shè)置集群中自動(dòng)發(fā)現(xiàn)其它節(jié)點(diǎn)時(shí)ping連接超時(shí)時(shí)間隙姿,默認(rèn)為3秒梅垄,對(duì)于比較差的網(wǎng)絡(luò)環(huán)境可以高點(diǎn)的值來(lái)防止自動(dòng)發(fā)現(xiàn)時(shí)出錯(cuò)。
discovery.zen.ping.multicast.enabled: false
設(shè)置是否打開(kāi)多播發(fā)現(xiàn)節(jié)點(diǎn)输玷,默認(rèn)是true队丝。
discovery.zen.ping.unicast.hosts: ["host1", "host2:port", "host3[portX-portY]"]
設(shè)置集群中master節(jié)點(diǎn)的初始列表,可以通過(guò)這些節(jié)點(diǎn)來(lái)自動(dòng)發(fā)現(xiàn)新加入集群的節(jié)點(diǎn)欲鹏。
###節(jié)點(diǎn)ping設(shè)置机久,更多等待時(shí)間設(shè)置discovery.zen.fd.ping_interval:該屬性默認(rèn)為1s(1秒鐘),指定了節(jié)點(diǎn)互相ping的時(shí)間間隔赔嚎。
discovery.zen.fd.ping_timeout:該屬性默認(rèn)為30s(30秒鐘)膘盖,指定了節(jié)點(diǎn)發(fā)送ping信息后等待響應(yīng)的時(shí)間,超過(guò)此時(shí)間則認(rèn)為對(duì)方節(jié)點(diǎn)無(wú)響應(yīng)尤误。
discovery.zen.fd.ping_retries:該屬性默認(rèn)為3侠畔,指定了重試次數(shù),超過(guò)此次數(shù)則認(rèn)為對(duì)方節(jié)點(diǎn)已停止工作损晤。
1. # 官方插件 相關(guān)設(shè)置請(qǐng)查看此處
2. # https://www.elastic.co/guide/en/x-pack/current/xpack-settings.html
下面是一些查詢時(shí)的慢日志參數(shù)設(shè)置
index.search.slowlog.level: TRACE
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: 500ms
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: 200ms
二软棺、高級(jí)配置(線程池) 一個(gè)Elasticsearch節(jié)點(diǎn)會(huì)有多個(gè)線程池,但重要的是下面四個(gè):
索引(index):主要是索引數(shù)據(jù)和刪除數(shù)據(jù)操作(默認(rèn)是cached類型)
搜索(search):主要是獲取尤勋,統(tǒng)計(jì)和搜索操作(默認(rèn)是cached類型)
批量操作(bulk):主要是對(duì)索引的批量操作(默認(rèn)是cached類型)
更新(refresh):主要是更新操作(默認(rèn)是cached類型) 可以通過(guò)給設(shè)置一個(gè)參數(shù)來(lái)改變線程池的類型(type)喘落,例如德崭,把索引的線程池改成blocking類型:
min: 1
size: 30
wait_time: 30s
下面是三種可以設(shè)置的線程池的類型:
cache
cache線程池是一個(gè)無(wú)限大小的線程池,如果有很多請(qǐng)求的話都會(huì)創(chuàng)建很多線程揖盘,下面是個(gè)例子:
threadpool:
index:
type: cached
fixed
fixed線程池保持固定個(gè)數(shù)的線程來(lái)處理請(qǐng)求隊(duì)列。
size參數(shù)設(shè)置線程的個(gè)數(shù)锌奴,默認(rèn)設(shè)置是cpu核心數(shù)的5倍
queue_size可以控制待處理請(qǐng)求隊(duì)列的大小兽狭。默認(rèn)是設(shè)置為-1,意味著無(wú)限制鹿蜀。當(dāng)一個(gè)請(qǐng)求到來(lái)但隊(duì)列滿了的時(shí)候箕慧,reject_policy參數(shù)可以控制它的行為钦听。默認(rèn)是abort阀蒂,會(huì)使那個(gè)請(qǐng)求失敗瘩燥。設(shè)置成caller會(huì)使該請(qǐng)求在io線程中執(zhí)行锨天。
threadpool:
index:
type: fixed
size: 30
queue: 1000
reject_policy: caller
blocking
blocking線程池允許設(shè)置一個(gè)最小值(min辣垒,默認(rèn)為1)和線程池大谐胀弧(size辫塌,默認(rèn)為cpu核心數(shù)的5倍)原押。它也有一個(gè)等待隊(duì)列分冈,隊(duì)列的大谢怼(queue_size )默認(rèn)是1000,當(dāng)這隊(duì)列滿了的時(shí)候雕沉。它會(huì)根據(jù)定好的等待時(shí)間(wait_time集乔,默認(rèn)是60秒)來(lái)調(diào)用io線程,如果超時(shí)沒(méi)有執(zhí)行就會(huì)報(bào)錯(cuò)坡椒。
threadpool:
index:
type: blocking
min: 1
size: 30
wait_time: 30s
筆者在實(shí)際工作中扰路,由于程序啟動(dòng)時(shí)即產(chǎn)生大量請(qǐng)求,導(dǎo)致隊(duì)列大小溢出的情況倔叼,從而查詢請(qǐng)求報(bào)錯(cuò)汗唱,可以在以下2個(gè)解決方法權(quán)衡處理:
1、增加隊(duì)列長(zhǎng)度缀雳,但隨之帶來(lái)的是CPU消耗高渡嚣。
2、優(yōu)化程序肥印,適當(dāng)控制程序的并發(fā)請(qǐng)求量识椰。
三、操作系統(tǒng)配置
1深碱、文件句柄限制:ES在索引過(guò)程中腹鹉,尤其是有很多分片和副本時(shí),會(huì)創(chuàng)建若干文件敷硅。因此操作系統(tǒng)對(duì)打開(kāi)文件數(shù)量的限制不能少于32000功咒。對(duì)于linux服務(wù)器愉阎,通過(guò)可以在/etc/security/limits.conf中進(jìn)行修改,并且可以用ulimit命令來(lái)查看當(dāng)前值力奋。
2榜旦、節(jié)點(diǎn)內(nèi)存配置:ES每個(gè)節(jié)點(diǎn)默認(rèn)的2014M內(nèi)存空間可能是不夠的。如果日志文件中有out of memory error錯(cuò)誤景殷,則應(yīng)將環(huán)境變量ES_HEAP_SIZE設(shè)為大于1024的值溅呢。注意該值應(yīng)超過(guò)總可用物理內(nèi)存的50%,剩余內(nèi)存可用作磁盤(pán)高速緩存猿挚,可大大提高搜索性能咐旧。
附:ES集群的配置(3臺(tái)master和3臺(tái)data節(jié)點(diǎn))
data1
es@spark-dev:/usr/local/es/elasticsearch-5.6.8$ cat config/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
cluster.name: td-es
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
node.name: data1
node.master: false
#node.master: true
node.data: true
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
path.data: /mnt/local/data/es/data
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /mnt/local/data/es/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: ip1
# Set a custom port for HTTP:
#
#http.port: 9200
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping_timeout: 60s
#discovery.zen.ping.unicast.hosts: ["ip1","ip2"]
#discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.unicast.hosts: ["ip1:9301","ip2:9301","ip3:9301"]
discovery.zen.minimum_master_nodes: 2
#discovery.zen.ping.multicast.enabled: false
#head
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
xpack.security.enabled: false
#xpack.reporting.enabled: false
xpack.monitoring.enabled: false
#action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
#xpack.monitoring.elasticsearch.username: "elastic"
#xpack.monitoring.elasticsearch.password: "changeme"
#elsticsearch.username: "elastic"
#elasticsearch.password: "changeme"
#For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
indices.fielddata.cache.size: 20%
master1
es@spark-dev:/usr/local/es/elasticsearch-5.6.8_2$ cat config/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
cluster.name: td-es
#cluster.name: zzy-es
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
node.name: master1
#node.master: false
node.master: true
node.data: false
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
path.data: /mnt/local/data/es/data2
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /mnt/local/data/es/logs2
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: ip1
# Set a custom port for HTTP:
#
#http.port: 9200
http.port: 9201
#
transport.tcp.port: 9301
discovery.zen.ping_timeout: 60s
#discovery.zen.ping.unicast.hosts: ["ip1","ip2"]
#discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.unicast.hosts: ["ip1","ip2","ip3"]
discovery.zen.minimum_master_nodes: 2
#head
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
xpack.security.enabled: false
#xpack.reporting.enabled: false
xpack.monitoring.enabled: false
#action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
#xpack.monitoring.elasticsearch.username: "elastic"
#xpack.monitoring.elasticsearch.password: "changeme"
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
indices.fielddata.cache.size: 20%
jvm配置
es@spark-dev:/usr/local/es/elasticsearch-5.6.8$ cat config/jvm.options
##JVM configuration
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms32g
-Xmx32g
#-Xms4g
#-Xmx4g
################################################################
## Expert settings
################################################################
##
## All settings below this section are considered
## expert settings. Don't tamper with them unless
## you understand what you are doing
##
################################################################
## GC configuration
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
## optimizations
# pre-touch memory pages used by the JVM during initialization
-XX:+AlwaysPreTouch
## basic
# force the server VM (remove on 32-bit client JVMs)
-server
# explicitly set the stack size (reduce to 320k on 32-bit client JVMs)
-Xss1m
# set to headless, just in case
-Djava.awt.headless=true
# ensure UTF-8 encoding by default (e.g. filenames)
-Dfile.encoding=UTF-8
# use our provided JNA always versus the system one
-Djna.nosys=true
# use old-style file permissions on JDK9
-Djdk.io.permissionsUseCanonicalPath=true
# flags to configure Netty
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0
# log4j 2
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true
-Dlog4j.skipJansi=true
## heap dumps
# generate a heap dump when an allocation from the Java heap fails
# heap dumps are created in the working directory of the JVM
-XX:+HeapDumpOnOutOfMemoryError
# specify an alternative path for heap dumps
# ensure the directory exists and has sufficient space
#-XX:HeapDumpPath=${heap.dump.path}
## GC logging
#-XX:+PrintGCDetails
#-XX:+PrintGCTimeStamps
#-XX:+PrintGCDateStamps
#-XX:+PrintClassHistogram
#-XX:+PrintTenuringDistribution
#-XX:+PrintGCApplicationStoppedTime
# log GC status to a file with time stamps
# ensure the directory exists
#-Xloggc:${loggc}
# By default, the GC log file will not rotate.
# By uncommenting the lines below, the GC log file
# will be rotated every 128MB at most 32 times.
#-XX:+UseGCLogFileRotation
#-XX:NumberOfGCLogFiles=32
#-XX:GCLogFileSize=128M
# Elasticsearch 5.0.0 will throw an exception on unquoted field names in JSON.
# If documents were already indexed with unquoted fields in a previous version
# of Elasticsearch, some operations may throw errors.
#
# WARNING: This option will be removed in Elasticsearch 6.0.0 and is provided
# only for migration purposes.
#-Delasticsearch.json.allow_unquoted_field_names=true
data2
es@es3:/usr/local/es/elasticsearch-5.6.8$ cat config/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
cluster.name: td-es
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
node.name: data2
node.master: false
node.data: true
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
path.data: /mnt/local/data/es/data
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /mnt/local/data/es/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: ip2
#
# Set a custom port for HTTP:
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping_timeout: 60s
#discovery.zen.ping.unicast.hosts: ["ip1","ip2"]
#discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.unicast.hosts: ["ip1:9301","ip2:9301","ip3:9301"]
discovery.zen.minimum_master_nodes: 2
#head
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
xpack.security.enabled: false
#xpack.reporting.enabled: false
xpack.monitoring.enabled: false
#xpack.monitoring.exporters.auth.username: "elastic"
#xpack.monitoring.exporters.auth.password: "changeme"
#xpack.security.audit.enabled: true
#action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
#elasticsearch.username: "elastic"
#elasticsearch.password: "changeme"
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
indices.fielddata.cache.size: 20%
master2
es@es3:/usr/local/es/elasticsearch-5.6.8_2$ cat config/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
cluster.name: td-es
#cluster.name: zzy-es
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
node.name: master2
node.master: true
node.data: false
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
path.data: /mnt/local/data/es/data2
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /mnt/local/data/es/logs2
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: ip2
#
# Set a custom port for HTTP:
http.port: 9201
transport.tcp.port: 9301
discovery.zen.ping_timeout: 60s
#discovery.zen.ping.unicast.hosts: ["ip1","ip2"]
#discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.unicast.hosts: ["ip1","ip2","ip3"]
discovery.zen.minimum_master_nodes: 2
#head
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
xpack.security.enabled: false
#xpack.reporting.enabled: false
xpack.monitoring.enabled: false
#xpack.monitoring.exporters.auth.username: "elastic"
#xpack.monitoring.exporters.auth.password: "changeme"
#xpack.security.audit.enabled: true
#action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
#elasticsearch.username: "elastic"
#elasticsearch.password: "changeme"
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
indices.fielddata.cache.size: 20%
data3
es@es4:/usr/local/es/elasticsearch-5.6.8$ cat config/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
cluster.name: td-es
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
node.name: data3
node.master: false
node.data: true
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
path.data: /mnt/local/data/es/data
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /mnt/local/data/es/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#network.host: 0.0.0.0
network.host: ip3
#
# Set a custom port for HTTP:
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping_timeout: 60s
#discovery.zen.ping.unicast.hosts: ["ip1","ip2"]
#discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.unicast.hosts: ["ip1:9301","ip2:9301","ip3:9301"]
discovery.zen.minimum_master_nodes: 2
#head
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
xpack.security.enabled: false
#xpack.reporting.enabled: false
#xpack.monitoring.enabled: false
#xpack.monitoring.exporters.auth.username: "elastic"
#xpack.monitoring.exporters.auth.password: "changeme"
#xpack.security.audit.enabled: true
#action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
#elasticsearch.username: "elastic"
#elasticsearch.password: "changeme"
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
indices.fielddata.cache.size: 20%
master3
es@es4:/usr/local/es/elasticsearch-5.6.8_2$ cat config/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
cluster.name: td-es
#cluster.name: zzy-es
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
node.name: master3
node.master: true
node.data: false
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
path.data: /mnt/local/data/es/data2
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /mnt/local/data/es/logs2
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#network.host: 0.0.0.0
network.host: ip1
#
# Set a custom port for HTTP:
http.port: 9201
transport.tcp.port: 9301
discovery.zen.ping_timeout: 60s
#discovery.zen.ping.unicast.hosts: ["ip1","ip2"]
#discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.unicast.hosts: ["ip1","ip2","ip3"]
discovery.zen.minimum_master_nodes: 2
#head
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
xpack.security.enabled: false
#xpack.reporting.enabled: false
xpack.monitoring.enabled: false
#xpack.monitoring.exporters.auth.username: "elastic"
#xpack.monitoring.exporters.auth.password: "changeme"
#xpack.security.audit.enabled: true
#action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
#elasticsearch.username: "elastic"
#elasticsearch.password: "changeme"
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
indices.fielddata.cache.size: 20%
ES初學(xué)中,歡迎一起學(xué)習(xí)交流绩蜻!
參考:
https://blog.csdn.net/lu_wei_wei/article/details/51263153
https://blog.csdn.net/u013673976/article/details/73650889