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 提供了一系列文檔來幫助配置強制基礎安全特性。