elasticsearch 5.4 的插件安装

head插件

1.修改es参数 (elasticsearch.yml),增加如下参数

# 增加新的参数,允许js跨域访问,这样head插件可以访问es
http.cors.enabled: true
http.cors.allow-origin: "*"

2.安装git,下载源码

#若已安装git省略安装
yum -y install git
git clone git://github.com/mobz/elasticsearch-head.git

3.安装node

cd /opt/app/node
wget https://nodejs.org/dist/v6.9.1/node-v6.9.1-linux-x64.tar.xz
yum -y install xz
xz -d node-v6.9.1-linux-x64.tar.xz
tar xf node-v6.9.1-linux-x64.tar
#修改环境变量(/etc/profile 增加如下)
export NODE_HOME=/opt/app/node/node-v6.9.1-linux-x64
export PATH=$PATH:$NODE_HOME/bin
#设置npm的代理镜像
npm config set registry https://registry.npm.taobao.org

4.配置grunt构建工具

cd elasticsearch-head
npm install -g grunt
npm install grunt --save

5.修改Gruntfile.js

#增加hostname属性,设置为'0.0.0.0'
connect: {
    server: {
        options: {
            port: 9100,
            hostname: '0.0.0.0',
            base: '.',
            keepalive: true
        }
    }
}

6.修改head的连接地址:

cd /opt/app/elasticsearch/plugin/elasticsearch-head/_site
vim app.js
#修改如下参数
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";把localhost修改成你es的服务器地址

7.启动插件

cd elasticsearch-head
grunt server &

若出现如下错误

>> 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?

手动安装报错的模块

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

8.测试
访问 ip:9100,如下图则正确

elasticsearch 5.4 的插件安装_第1张图片

你可能感兴趣的:(elasticsearch 5.4 的插件安装)