tips:
- 本文以源碼安裝為例,默認(rèn)配置文件位置$ES_HOME/config/elasticsearch.yml
- 可以通過修改環(huán)境變量ES_PATH_CONF=/path/to/my/config設(shè)置默認(rèn)位置
命令行配置 -E
./bin/elasticsearch -d -Ecluster.name=my_cluster -Enode.name=node_1
./bin/elasticsearch -p pidfile
主要配置文件
elasticsearch.yml
jvm.options
log4j2.properties
配置文件格式
變量
node.name: ${HOSTNAME}
network.host: ${ES_NETWORK_HOST}
path:
data: /var/lib/elasticsearch
logs: /var/log/elasticsearch
或者
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
keystore配置
對于敏感配置喻鳄,es提供了keystore進(jìn)行存儲扼倘,并提供相關(guān)工具來管理
提示:
用戶與es啟動用戶一致
只有部分配置可以從keystore中讀取,如果配置了不支持keystore存儲的配置項到keystore中除呵,則es啟動會失敗
所有配置再菊,重啟es才會生效
各節(jié)點(diǎn)的配置應(yīng)該保持一致
創(chuàng)建config/elasticsearch.keystorre
bin/elasticsearch-keystore create
列出
bin/elasticsearch-keystore list
從標(biāo)準(zhǔn)輸入流添加配置項
cat /file/containing/setting/value | bin/elasticsearch-keystore add --stdin the.setting.name.to.set
從文件添加配置項
bin/elasticsearch-keystore add-file the.setting.name.to.set /path/example-file.json
移除配置項
bin/elasticsearch-keystore remove the.setting.name.to.remove
動態(tài)重載,部分reloadable配置項可以不用重啟更新生效
POST _nodes/reload_secure_settings
重要配置項
#path.data path.logs
path:
logs: /var/log/elasticsearch
data: /var/data/elasticsearch
#path.data可以設(shè)置目錄列表
#單個shard的數(shù)據(jù)會存儲為單獨(dú)的文件颜曾,只會在一個路徑下存儲
path:
data:
- /mnt/elasticsearch_1
- /mnt/elasticsearch_2
- /mnt/elasticsearch_3
#cluster.name 纠拔,該配置相同的實例構(gòu)成集群
cluster.name: logging-prod
#node.name,默認(rèn)為主機(jī)名
node.name: prod-data-2
#network.host
network.host:ip
http.port:port
discovery.seed_hosts #見下
transport.port #節(jié)點(diǎn)間通信端口
#集群節(jié)點(diǎn)發(fā)現(xiàn)和選舉master配置
discovery.seed_hosts:
- 192.168.1.10:9300
- 192.168.1.11 #默認(rèn)會使用transport.port配置的端口
- seeds.mydomain.com #如果域名被解析到多個地址泛豪,會嘗試到多個ip檢測發(fā)現(xiàn)
cluster.initial_master_nodes:
- master-node-a # node.name
- master-node-b
- master-node-c