head插件
1.修改es參數(shù) (elasticsearch.yml)咱台,增加如下參數(shù)
# 增加新的參數(shù)图焰,允許js跨域訪問(wèn)盐碱,這樣head插件可以訪問(wèn)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
#修改環(huán)境變量(/etc/profile 增加如下)
export NODE_HOME=/opt/app/node/node-v6.9.1-linux-x64
export PATH=$PATH:$NODE_HOME/bin
#設(shè)置npm的代理鏡像
npm config set registry https://registry.npm.taobao.org
4.配置grunt構(gòu)建工具
cd elasticsearch-head
npm install -g grunt
npm install grunt --save
5.修改Gruntfile.js
#增加hostname屬性矿咕,設(shè)置為'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
#修改如下參數(shù)
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";把localhost修改成你es的服務(wù)器地址
7.啟動(dòng)插件
cd elasticsearch-head
grunt server &
若出現(xiàn)如下錯(cuò)誤
>> 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?
手動(dòng)安裝報(bào)錯(cuò)的模塊
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.測(cè)試
訪問(wèn) ip:9100抢肛,如下圖則正確