ElasticSearch-5.3.1集羣環境搭建,安裝ElasticSearch-head插件,安裝錯誤解決

 

      提及來甚是慚愧,博主在寫這篇文章的時候,尚未系統性的學習一下ES,只知道能夠拿來作全文檢索,功能很牛逼,可是接到了任務不想作也不行,html

leader讓我搭建一下分佈式的ES集羣環境,用來支持企業信用數據的檢索,剛開始寶寶一臉蒙逼,只是以前本身本地搭建過一個測試玩過,開發任務也是忙的不行,java

一直也沒時間好好的研究一下,慚愧。《Elasticsearch服務器開發》已經備好,只能邊學邊開發了,但願本篇拙文能夠幫到有須要的coder們。----jstarsevennode

 

話很少說,開始搭建環境,準備好集羣搭建須要的軟硬件:linux

1.服務器(系統版本 centos7)三臺(沒有的話,能夠在一臺pc上嘗試不一樣端口):git

1. 172.16.31.220github

2. 172.16.31.221npm

3. 172.16.31.224bootstrap

2.JDK (下載最新版本JDK,至少JDK1.8,最新版本ES須要1.8的jdk環境):vim

博主的爲:centos

 

配置JDK1.8環境變量(自行解決。。。)
3.elasticsearch-5.3.1.tar.gz(下載地址:https://www.elastic.co/downloads/elasticsearch)

在220服務器/usr/local/下解壓 tar -zxvf elasticsearch-5.3.1.tar.gz,修改配置文件,vim elasticsearch-5.3.1/config/elasticsearch.yml

220服務器,原有配置文件

修改以後的配置文件:

解釋:

cluster.name: es-cluster-5.3.1   配置集羣名稱 三臺服務器保持一致

node.name: node-1                 配置單一節點名稱,每一個節點惟一標識

network.host: 0.0.0.0              設置綁定的ip地址

http.port: 9200                      端口

discovery.zen.ping.unicast.hosts: ["172.16.31.220", "172.16.31.221","172.16.31.224"]   集羣節點ip或者主機

discovery.zen.minimum_master_nodes: 3    設置這個參數來保證集羣中的節點能夠知道其它N個有master資格的節點。默認爲1,對於大的集羣來講,能夠設置大一點的值(2-4)

下面兩行配置爲haad插件配置,三臺服務器一致。

http.cors.enabled: true
http.cors.allow-origin: "*"

ok,220服務器修改完畢。

 [轉載請註明原文出處]:http://www.cnblogs.com/jstarseven/p/6803054.html

221服務器ES配置文件修改   vim elasticsearch-5.3.1/config/elasticsearch.yml

cluster.name: es-cluster-5.3.1

node.name: node-2               

network.host: 0.0.0.0            

http.port: 9200                     

discovery.zen.ping.unicast.hosts: ["172.16.31.220", "172.16.31.221","172.16.31.224"]  

discovery.zen.minimum_master_nodes: 3

http.cors.enabled: true
http.cors.allow-origin: "*"

 

224服務器ES配置文件修改   vim elasticsearch-5.3.1/config/elasticsearch.yml

cluster.name: es-cluster-5.3.1

node.name: node-3               

network.host: 0.0.0.0            

http.port: 9200                     

discovery.zen.ping.unicast.hosts: ["172.16.31.220", "172.16.31.221","172.16.31.224"]  

discovery.zen.minimum_master_nodes: 3

http.cors.enabled: true
http.cors.allow-origin: "*"

到這裏集羣就算配置完畢了,可是ES5.3.1不容許使用root用戶運行,否則啓動會報錯,Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.

因此新建用戶(三臺服務器,都要新建)

groupadd elsearch                                             新增elsearch用戶組
useradd elsearch -g elsearch -p elasticsearch        建立elsearch用戶

chown -R elsearch:elsearch ./elasticsearch-5.3.1    用戶目錄權限

運行操做,開啓三臺服務

切換到elsearch用戶下,su elsearch,cd /usr/local/elasticsearch-5.3.1  執行命令./bin/elasticsearch

觀察運行日誌:

能夠看到集羣已經成功運行,選舉了node-3節點爲master節點

測試,節點啓動狀況: curl  http://172.16.31.220:9200/,集羣狀況安裝好了head插件,便可顯示

固然配置完成以後,啓動的時候出現了不少的錯誤,錯誤彙總<部分問題來源於網絡,感謝你們的以後,博主在此彙總一下>:

問題一:

[2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] unable to install syscall filter:
Java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMPandCONFIG_SECCOMP_FILTERcompiledinatorg.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]
緣由:只是一個警告,主要是由於Linux版本太低形成的。
解決方案:一、從新安裝新版本的Linux系統 二、警告不影響使用,能夠忽略
 
問題二:
ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
緣由:沒法建立本地文件問題,用戶最大可建立文件數過小
 
解決方案:
切換到root用戶,編輯limits.conf配置文件, 添加相似以下內容:
vi /etc/security/limits.conf
添加以下內容:
*  soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
備註:* 表明Linux全部用戶名稱(好比 hadoop)
保存、退出、從新登陸纔可生效
 
