本文主要介紹elasticsearch5.0安裝及head插件安裝。確保系統已經安裝好jdk1.8以上,操做系統CentOS6以上。css
1、elasticsearch安裝配置java
1.官網下載源碼包node
下載不一樣版本技巧:linux
複製下載連接修改版本號!git
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.zip
2.解壓安裝github
useradd elasticsearch tar xf elasticsearch-6.3.0.tar.gz -C /usr/local cd /usr/local ln -sv elasticsearch-6.3.0 elasticsearch mkdir -pv /data/elasticsearch/{data,logs} chown -R elasticsearch.elasticsearch /data/elasticsearch
3.修改配置文件shell
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.修改系統參數npm
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.啓動服務bootstrap
su - elasticsearch -c "/usr/local/elasticsearch/bin/elasticsearch &"
瀏覽器訪問:http://192.168.1.12:9200/vim
2、head插件的安裝
在5.0版本中不支持直接安裝head插件,須要啓動一個服務
1.下載插件安裝
先安裝node 自帶一個npm。
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//node-v4.4.7-linux-x64/bin/npm start
瀏覽器訪問 http://123.56.154.68:9100/
IK分詞器安裝:
1. 下載
下載對應的版本: https://github.com/medcl/elasticsearch-analysis-ik
2. 編譯
配置前關閉elasticsearch,安裝完成後再啓動。
下載後,進入elasticsearch-analysis-pinyin-master目錄,mvn打包(未下載maven的自行下載安裝)。
3. 配置
打包成功後,在 elasticsearch-analysis-ik-master\target\releases會有一個elasticsearch-analysis-ik-6.3.0.zip。
把壓縮包複製到 \elasticsearch-6.3.0\plugins\ik中, 沒有文件夾就建立。
而後重啓elasticsearch。
到此安裝完成了!
附:
elasticsearch 安裝過程當中遇到了一些問題,這是在網上找的一些資料
[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_SECCOMP and CONFIG_SECCOMP_FILTER compiled in at org.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版本,就不會出現此類問題了。
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536] max number of threads [1024] for user [lishang] likely too low, increase to at least [2048] max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
解決:切換到root用戶,編輯limits.conf 添加相似以下內容
vi /etc/security/limits.conf
添加以下內容:
* soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096
對於第二條錯誤贊成須要切換到root用戶,進入limits.d目錄下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
修改以下內容:
* soft nproc 1024
#修改成 * soft nproc 2048
第三條錯誤須要切換到root用戶修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
並執行命令:
sysctl -p
而後,從新啓動elasticsearch,便可啓動成功。
**一、Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)**
因爲elasticsearch5.0默認分配jvm空間大小爲2g,修改jvm空間分配
# vim config/jvm.options -Xms2g -Xmx2g 修改成 -Xms512m -Xmx512m
二、max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]修改 /etc/security/limits.d/90-nproc.conf
* soft nproc 1024 * soft nproc 2048
三、max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf配置文件,
cat /etc/sysctl.conf | grep vm.max_map_countvm.max_map_count=262144
若是不存在則添加
echo "vm.max_map_count=262144" >>/etc/sysctl.conf
四、max file descriptors [65535] for elasticsearch process likely too low, increase to at least [65536]
須要執行下面的命令
ulimit -n 65536