1. 程式人生 > >elasticsearch6.x安裝head外掛

elasticsearch6.x安裝head外掛

1.安裝依賴nodejs

wget --no-check-certificate  https://nodejs.org/dist/v9.9.0/node-v9.9.0-linux-x64.tar.xz
tar -xf node-v9.9.0-linux-x64.tar.xz
mv node-v9.9.0-linux-x64 /usr/local/nodejs

vim /etc/profile
export NODE_HOME=/usr/local/nodejs
export PATH=$PATH:$NODE_HOME/bin
source /etc/profile

2.修改elasticsearch.yml(支援跨域訪問)

# 新增
http.cors.enabled: true
http.cors.allow-origin: "*"

3.獲取elasticsearch-head-master, 並安裝必要元件

wget  https://github.com/mobz/elasticsearch-head/archive/master.zip
# 如無unzip 自行安裝(yum install -y unzip)
unzip master.zip

cd elasticsearch-head-master

# package.json證書失效 替換
vim package.json
license Apache-2.0


npm install -g grunt-cli
npm install grunt --save-dev
grunt -version

4.修改配置

vim Gruntfile.js
connect => server => options 新增 hostname: '172.22.2.15'(本機IP)

vim app.js
localhost替換為安裝es機器的IP (172.17.9.30)

5.測試

grunt server            啟動
nohup grunt server &    後臺啟動

# 如無netstat 安裝(yum install net-tools)
netstat -tunlp | grep 9100  (檢查是否啟動成功) 

http://172.22.2.15:9100

6.其他

在使用的時候會發現基本查詢報404 需要修改vendor.js 將contentType全部替換為application/json;charset=UTF-8