問題三:
max number of threads [1024] for user [es] likely too low, increase to at least [2048]
緣由:沒法建立本地線程問題,用戶最大可建立線程數過小
解決方案:切換到root用戶,進入limits.d目錄下,修改90-nproc.conf 配置文件。
vi /etc/security/limits.d/90-nproc.conf
找到以下內容:
* soft nproc 1024
#修改成
* soft nproc 2048
 
問題四:
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
緣由:最大虛擬內存過小
解決方案:切換到root用戶下,修改配置文件sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
並執行命令:
sysctl -p
而後從新啓動elasticsearch,便可啓動成功。
 
問題五:
ElasticSearch啓動找不到主機或路由
緣由:ElasticSearch 單播配置有問題
解決方案:
檢查ElasticSearch中的配置文件
vi  config/elasticsearch.yml
找到以下配置:
discovery.zen.ping.unicast.hosts: ["172.16.31.220", "172.16.31.221","172.16.31.224"]  
通常狀況下,是這裏配置有問題,注意書寫格式
 
問題六:
org.elasticsearch.transport.RemoteTransportException: Failed to deserialize exception response from stream
緣由:ElasticSearch節點之間的jdk版本不一致
解決方案:ElasticSearch集羣統一jdk環境
 
問題七:
Unsupported major.minor version 52.0
緣由:jdk版本問題過低
解決方案:更換jdk版本,ElasticSearch5.0.0支持jdk1.8.0
 
問題八:
bin/elasticsearch-plugin install license
ERROR: Unknown plugin license
 
緣由:ElasticSearch5.0.0之後插件命令已經改變
解決方案:使用最新命令安裝全部插件

bin/elasticsearch-plugin install x-pack

問題九:

啓動異常:ERROR: bootstrap checks failed
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

問題緣由:由於Centos6不支持SecComp,而ES5.2.1默認bootstrap.system_call_filter爲true進行檢測,因此致使檢測失敗,失敗後直接致使ES不能啓動。詳見 :https://github.com/elastic/elasticsearch/issues/22899

解決方法:在elasticsearch.yml中配置bootstrap.system_call_filter爲false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

問題十:

Failed to send join request to master [{node-1}{WbcP0pC_T32jWpYvu5is1A}{2_LCVHx1QEaBZYZ7XQEkMg}{10.10.11.200}{10.10.11.200:9300}], reason [RemoteTransportException[[node-1][10.10.11.200:9300][internal:discovery/zen/join]]; nested: IllegalArgumentException[can't add node {node-2}{WbcP0pC_T32jWpYvu5is1A}{p-HCgFLvSFaTynjKSeqXyA}{10.10.11.200}{10.10.11.200:9301}, found existing node {node-1}{WbcP0pC_T32jWpYvu5is1A}{2_LCVHx1QEaBZYZ7XQEkMg}{10.10.11.200}{10.10.11.200:9300} with the same id but is a different node instance]; ]

問題緣由:要是部署的時候從一個節點複製elasticsearch文件夾,其餘節點可能包含被複制節點的data文件數據,須要把data文件下的文件清空

到這裏基本上集羣搭建起來就沒什麼問題了,若是還不能正常啓動,麻煩各位解決了,通知我一聲,我也好記錄一下,哈哈哈。

 

下面說ElasticSearch-head插件在ElasticSearch-5.3.1中的安裝使用:

1.安裝nodejs環境

1) wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.4.7-linux-x64.tar.gz
2) tar -zxvf node-v4.4.7-linux-x64.tar.gz

3) vim /etc/profile
4)source /etc/profile
5) 追加 export PATH=$PATH:/opt/node-v4.4.7-linux-x64/bin 至文件最後

測試 node --version
v4.4.7

2.安裝npm

     下載nmp安裝包,通常nodejs包中已經包含了,設置過環境變量就能夠直接使用nmp命令了,若是沒有安裝,先下載:

  官網地址:www.npmjs.com 

  淘寶地址:https://npm.taobao.org/mirrors/npm/

  安裝使用以下命令:

  node cli.js install npm -gf

3.安裝grunt

 1)安裝grunt命令行工具grunt-cli      npm install -g grunt-cli

 2)安裝grunt及其插件                     npm install grunt --save-dev 

 可使用grunt -version查看安裝版本狀況  

而後,在220服務器上,

git clone git://github.com/mobz/elasticsearch-head.git

cd elasticsearch-head

npm install

npm install grunt --save

修改elasticsearch-head下Gruntfile.js文件,默認監聽在127.0.0.1下9200端口,

而後cd /usr/local/elasticsearch-head  執行grunt server

瀏覽器訪問 http://172.16.31.220:9100/

出現一下界面:

ok 到此,ElasticSearch-5.3.1集羣,以及head插件的安裝就結束了。

 [轉載請註明原文出處]:http://www.cnblogs.com/jstarseven/p/6803054.html,這麼多字,博主碼的也挺累的,謝謝合做。

  


  -END-

相關文章
相關標籤/搜索