華為云計算 云知識 ElasticSearch是什么
ElasticSearch是什么

簡介

ElasticSearch是一個基于Lucene的搜索服務器。它提供了一個分布式多用戶能力的全文搜索引擎。

配置流程

1. 操作系統(tǒng)選擇

本文選用華為鯤鵬云服務ECS KC1實例做測試,KC1實例的處理器為兼容ARMv8指令集的鯤鵬920

2. 獲取軟件包

執(zhí)行如下命令,獲取軟件包。

cd /usr/local/src

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz

3.編譯環(huán)境配置

1)安裝JDK。

yum install -y java-1.8.0-openjdk

2)解壓軟件包。

tar -xvf elasticsearch-5.6.3.tar.gz

3)設置單進程最多內存映射大小。

a. 修改單進程最多可用于內存映射區(qū)大小為262145(ElasticSearch要求最小為262144)。

vim /etc/sysctl.conf

b.增加vm.max_map_count=262145。

c. 執(zhí)行如下命令使配置生效。

sysctl -p

4)修改系統(tǒng)支持的文件句柄為65536。

系統(tǒng)默認文件句柄為65535,您可用ulimit -n查詢,ElasticSearch要求最低為65536。

a. 執(zhí)行以下命令,編輯huawei-nofile.conf文件。

vi /etc/security/limits.d/huawei-nofile.conf

b.配置參數(shù),如下圖所示。

soft nofile修改為65536。

hard nofile修改為65536。

c.按“Esc”鍵。

d. 輸入“:wq”保存并退出。

e. 執(zhí)行以下命令,重啟機器使配置生效。

reboot

5)配置ElasticSearch啟動文件。

a.執(zhí)行以下命令,編輯ElasticSearch啟動文件。

vi /usr/local/src/elasticsearch-5.6.3/config/elasticsearch.yml

network.host修改為本地地址,http.port端口改為9301。

b.  按“Esc”鍵。

c. 輸入“:wq”保存并退出。

6) 創(chuàng)建賬戶并配備權限(ElasticSearch不支持root直接運行)。

useradd elasticsearch

chown elasticsearch:elasticsearch /usr/local/src/elasticsearch-5.6.3 -R

4.測試已完成編譯的軟件

1) 切換到“elasticsearch”賬號下,運行ElasticSearch。

su - elasticsearch

/usr/local/src/elasticsearch-5.6.3/bin/elasticsearch

2)打開瀏覽器,輸入URL“http:// 云服務器 公網IP地址:9301”。當出現(xiàn)如下圖所示內容時,表示ElasticSearch部署完成。

已知問題匯總

1. 內存映射大小配置問題解決

問題現(xiàn)象

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解決方案

修改單進程最多可用于內存映射區(qū)大小為262145(elasticsearch要求最小為262144)。

操作步驟

1)執(zhí)行如下命令,編輯配置文件。

vim /etc/sysctl.conf

2)增加vm.max_map_count=262145,如下圖所示。

3)按“Esc”鍵。

4)輸入“:wq”保存并退出。

保存文件內容并退出。

2.文件句柄配置過小問題處理

問題現(xiàn)象

max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]

解決方案

修改系統(tǒng)當前支持的文件句柄為65536(系統(tǒng)默認為65535,可用ulimit -n查詢,elasticsearch要求最低為65536)

操作步驟

1)執(zhí)行如下命令,編輯配置文件。

vi /etc/security/limits.d/huawei-nofile.conf

該文件是華為OS加固的文件,因此修改/etc/security/limits.conf參數(shù)無效,需要修改/etc/security/limits.d/huawei-nofile.conf。

2)配置參數(shù),如下圖所示。

−soft nofile修改為65536。

−hard nofile修改為65536。

3)按“Esc”鍵。

4)輸入“:wq”保存并退出。

5)執(zhí)行以下命令,重啟機器使配置生效。

reboot