centos7上elastic search安裝詳解

本文主要介紹了centos7上elastic search安裝及填坑記,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧,希望能幫助到大家。

本文介紹了centos7上elastic search安裝及填坑記,分享給大家,下面一起來看看。

課程推薦→:《elasticsearch全文搜索實戰》(實戰視頻)來自課程《千萬級數據并發解決方案(理論+實戰)》

下載elastic search 5.3.0

wget?https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.0.tar.gz mv?elasticsearch-5.3.0.tar.gz?/opt cd?/opt tar?-xzvf?elasticsearch-5.3.0.tar.gz cd?elasticsearch-5.3.0/

啟動ES

cd?/bin ./elasticsearch

按照道理應該就可以了,然而接下來各種坑一一出現,分別闡述

錯誤1:error=’Cannot allocate memory’ (errno=12)

centos7上elastic search安裝詳解

error=’Cannot allocate memory’

solutions:

由于elasticsearch5.0默認分配jvm空間大小為2g,需要改小一點

vim?config/jvm.options? -Xms2g?→?-Xms512m -Xmx2g?→?-Xmx512m

錯誤2: can not run elasticsearch as root

centos7上elastic search安裝詳解

can not run elasticsearch as root

solutions:

在 Linux 環境中,elasticsearch 不允許以 root 權限來運行!所以需要創建一個非root用戶,以非root用戶來起es

groupadd?elk?#?創建用戶組elk useradd?elk?-g?elk?-p?111111?#?創建新用戶elk,-g?elk?設置其用戶組為?elk,-p?111?設置其密碼6個1 chown?-R?elk:elk?/opt?#?更改?/opt?文件夾及內部文件的所屬用戶及組為?elk:elk su?elk?#?切換到非root用戶elk下來

錯誤3:(1) max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
(2) max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
此錯誤出現在修改config/elasticsearch.yml中的network.host為network.host: 0.0.0.0以便讓外網任何IP都能來訪問時。

solutions:

切換到root用戶,然后

vim?/etc/security/limits.conf *?soft?nofile?300000 *?hard?nofile?300000 *?soft?nproc?102400 *?soft?memlock?unlimited *?hard?memlock?unlimited

centos7上elastic search安裝詳解

/etc/security/limits.conf

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

centos7上elastic search安裝詳解

vm.max_map_count is too low

solutions:

先要切換到root用戶;

然后可以執行以下命令,設置 vm.max_map_count ,但是重啟后又會恢復為原值。

sysctl?-w?vm.max_map_count=262144

持久性的做法是在 /etc/sysctl.conf 文件中修改 vm.max_map_count 參數:

echo?"vm.max_map_count=262144"?>?/etc/sysctl.conf sysctl?-p

centos7上elastic search安裝詳解

最后終于在外網訪問成功:

centos7上elastic search安裝詳解

外網訪問成功!

安裝可視化插件 elasticsearch-head

git?clone?git://github.com/mobz/elasticsearch-head.git cd?elasticsearch-head npm?install??#?此處我試圖用cnpm?install有問題,用npm可以 npm?run?start

centos7上elastic search安裝詳解

然后在外網訪問http://你的安裝機IP:9100

centos7上elastic search安裝詳解

訪問elasticsearch-head可視化界面成功

最后實際簡單測試一下

新建 Index,可以直接向 Elastic 服務器發出 PUT 請求。下面的例子是新建一個名叫weather的 Index。

centos7上elastic search安裝詳解

用rest接口向es添加index

然而刷新elasticsearch-head可視化界面可以看到索引已經成功插入

centos7上elastic search安裝詳解

索引已經插入

相關推薦:

CentOS7中apache與php7及mysql5.7的安裝配置詳解

CentOS7中apache與php7及mysql5.7的安裝配置詳解

CentOS7中apache與php7及mysql5.7的安裝配置詳解

? 版權聲明
THE END
喜歡就支持一下吧
點贊7 分享