安裝運行
html

一、前置安裝java8java

jdk-8u112-linux-x64.rpmnode

下載地址:http://www.oracle.com/technetwork/java/javase/downloads/index.htmllinux

二、下載git

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.zipgithub

三、解壓npm

unzip elasticsearch-5.1.1.zipbootstrap

四、運行vim

./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]

解決方案

一、vi /etc/sysctl.conf

設置fs.file-max=655350

保存以後sysctl -p使設置生效

二、vi /etc/security/limits.conf 新增

* soft nofile 655350

* hard nofile 655350

三、從新使用SSH登陸,再次啓動elasticsearch便可。

外網訪問:serverip:9200/

 

安裝elasticsearch-head插件

elasticsearch 5之後的版本比較新,不支持直接安裝head插件,如下是github上提供的安裝方法,以下圖示

如下爲我本身整理的方法,參考來源:http://blog.csdn.net/qq942477618/article/details/53637817

一、下載head插件wget https://codeload.github.com/mobz/elasticsearch-head/zip/master二、下載nodejsnodejs官網下載地址https://nodejs.org/dist/wget https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-x64.tar.xz三、配置node環境變量xz –d node-v6.9.2-linux-x64.tar.xztar –xvf node-v6.9.2-linux-x64.tarmv node-v6.9.2-linux-x64 /alidata/app/nodevim /etc/profileexport NODE_HOME=/alidata/app/nodeexport PATH=$PATH:$NODE_HOME/binsource /etc/profile# node –vv6.9.2# npm –v3.10.9四、安裝gruntcd elasticsearch-head-masternpm install -g grunt --registry=https://registry.npm.taobao.org五、測試一下cd elasticsearch-head-mastergrunt出現如下提示,爲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.orgnpm install grunt-contrib-concat --registry=https://registry.npm.taobao.orgnpm install grunt-contrib-watch --registry=https://registry.npm.taobao.orgnpm install grunt-contrib-connect --registry=https://registry.npm.taobao.orgnpm install grunt-contrib-copy --registry=https://registry.npm.taobao.orgnpm install grunt-contrib-jasmine --registry=https://registry.npm.taobao.org六、運行grunt server七、測試http://serverip:9100/修改head目錄下的Gruntfile.js配置,head默認監聽127.0.0.1vm Gruntfile.jshostname: '0.0.0.0',八、爲es設置跨域訪問vi config/elasticsearch.yml         #新增兩行http.cors.enabled: truehttp.cors.allow-origin: "*"九、啓動es,啓動head插件