華為云計(jì)算 云知識(shí) ElasticSearch是什么
ElasticSearch是什么

簡(jiǎn)介

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

配置流程

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

本文選用華為鯤鵬云服務(wù)ECS KC1實(shí)例做測(cè)試,KC1實(shí)例的處理器為兼容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)設(shè)置單進(jìn)程最多內(nèi)存映射大小。

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

vim /etc/sysctl.conf

b.增加vm.max_map_count=262145。

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

sysctl -p

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

系統(tǒng)默認(rèn)文件句柄為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í)行以下命令,重啟機(jī)器使配置生效。

reboot

5)配置ElasticSearch啟動(dòng)文件。

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

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

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

b.  按“Esc”鍵。

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

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

useradd elasticsearch

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

4.測(cè)試已完成編譯的軟件

1) 切換到“elasticsearch”賬號(hào)下,運(yùn)行ElasticSearch。

su - elasticsearch

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

2)打開瀏覽器,輸入U(xiǎn)RL“http:// 云服務(wù)器 公網(wǎng)IP地址:9301”。當(dāng)出現(xiàn)如下圖所示內(nèi)容時(shí),表示ElasticSearch部署完成。

已知問(wèn)題匯總

1. 內(nèi)存映射大小配置問(wèn)題解決

問(wèn)題現(xiàn)象

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

解決方案

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

操作步驟

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

vim /etc/sysctl.conf

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

3)按“Esc”鍵。

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

保存文件內(nèi)容并退出。

2.文件句柄配置過(guò)小問(wèn)題處理

問(wèn)題現(xiàn)象

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

解決方案

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

操作步驟

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

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

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

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

−soft nofile修改為65536。

−hard nofile修改為65536。

3)按“Esc”鍵。

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

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

reboot