elasticsearch 5.4 的插件安裝

head插件

1.修改es參數(shù) (elasticsearch.yml),增加如下參數(shù)

# 增加新的參數(shù),允許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
#修改環(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.啟動插件

cd elasticsearch-head
grunt server &

若出現(xiàn)如下錯誤

>> 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,如下圖則正確

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容