[elk]elasticsearch5.0及head插件安裝

 

ElasticSearch2.3/2.4升級到ElasticSearch5.0html

參考文檔(排名不分前後)
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/setup-upgrade.html
https://github.com/elastic/elasticsearch-migration/
http://www.infoq.com/cn/news/2016/08/Elasticsearch-5-0-Elastic
http://hnr520.blog.51cto.com/4484939/1867033java

注意最好用elasticsaerch-migration跑一下注意事項,我這裏是抱着丟數據index的目的來升級的。node

近日,Elastic在官方博客中宣佈,Elasticsearch 5.0正式發佈。該版本基於Lucene 6.2.0,已經在Elastic Cloud上完成了部署。據稱,這是迄今爲止最快、最安全、最易用的版本。linux

Elasticsearch 5.0帶來了許多加強功能和新特性,主要包括:nginx

索引性能:得益於多項改進,其中包括更好的數值型數據結構,索引吞吐量大幅提高。根據應用場景的不一樣,索引吞吐量提高在25%到80%之間。
Ingest節點:向Elasticsearch添加數據更簡單了。Logstash是一個強大的工具,而一些較小的用戶只須要過濾器,不須要它所提供的衆多路由選項。所以,Elastic將一些最流行的Logstash過濾器(如grok、split)直接在Elasticsearch中實現爲處理器。多個處理器能夠組合成一個管道,在索引時應用到文檔上。
Painless腳本:Elasticsearch中不少地方用到了腳本,而出於安全考慮,腳本在默認狀況下是禁用的,這使人至關失望。爲此,Elastic開發了一種新的腳本語言Painless。該語言更快、更安全,並且默認是啓用的。不只如此,它的執行速度是Groovy的4倍,並且正在變得更快。Painless已經成爲默認腳本語言,而Groovy、Javascript和Python都遭到棄用。要了解有關這門新語言的更多信息,請點擊這裏。
新數據結構:Lucene 6帶來了一個新的Points 數據結構K-D樹,用於存儲數值型和地理位置字段,完全改變了數值型值的索引和搜索方式。基準測試代表,Points將查詢速度提高了36%,將索引速度提高了71%,而佔用的磁盤和內存空間分別減小了66%和85%(參見「在5.0中搜索數值」)。
搜索和聚合:藉助即時聚合,Kibana圖表生成速度顯著提高。Elastic用一年的時間對搜索API進行了重構,Elasticsearch如今能夠更巧妙地執行範圍查詢,只針對已經發生變化的索引從新計算聚合,而不是針對每一個查詢從頭開始從新計算。在搜索方面,默認的相關性計算已經由TF/IDF換成了更先進的BM25。補全建議程序通過了徹底重寫,將已刪除的文檔也考慮了進來。
更友好:Elasticsearch 5.0更安全、更易用。他們採用了「儘早提示」的方法。若是出現了問題,則新版本會及早給出提示。例如,Elasticsearch 5.0會嚴格驗證設置。若是它不能識別某項設置的值,就會給出提示和建議。不只如此,集羣和索引設置如今能夠經過null進行解除。此外,還有其餘的一些改進,例如,rollover和shrink API啓用了一種新的模式來管理基於時間的索引,引入新的cluster-allocation-explain API,簡化索引建立。
彈性:Elasticsearch分佈式模型的每一部分都被分解、重構和簡化,提高了可靠性。集羣狀態更新如今會等待集羣中的全部節點確認。若是一個「複製片(replica shard)」被「主片(primary)」標記爲失敗,則主片會等待「主節點(master)」的響應。索引如今使用數據路徑中的UUID,而不是索引名,避免了命名衝突。另外,Elasticsearch如今進行啓動檢查,確保系統配置沒有問題。配置比較麻煩,但若是隻是試用,開發人員也能夠選擇localhost-only模式,避免繁瑣的配置。另外,新版本還增長了斷路器及其餘一些軟限制,限制請求使用的內存大小,保護集羣免受惡意用戶攻擊。
此外,該版本還提供了一個底層的Java REST/HTTP客戶端,能夠用於監聽、日誌記錄、請求輪詢、故障節點重試等。它使用Java 7,將依賴降到了最低,比Transport客戶端的依賴衝突少。而在基準測試中,它的性能並不輸於Transport客戶端。不過,這是一個底層客戶端,目前尚未提供任何查詢構建器或輔助器。它的輸入參數和輸出結果都是JSON。git

