通过配置阿里云Elasticsearch实例的YML参数,您可以设置允许自动创建索引、删除索引指定名称、配置Auditlog索引、开启Watcher以及其他配置。本文介绍如何配置YML参数、CORS访问、reindex白名单、Auditlog和queue大小。
注意事项
2020年10月起,由于阿里云Elasticsearch网络架构调整,导致部分通过reindex方式跨集群迁移数据的场景受到了限制。如果需要使用reindex方式跨集群迁移数据,请参见通过实例私网打通将自建Elasticsearch数据迁移至阿里云中的注意事项进行处理。
说明 对于华北3(张家口)和海外地域,由于网络架构调整时间不确定,因此需要提交工单,联系阿里云Elasticsearch技术支持,校验网络是否可以互通。
修改配置
配置CORS访问
通过配置跨域资源共享CORS(Cross-origin resource sharing)访问,设置是否允许其他域资源下的浏览器向阿里云Elasticsearch发送请求。您可以在YML文件配置中,配置CORS访问,支持配置的参数如下。
参数 | 默认值 | 说明 |
---|---|---|
http.cors.enabled | false | 设置是否启用跨域资源访问(Elasticsearch是否允许其他域资源下的浏览器向其发送请求):
|
http.cors.allow-origin | “” | 域资源配置项,可设置接受来自哪些域名的请求。默认不允许接受跨域请求且无配置。支持正则表达式,例如/https?:\/\/localhost(:[0-9]+)?/,表示可响应符合此正则的请求信息。
重要 *是合法配置,表示集群支持来自任意域名的跨域请求,此配置存在安全风险,不建议使用。
|
http.cors.max-age | 1728000(20天) | 浏览器可发送OPTIONS请求以获取CORS配置信息,此配置项可设置获取的信息在浏览器中的缓存时间,单位为秒。 |
http.cors.allow-methods | OPTIONS, HEAD, GET, POST, PUT, DELETE | 请求方法配置项。 |
http.cors.allow-headers | X-Requested-With, Content-Type, Content-Length | 请求头信息配置项。 |
http.cors.allow-credentials | false | 凭证信息配置项目,设置是否允许响应头中返回Access-Control-Allow-Credentials信息:
|
配置reindex白名单
通过当前集群调用reindex API,从远程集群迁移索引数据前,需要先配置reindex白名单。您可以在YML文件配置中,配置reindex白名单,支持配置的参数如下。
参数 | 默认值 | 说明 |
---|---|---|
reindex.remote.whitelist | [] | 设置远程Elasticsearch集群的访问地址,将其添加到当前集群的远程访问白名单中。
白名单支持host和port的组合,并使用逗号分隔多个主机配置(例如otherhost:9200,another:9200,127.0.10.**:9200,localhost:**),不识别协议信息。 |
配置reindex白名单时,如果远程Elasticsearch集群为单可用区的阿里云Elasticsearch实例,请使用<阿里云Elasticsearch实例的域名>:9200;如果为多可用区实例,请使用实例中所有数据节点的IP地址与端口的组合。具体示例如下:
- 单可用区
reindex.remote.whitelist: ["es-cn-09k1rgid9000g****.elasticsearch.aliyuncs.com:9200"]
- 多可用区
reindex.remote.whitelist: ["10.0.xx.xx:9200","10.0.xx.xx:9200","10.0.xx.xx:9200","10.15.xx.xx:9200","10.15.xx.xx:9200","10.15.xx.xx:9200"]
说明 reindex白名单配置完成后,即可调用reindex API重建索引。具体操作,请参见通过reindex迁移数据。
配置Auditlog(审计日志)
Auditlog为审计日志,默认关闭。查看审计日志前,需要先开启Auditlog。开启后,系统会记录Elasticsearch实例对应的增、删、改、查等操作产生的日志。对于审计日志的开启、配置和查看,阿里云Elasticsearch不同版本实例的操作有所不同,具体如下。
说明 关于Auditlog的更多详细信息,请参见Auditing Security Settings。
7.x版本
非7.x版本
配置queue大小
通过自定义queue大小,调整文档写入和搜索的队列大小。您可以在YML文件配置中,配置queue大小。以下示例配置文档写入和搜索queue大小为500和1000,实际业务中请根据具体情况自行调整。
- 5.x版本
thread_pool.bulk.queue_size: 500 thread_pool.search.queue_size: 1000
- 6.x及7.x版本
thread_pool.write.queue_size: 500 thread_pool.search.queue_size: 1000
参数 | 默认值 | 说明 |
---|---|---|
thread_pool.bulk.queue_size | 200 | 文档写入队列大小,适用于阿里云Elasticsearch 5.x版本。 |
thread_pool.write.queue_size | 200 | 文档写入队列大小,适用于阿里云Elasticsearch 6.x及7.x版本。 |
thread_pool.search.queue_size | 1000 | 文档搜索队列大小。
说明 Elasticsearch实例的thread_pool.search.queue_size参数的最大值为1000,调整为1000以上仍取值为1000。
|