Elasticsearch
- Elasticsearch is a search engine based on Lucene. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents. Elasticsearch is developed in Java and is released as open source under the terms of the Apache License.
安装[编辑 | 编辑源代码]
Elasticsearch 依赖于 jre-openjdk-headless包,详细信息请参考 Java。
安装 elasticsearchAUR。
运行[编辑 | 编辑源代码]
如果你在 /usr/share/elasticsearch/config/elasticsearch.keystore
位置下还没有密钥库,需要在启动 Elasticsearch 前先创建一个:
# elasticsearch-keystore create
之后就可以启动/启用 elasticsearch.service
。
使用 curl包 来确保 Elasticsearch 正在运行且可被访问,用法为 curl '<protocol>://<host>:<port>'
:
curl http://127.0.0.1:9200
{ "name" : "Sunder", "cluster_name" : "elasticsearch", "cluster_uuid" : "*cluster-uuid*", "version" : { "number" : "2.4.1", "build_hash" : "c67dc32e24162035d18d6fe1e952c4cbcbe79d16", "build_timestamp" : "2016-09-27T18:57:55Z", "build_snapshot" : false, "lucene_version" : "5.5.2" }, "tagline" : "You Know, for Search" }
配置[编辑 | 编辑源代码]
Elasticsearch 的主配置文件位于 /etc/elasticsearch/elasticsearch.yml
位置下,有着完善的说明文档。
- 默认情况下 Elasticsearch 可被公开访问,建议仅允许本机访问:
network.host: 127.0.0.1
- 可以自定义其它端口,而不是使用默认的
9200
端口:
http.port: 9200
你可以修改默认初始及最大可用内存量 [1]:
/etc/elasticsearch/jvm.options.d/.options
# Xms represents the initial size of total heap space # Xmx represents the maximum size of total heap space -Xms2g # e.g. 256m, 512m, 1g, 2g, .. -Xmx2g # e.g. 256m, 512m, 1g, 2g, ..
如果你碰到了 Linux 内存不足报错,可以将其从 4g 修改到 2g。
你可能会需要更新系统 vm.max_map_count 限制:
# sysctl -w vm.max_map_count=262144
用法[编辑 | 编辑源代码]
Elasticsearch 使用了 REST API,更多信息请参考 Wikipedia:RESTful API。
Elasticsearch 向导中的快速指引一节中提供了基础和详细的用法。
Elasticsearch 服务器管理任务(文档管理,执行搜索等)通常是通过客户端来完成的,应能和你喜欢的编程语言无缝结合。
Useful tools to manage ElasticSearch instances and clusters like ElasticHQ, Elasticsearch GUI, Kibana and Adminer are also available to simplify management.
基础安全功能[编辑 | 编辑源代码]
Elasticsearch 从 8.0 开始会默认启用及配置安全功能。
Elasticsearch 提供了一系列文档来帮助配置强制基础安全特性。