ElasticSearch2.3/2.4升級到ElasticSearch5.0
參考文檔(排名不分先后)
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/1867033
注意最好用elasticsaerch-migration跑一下注意事項,我這里是抱着丟數據index的目的來升級的。
近日,Elastic在官方博客中宣布,Elasticsearch 5.0正式發布。該版本基於Lucene 6.2.0,已經在Elastic Cloud上完成了部署。據稱,這是迄今為止最快、最安全、最易用的版本。
Elasticsearch 5.0帶來了許多增強功能和新特性,主要包括:
索引性能:得益於多項改進,其中包括更好的數值型數據結構,索引吞吐量大幅提升。根據應用場景的不同,索引吞吐量提升在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。
需要注意的是,該版本引入了許多破壞性更改,好在他們提供了一個遷移輔助插件,可以幫助開發人員從Elasticsearch 2.3.x/2.4.x遷移到Elasticsearch 5.0。如果是從更早的Elasticsearch版本向最新的5.0版本遷移,則請查閱升級文檔。
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
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.yml
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
一、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/
二、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