images\cherry_red.png1 ELK日志分析系统
      images\cherry_blue.png1.1 ELK系统部署
         images\cherry_orange.png1.1.1 ELK端配置
            images\cherry_cyan.png1.1.1.1 Elasticsearch
            images\cherry_cyan.png1.1.1.2 Kibana
            images\cherry_cyan.png1.1.1.3 Filebeat
      images\cherry_blue.png1.2 ELK优化
         images\cherry_orange.png1.2.1 es-head插件安装
         images\cherry_orange.png1.2.2 安装filebeat nginx 日志模板

>修改elasticsearch配置文件在最后增加以下配置,并重启elasticsearch
# vi /usr/local/elasticsearch-6.2.3/config/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true

重启:
# netstat -nlpt | grep 9200
tcp6 0 0 127.0.0.1:9200 :::* LISTEN 13803/java
tcp6 0 0 192.168.110.200:9200 :::* LISTEN 13803/java

# kill -9 13803
# /usr/local/elasticsearch-6.2.3/bin/elasticsearch -d


>下载head插件
# cd /tmp
# wget https://github.com/mobz/elasticsearch-head/archive/master.zip

>解压到/opt目录
[root@elk tmp]# unzip master.zip -d /opt/
[root@elk tmp]# ls /opt/
elasticsearch-head-master

>下载安装node
[root@elk tmp]# wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.4.7-linux-x64.tar.gz
[root@elk tmp]# tar -xf node-v4.4.7-linux-x64.tar.gz -C /opt/
[root@elk tmp]# ls /opt/
elasticsearch-head-master node-v4.4.7-linux-x64

>修改环境变量配置文件
# vi /etc/profile
export NODE_HOME=/opt/node-v4.4.7-linux-x64
export PATH=${PATH}:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules

[root@elk ~]# source /etc/profile
[root@elk ~]# npm -v
2.15.8
[root@elk ~]# node -v
v4.4.7

>执行 npm install -g grunt-cli 安装grunt ,安装完成后执行grunt -version查看是否安装成功,会显示安装的版本号
[root@elk elasticsearch-head-master]# npm install -g grunt-cli
[root@elk elasticsearch-head-master]# grunt -version



>修改head插件源码/opt/elasticsearch-head-master/Gruntfile.js
# vi /opt/elasticsearch-head-master/Gruntfile.js
connect: {
server: {
options: {
hostname: "*",
port: 9100,
base: '.',
keepalive: true,
}
}
}




>修改连接地址/opt/elasticsearch-head-master/_site/app.js
images\8-1.png




>下载运行head必要的文件(放置在文件夹/tmp/phantomjs
# mkdir /tmp/phantomjs
# chmod 0777 /tmp/phantomjs
# cd /tmp/phantomjs
# wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
# yum -y install bzip2


>在elasticsearch-head-master 目录下执行npm install
[root@elk ~]# cd /opt/elasticsearch-head-master/
[root@elk elasticsearch-head-master]# npm install

PS:如果失败如下尝试
# npm cache clean
# npm install -g grunt grunt-cli



> 运行head插件,如果不成功重新安装grunt
# nohup npm run start &


# netstat -nlpt
tcp6 0 0 :::9100 :::* LISTEN 14122/grunt

images\8-2.png

++++++++++++++++++++++++++++++++++++++++++++++++++++