Elasticsearch 5常見問題解決方案
安裝運行
1、前置安裝java8
jdk-8u112-linux-x64.rpm
下載地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html
2、下載
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.zip
3、解壓
unzip elasticsearch-5.1.1.zip
4、運行
./bin/elasticsearch
./bin/elasticsearch -d #後臺運行
tail -f logs/elasticsearch.log #查看日誌
註:ES有執行腳本的能力,因安全因素,不能在root用戶下運行,強行運行會報如下錯誤:
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
解決方案:
groupadd es #增加es組
useradd es -g es -p pwd #增加es用戶並附加到es組
chown -R es:es elasticsearch-5.1.1 #給目錄權限
su es #使用es用戶
./bin/elasticsearch -d #後臺運行es
外網訪問
vi conf/elasticsearch.yml
修改network.host: 0.0.0.0
再次啟動linux可能出現如下類似錯誤
bootstrap checks failed
max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
解決方案
1、vi /etc/sysctl.conf
設置fs.file-max=655350
保存之後sysctl -p使設置生效
2、vi /etc/security/limits.conf 新增
* soft nofile 655350
* hard nofile 655350
3、重新使用SSH登錄,再次啟動elasticsearch即可。
外網訪問:serverip:9200/
安裝elasticsearch-head插件
elasticsearch 5以後的版本比較新,不支持直接安裝head插件,以下是github上提供的安裝方法,如下圖示
以下為我自己整理的方法,參考來源:http://blog.csdn.net/qq942477618/article/details/53637817
1、下載head插件
wget https://codeload.github.com/mobz/elasticsearch-head/zip/master
2、下載nodejs
nodejs官網下載地址https://nodejs.org/dist/
wget https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-x64.tar.xz
3、配置node環境變量
xz –d node-v6.9.2-linux-x64.tar.xz
tar –xvf node-v6.9.2-linux-x64.tar
mv node-v6.9.2-linux-x64 /alidata/app/node
vim /etc/profile
export NODE_HOME=/alidata/app/node
export PATH=$PATH:$NODE_HOME/bin
source /etc/profile
# node –v
v6.9.2
# npm –v
3.10.9
4、安裝grunt
cd elasticsearch-head-master
npm install -g grunt --registry=https://registry.npm.taobao.org
5、測試一下
cd elasticsearch-head-master
grunt
出現以下提示,為Gruntfile.js引用的,缺少以下包
>> Local Npm module "grunt-contrib-clean" not found. Is it installed?
>> Local Npm module "grunt-contrib-concat" not found. Is it installed?
>> Local Npm module "grunt-contrib-watch" not found. Is it installed?
>> Local Npm module "grunt-contrib-connect" not found. Is it installed?
>> Local Npm module "grunt-contrib-copy" not found. Is it installed?
>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?
Warning: Task "connect:server" not found. Use --force to continue.
Aborted due to warnings.
安裝
npm install grunt-contrib-clean --registry=https://registry.npm.taobao.org
npm install grunt-contrib-concat --registry=https://registry.npm.taobao.org
npm install grunt-contrib-watch --registry=https://registry.npm.taobao.org
npm install grunt-contrib-connect --registry=https://registry.npm.taobao.org
npm install grunt-contrib-copy --registry=https://registry.npm.taobao.org
npm install grunt-contrib-jasmine --registry=https://registry.npm.taobao.org
6、運行
grunt server
7、測試
http://serverip:9100/
修改head目錄下的Gruntfile.js配置,head默認監聽127.0.0.1
vm Gruntfile.js
hostname: ‘0.0.0.0‘,
8、為es設置跨域訪問
vi config/elasticsearch.yml #新增兩行
http.cors.enabled: true
http.cors.allow-origin: "*"
9、啟動es,啟動head插件
本文出自 “菜鳥也想飛” 博客,請務必保留此出處http://xiumin.blog.51cto.com/6205237/1933174
Elasticsearch 5常見問題解決方案