須要注意的是,該版本引入了許多破壞性更改,好在他們提供了一個遷移輔助插件,能夠幫助開發人員從Elasticsearch 2.3.x/2.4.x遷移到Elasticsearch 5.0。若是是從更早的Elasticsearch版本向最新的5.0版本遷移,則請查閱升級文檔。github

1,卸載原軟件安裝新軟件
cd /usr/local/src
rpm -e elasticsearch
rpm -e kibana
rpm -ivh elasticsearch-5.0.0.rpm kibana-5.0.0-x86_64.rpm npm

2,大概看了下配置文件沒什麼改動就直接用原來的
diff elasticsearch.yml elasticsearch.yml.rpmsave
mv elasticsearch.yml elasticsearch.yml.default
cp -f elasticsearch.yml.rpmsave elasticsearch.yml
chown elasticsearch:elasticsearch /etc/elasticsearch/elasticsearch.ymlcentos

3,根據官網建議添加了以下配置到elasticsearc.yml主配置文件
http.cors.enabled: true
http.cors.allow-origin: "*"瀏覽器


4,啓動新的elasticsearch
啓動過程一直失敗,經過查看錯誤日誌發現以下問題總結以下:

問題一
[2016-11-07T11:37:54,191][WARN ][o.e.b.JNANatives ] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
[2016-11-07T11:37:54,191][WARN ][o.e.b.JNANatives ] This can result in part of the JVM being swapped out.
[2016-11-07T11:37:54,191][WARN ][o.e.b.JNANatives ] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536
[2016-11-07T11:37:54,191][WARN ][o.e.b.JNANatives ] These can be adjusted by modifying /etc/security/limits.conf, for example:
# allow user 'elasticsearch' mlockall
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited

解決方法:
/etc/security/limits.conf
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited


問題二
Found index level settings on node level configuration.

Since elasticsearch 5.x index level settings can NOT be set on the nodes
configuration like the elasticsearch.yaml, in system properties or command line
arguments.In order to upgrade all indices the settings must be updated via the
/${index}/_settings API. Unless all settings are dynamic all indices must be closed
in order to apply the upgradeIndices created in the future should use index templates
to set default values.

解決方法:
註釋主配置文件裏面的,官方建議生成索引時再設置
# index.number_of_shards: 5
# index.number_of_replicas: 1

Please ensure all required values are updated on all indices by executing:

curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
"index.number_of_replicas" : "1",
"index.number_of_shards" : "10"
}'


問題三
java.lang.IllegalArgumentException: unknown setting [node.rack] please check that any required plugins are installed, or check the breaking changes documentation for removed settings

解決方法:
這個是diff時惟一不一樣的地方,至於爲啥這樣改官網有介紹
# node.rack: r1
node.attr.rack: r1


問題四
[2016-11-07T12:26:05,957][ERROR][o.e.b.Bootstrap ] Exception
java.lang.IllegalArgumentException: unknown setting [script.indexed] did you mean any of [script.inline, script.ingest]?

解決方法:
目前我註釋了,這個應該是語法錯誤,後續再查官網
#script.inline: true
#script.indexed: true


問題五,
max file descriptors [65535] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [elasticsearch] likely too low, increase to at least [2048]

解決方法:
報錯信息直接提示了修改limits.conf的相關參數
elasticsearch soft nofile 65536
elasticsearch hard nofile 131072
elasticsearch soft nproc 2048
elasticsearch hard nproc 4096

 

==================================================================

01.Elasticsearch5.0安裝

(1)下載地址:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.0.zip

(2)jdk安裝
tar xf jdk-8u101-linux-x64.tar.gz
mv jdk1.8.0_101 /usr/local/.
cd /usr/local/
ln -sf jdk1.8.0_101 jdk

vi /etc/profile
最後添加:
export JAVA_HOME=/usr/local/jdk
export JAVA_BIN=$JAVA_HOME/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

從新加載profile配置
source /etc/profile

檢測jdk是否安裝成功.
java -version

