1. 程式人生 > >Elasticsearch5.5 部署Head插件

Elasticsearch5.5 部署Head插件

func his 機制 usr 屬性 value container targe keep

1、git下載軟件包

yum -y install git
git clone git://github.com/mobz/elasticsearch-head.git

備註:安裝包不要放到elasticsearch/plugins目錄下

2、node安裝

http://www.cnblogs.com/shhnwangjian/p/6559732.html

2.1、下載編譯好的文件

1 2 3 yum -y install wget cd /usr/local/src/ wget http://nodejs.org/dist/v6.9.4/node-v6.9.4-linux-x64.tar.gz

2.2、解壓

1 tar -xvf node-v6.9.4-linux-x64.tar.gz

2.3、查看版本信息

1 2 cd /usr/local/src/node-v6.9.4-linux-x64/bin ./node -v

2.4、設置全局

1 2 ln -s /usr/local/src/node-v6.9.4-linux-x64/bin/node /usr/local/bin/node ln -s /usr/local/src/node-v6.9.4-linux-x64/bin/npm /usr/local/bin/npm

或者設置NODE_HOME環境變量

1 2 export NODE_HOME=/usr/local/src/node-v6.9.14-linux-x64 export PATH=$NODE_HOME/bin:$PATH

2.5、淘寶鏡像cnpm安裝 https://npm.taobao.org/

1 2 3 npm install -g cnpm --registry=https://registry.npm.taobao.org ln -s /usr/local/src/node-v6.9.4-linux-x64/bin/cnpm /usr/local/bin/cnpm
cnpm -v

3、安裝grunt和grunt-cli

1 2 3 npm install -g grunt-cli npm install -g grunt cnpm -v

3、安裝grunt

1 2 3 npm install -g cnpm --registry=https://registry.npm.taobao.org ln -s /usr/local/src/node-v6.9.4-linux-x64/bin/cnpm /usr/local/bin/cnpm cnpm -v
1 2 npm install -g grunt-cli npm install -g grunt

4、修改Elasticsearch配置文件

/etc/elasticsearch/elasticsearch.yml

http.cors.enabled: true
http.cors.allow-origin: "*"

5、修改Gruntfile.js

elasticsearch-head/Gruntfile.js

                connect: {
                        server: {
                                options: {
                                        hostname: ‘0.0.0.0‘,
                                        port: 9100,
                                        base: ‘.‘,
                                        keepalive: true
                                }
                        }
                }

增加hostname屬性,設置為0.0.0.0

6、修改app.js

elasticsearch-head/_site/app.js

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://10.10.83.163:9200";

把localhost修改成ES的服務器地址,如上面10.10.83.163

7、運行head

進入elasticsearch-head 目錄

npm install 

啟動

grunt server

頁面訪問:http://10.10.83.163:9100

8、後臺啟動elasticsearch-head

nohup grunt server &

如果想關閉head插件,查找進程命令:

ps aux|grep head

x-pack安全模塊(security機制)

1、修改Elasticsearch配置文件

/etc/elasticsearch/elasticsearch.yml

http.cors.allow-headers: Authorization

2、頁面訪問

http://10.10.83.163:9100/?auth_user=elastic&auth_password=changeme

Elasticsearch5.5 部署Head插件