Elasticsearch配置

配置文件位置

rpm和Debian安装包默认放在/etc/elasticserach下面。
如果你自己下载java包到/data(注意elasticserach需要java se环境),那么之后根据官方文档的也会放在/data下。

你也可以修配置文件的位置

./bin/elasticsearch -Epath.conf=/path/to/my/config/

配置文件格式:

下面修改数据和日志存放的目录

path: data: /var/lib/elasticsearch 
logs: /var/log/elasticsearch

也可以这样子写

path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch

环境变量的替代

环境变量设置的格式为${...},
例如

node.name:  ${HOSTNAME}
network.host: ${ES_NETWORK_HOST}

第一个修改节点的名字,第二个修改可访问到该节点的IP。

即时设置:(不会被写进去配置文件中)

我们可以使用

${promp.text}
${promp.secret}

在前台中开启elasticsearch,使用prompt.secret时,在终端输入的内容不会显示出来,提高安全性。

例子:

node: name: ${prompt.text}

当我们开启elasticsearch之后,会让你输入节点的名字

Enter value for [node.name]:
注意:Elasticsearch不会把${prompt.text}或者${prompt.secret}的设置用于service或者background的进程。

默认设置

在开启elasticsearch时,可以在命令行中使用

default.

前缀使用默认设置,如下:

./bin/elasticsearch -Edefault.node.name=My_Node

节点的名字就是My_Node。当然我们也可以直接在config直接修改或者在命令行下重写节点名字。(使用es.node.name)

日志输出配置

Elasticseach使用

Log4j 2
http://logging.apache.org/log4j/2.x/

的格式来输出日志。
我们可以使用Log4j 2属性文件来配置Log4j 2 。Elasticsearch开放一个属性

${sys:es.logs}

这个可以在配置文件中找到,它是用于设置日志文件存放的目录。在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."

为了能够正常地进行日志输出,Elasticsearch允许你使用废弃的(过时的)
方法。默认地,deprecation logging 能够在WRAN等级下使用:

logger.deprecation.level = warn

详情参考:

https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html#logging

你可能感兴趣的:(Elasticsearch配置)