(2)安裝Elasticsearch
unzip elasticsearch-5.0.0.zip
mkdir /data
mv elasticsearch-5.0.0 /data/.
cd /data/
ln -sf elasticsearch-5.0.0 elasticsearch

useradd nginx
chown -R nginx.nginx elasticsearch*

配置系統最大文件數
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536

修改最大線程數的配置
vi /etc/security/limits.d/90-nproc.conf
* soft nproc 4096
root soft nproc unlimited

內存過小須要修改
vi /data/elasticsearch/config/jvm.options
將-Xmx2g改爲-Xmx512m
將-Xms2g改爲-Xms512m
-Xms512m
-Xmx512m

vi /etc/sysctl.conf
vm.max_map_count=262144
sysctl -p

(3)啓動elasticsearch
vi elasticsearch.yml
配置
network.host: 本機IP地址
http.port: 9200
啓動
su - nginx
/data/elasticsearch/bin/elasticsearch -d


其餘安裝資料彙總
設置內核參數
vi /etc/sysctl.conf
# 增長下面的內容
fs.file-max=65536
vm.max_map_count=262144

設置資源參數
vi /etc/security/limits.conf
# 修改
* soft nofile 32768
* hard nofile 65536

修改進程數
ulimit -u 2048

 

 

 

 

 

 

 

這個瞎jb整了半天.準備把es2.4升級到5.0,結果老報錯

環境:centos6.5+es2.4是ok的換成es5就出毛病.也不能說啥 ,我用的是最新的

源碼解壓啓動時候報錯,具體錯誤forget already.

折騰了下,沒什麼心情了.放棄了.

心想,難道es5高大上了?只能跑c7了?

可能性不大.能有時間再搞.

 

不過搞的過程當中收穫了點東西

1,修改ulimit 咱們通常是65535,而我啓動es5時候要求我改爲65536

cat /etc/security/limits.conf

*               soft    nproc           65536

*               hard    nproc           65536

*               soft    nofile          65536

*               hard    nofile          65536

cat /etc/sysctl.conf

vm.max_map_count= 262144

sysctl -p

2,跨用戶啓動es. es本只能在普通用戶下啓動.

導致我一度要切到普通用戶而後啓動,這樣給開機自啓動形成了困擾.

su - elasticsearch -c "/usr/local/elasticsearch/bin/elasticsearch &"

3,

 

 

 

 

 

 

 

本文主要介紹elasticsearch5.0安裝及head插件安裝。

確保系統已經安裝好jdk1.8.0_73以上,操做系統centos6以上。

 

 

 

 

原文:

http://hnr520.blog.51cto.com/4484939/1867033

 

1、elasticsearch安裝配置

1.官網下載源碼包

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

2.解壓安裝

1

2

3

4

5

6

useradd elasticsearch

tar xf elasticsearch-5.0.0.tar.gz -C /usr/local

cd /usr/local

ln -sv elasticsearch-5.0.0 elasticsearch

mkdir -pv /data/elasticsearch/{data,logs}

chown -R elasticsearch.elasticsearch /data/elasticsearch

3.修改配置文件

1

2

3

4

5

6

cat /usr/local/elasticsearch/config/elasticsearch.yml

path.data:/data/elasticsearch/data

path.logs:/data/elasticsearch/logs

network.host:192.168.1.12

http.cors.enabled:true

http.cors.allow-origin:"*"

4.修改系統參數

1

2

3

4

5

6

7

8

cat /etc/security/limits.conf

*               soft    nproc           65536

*               hard    nproc           65536

*               soft    nofile          65536

*               hard    nofile          65536

cat /etc/sysctl.conf

vm.max_map_count= 262144

sysctl -p

5.啓動服務

su - elasticsearch -c "/usr/local/elasticsearch/bin/elasticsearch &"

瀏覽器訪問:http://192.168.1.12:9200/

2、head插件的安裝

在5.0版本中不支持直接安裝head插件,須要啓動一個服務

1.下載插件安裝

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

cd elasticsearch-head

npm install

在elasticsearch-head目錄下node_modules/grunt下若是沒有grunt二進制程序,須要執行

cd elasticsearch-head

npm install grunt --save

2.修改配置

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

3.啓動服務

/usr/local/elasticsearch-head/node_modules/grunt/bin/gruntserver

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

相關文章
相關標籤/搜索