elasticsearch-head插件安装

安装nodejs

cd /usr/local/src
wget https://nodejs.org/dist/v6.11.3/node-v6.11.3-linux-x64.tar.xz
yum -y install xz
xz -d node-v6.11.3-linux-x64.tar.xz
tar xf node-v6.11.3-linux-x64.tar -C /usr/local/
ln -s /usr/local/node-v6.11.3-linux-x64 /usr/local/node

vim /etc/profile

###NODE###
export NODE_HOME=/usr/local/node
###所有PATH###
export PATH=$NODE_HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

一条命令搞定:

echo -e '###NODE###\nexport NODE_HOME=/usr/local/node\n###所有PATH###\nexport PATH=$NODE_HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin:$PATH'>>/etc/profile&&source /etc/profile&&tail -4 /etc/profile

检查

[root@elk-node1 src]# node -v
v6.11.3
[root@elk-node1 src]# npm -v
3.10.10

安装grunt

npm install -g grunt-cli --registry=https://registry.npm.taobao.org
grunt -version

安装git

yum -y install git

安装head插件

克隆代码

mkdir -p /usr/local/elasticsearch-plugin/head/
cd /usr/local/elasticsearch-plugin/head/
git clone git://github.com/mobz/elasticsearch-head.git

修改head插件配置

修改服务器监听地址 目录:head/Gruntfile.js 92行后,增加hostname属性,设置为*

vim /usr/local/elasticsearch-plugin/head/elasticsearch-head/Gruntfile.js

connect: {
    server: {
        options: {
            port: 9100,
            hostname: '*',
            base: '.',
            keepalive: true
        }
    }
}

修改连接地址:目录:/usr/local/elasticsearch-plugin/head/elasticsearch-head/_site/app.js
把localhost修改成你es的服务器地址

sed -i 's#localhost:9200#elk-node1:9200#g' /usr/local/elasticsearch-plugin/head/elasticsearch-head/_site/app.js

查看:

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

配置elastic插件支持

增加新的参数,这样head插件可以访问es,然后重启 elasticsearch

vim /usr/local/elasticsearch/config/elasticsearch.yml

# head plugins
http.cors.enabled: true
http.cors.allow-origin: "*"

下载依赖包

cd /usr/local/elasticsearch-plugin/head/elasticsearch-head/
npm install --registry=https://registry.npm.taobao.org

有一个phantomjs-2.1.1-linux-x86_64.tar.bz2 无法下载,手工翻墙后,下载后放入到/tmp/phantomjs/下;并操作下面命令

rm -rf /usr/local/elasticsearch-plugin/head/elasticsearch-head/node_modules/

后再次执行 npm install --registry=https://registry.npm.taobao.org 成功后执行

cd /usr/local/elasticsearch-plugin/head/elasticsearch-head
grunt server

查看

将相关主机名添加到window的hosts中:
C:\Windows\System32\drivers\etc

192.168.200.21 elk-node1

浏览器访问:http://192.168.200.21:9100/

相关参考

http://blog.csdn.net/mergerly/article/details/53412417

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