配置文件位置
rpm和Debian安裝包默認(rèn)放在/etc/elasticserach下面。
如果你自己下載java包到/data(注意elasticserach需要java se環(huán)境)撬槽,那么之后根據(jù)官方文檔的也會放在/data下襟齿。
你也可以修配置文件的位置
./bin/elasticsearch -Epath.conf=/path/to/my/config/
配置文件格式:
下面修改數(shù)據(jù)和日志存放的目錄
path: data: /var/lib/elasticsearch
logs: /var/log/elasticsearch
也可以這樣子寫
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
環(huán)境變量的替代
環(huán)境變量設(shè)置的格式為${...},
例如
node.name: ${HOSTNAME}
network.host: ${ES_NETWORK_HOST}
第一個修改節(jié)點(diǎn)的名字澎灸,第二個修改可訪問到該節(jié)點(diǎn)的IP炸宵。
即時設(shè)置:(不會被寫進(jìn)去配置文件中)
我們可以使用
${promp.text}
${promp.secret}
在前臺中開啟elasticsearch瓜客,使用prompt.secret時俭正,在終端輸入的內(nèi)容不會顯示出來,提高安全性掸读。
例子:
node: name: ${prompt.text}
當(dāng)我們開啟elasticsearch之后串远,會讓你輸入節(jié)點(diǎn)的名字
Enter value for [node.name]:
注意:Elasticsearch不會把${prompt.text}或者${prompt.secret}的設(shè)置用于service或者background的進(jìn)程宏多。
默認(rèn)設(shè)置
在開啟elasticsearch時,可以在命令行中使用
default.
前綴使用默認(rèn)設(shè)置澡罚,如下:
./bin/elasticsearch -Edefault.node.name=My_Node
節(jié)點(diǎn)的名字就是My_Node伸但。當(dāng)然我們也可以直接在config直接修改或者在命令行下重寫節(jié)點(diǎn)名字。(使用es.node.name)
日志輸出配置
Elasticseach使用
Log4j 2
http://logging.apache.org/log4j/2.x/
的格式來輸出日志留搔。
我們可以使用Log4j 2屬性文件來配置Log4j 2 更胖。Elasticsearch開放一個屬性
${sys:es.logs}
這個可以在配置文件中找到,它是用于設(shè)置日志文件存放的目錄隔显。在runtime時這個路徑會成為Elasticsearch log目錄的前綴却妨。
舉個例子:如果你的日志目錄(path.logs)是
/var/log/elasticsearch
然后你的cluster的名字是production,那么${sys:es.logs}將會是
/var/log/elasticsearch/production
appender.rolling.type = RollingFile #1
appender.rolling.name = rolling
appender.rolling.fileName = ${sys:es.logs}.log #2
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c]
%.10000m%n
appender.rolling.filePattern = ${sys:es.logs}-%d{yyyy-MM-dd}.log #3
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy #4
appender.rolling.policies.time.interval = 1 #5
appender.rolling.policies.time.modulate = true #6
1:Configure the RollingFile appender
2:日志輸出到 /var/log/elasticsearch/production.log
3:Roll logs to /var/log/elasticsearch/production-yyyy-MM-dd.log
4:Using a time-based roll policy
5:Roll logs on a daily basis
6:Align rolls on the day boundary (as opposed to rolling every twenty-four hours)
如果你添加.gz或者.zip到appender.roolling.filePattern,那么日志將會被壓縮
Multiple configuration files can be loaded (in which case they will get merged) as long as they are named log4j2.properties
and have the Elasticsearch config directory as an ancestor; this is useful for plugins that expose additional loggers. The logger section contains the java packages and their corresponding log level. The appender section contains the destinations for the logs. Extensive information on how to customize logging and all the supported appenders can be found on the Log4j documentation.
Deprecation logging
名詞解釋:"A deprecation log has been introduced to track calls to deprecated/outdated methods in the TYPO3 Core. Developers have to make sure to adjust their code to avoid using this old functionality since deprecated methods will be removed in future TYPO3 releases! The information can be found in /typo3conf/deprecation_[hash-value].log The install tool has a setting "enableDeprecationLog" that allows one to disable the logging of deprecation messages since the file might grow quite fast depending on the extensions installed."
為了能夠正常地進(jìn)行日志輸出,Elasticsearch允許你使用廢棄的(過時的)
方法括眠。默認(rèn)地管呵,deprecation logging 能夠在WRAN等級下使用:
logger.deprecation.level = warn
詳情參考:
https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html#logging