centos7.2部署最新ELK 5.3
## 安装elasticsearch服务
> 安装jdk 1.8
```
rpm -ivh jdk-8u101-linux-x64.rpm
java -version
```
> 配置rpm
```
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
```
> 配置yum源
```
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
```
> 安装elasticsearch
```
yum install elasticsearch
```
> 配置elasticsearch
```
cluster.name: htd 配置集群
node.name: htd-es-1 配置集群节点
path.data: /home/htd/es-data 配置数据目录
network.host: 0.0.0.0 配置绑定IP
http.port: 9200 配置端口
discovery.zen.ping.unicast.hosts: ["171.16.45.11", "171.16.45.122"] 配置集群寻址
http.cors.enabled: true 配置插件head访问权限
http.cors.allow-origin: "*" 配置插件head访问权限
```
> 插件数据目录
```
mkdir -pv /home/htd/es-data
chmod -R elasticsearch:elasticsearch /home/htd/es-data/
```
> 启动elasticsearch
```
systemctl start elasticsearch.service
systemctl enable elasticsearch.service
systemctl status elasticsearch.service
```
> 测试elasticsearch
```
访问 http://171.16.45.11:9200
{
"name" : "htd-es-1",
"cluster_name" : "htd",
"cluster_uuid" : "kWIGrN9xTHyzLpOEup9uJA",
"version" : {
"number" : "5.3.0",
"build_hash" : "3adb13b",
"build_date" : "2017-03-23T03:31:50.652Z",
"build_snapshot" : false,
"lucene_version" : "6.4.1"
},
"tagline" : "You Know, for Search"
}
```
## 安装logstash服务
> 安装jdk 1.8
```
rpm -ivh jdk-8u101-linux-x64.rpm
java -version
```
> 配置rpm
```
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
```
> 配置yum源
```
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
```
> 安装logstash
```
yum install logstash
```
> 配置logstash
```
path.data: /home/htd/logstash 配置数据目录
path.config: /etc/logstash/conf.d logstash配置目录
http.host: "0.0.0.0" 配置服务IP
http.port: 9600-9700 配置端口
path.logs: /var/log/logstash logstash日志目录
```
> 启动logstash
```
systemctl start logstash.service
systemctl enable logstash.service
systemctl status logstash.service
```
> 配置logstash服务文件
```
配置文件目录:/etc/logstash/conf.d
input {
beats {
port => "5044"
codec => "json"
}
}
filter {
if [type] == "nginx-public"{
geoip {
source => "clientip"
target => "geoip"
database => "/usr/share/logstash/config/GeoLite2-City.mmdb"
add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}" ]
}
mutate {
convert => [ "[geoip][coordinates]", "float"]
}
}
}
output {
if [type] == "nginx-public" {
elasticsearch {
hosts => ["171.16.45.11:9200"]
index => "logstash-nginx-public-%{+YYYY.MM.dd}"
}
}
}
```
**==完成配置文件后需要重启logstash或者重新加载配置文件==**
## 安装kibana服务
> 安装jdk 1.8
```
rpm -ivh jdk-8u101-linux-x64.rpm
java -version
```
> 配置rpm
```
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
```
> 配置yum源
```
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
```
> 安装kibana
```
yum install kibana
```
> 配置kibana
```
server.port: 5601 配置端口
server.host: "0.0.0.0" 配置服务地址
server.name: "HTD-Formal-Kibana" 配置kibana服务名
elasticsearch.url: "http://171.16.45.11:9200" 配置连接elasticsearch参数
tilemap.url: 'http://webrd02.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}' 配置高德地图
```
> 启动kibana
```
systemctl enable kibana.service
systemctl start kibana.service
systemctl status kibana.service
```
> 访问kibana
```
http://171.16.45.10:5601/
```
> 通过Nginx限制输入用户名及密码访问kibana
```
server {
listen 80;
server_name elk.kibana.htd.cn;
auth_basic "Kibana";
auth_basic_user_file /etc/nginx/htdpasswd;
access_log /home/htd/nginx_logs/kibana_access_80.log htdlog;
error_log /home/htd/nginx_logs/kibana_error_80.log;
location / {
proxy_pass http://htd_kibana;
}
}
配置用户名及密码:
printf "admin:$(openssl passwd -crypt 123456)\n" >/etc/nginx/htdpasswd
测试nginx配置:
nginx -t
重载nginx配置:
nginx -s reload
```
## 安装filebeat
> 下载安装filebeat
```
yum install libpcap
curl -L -O https://artifacts.elastic.co/downloads/beats/packetbeat/packetbeat-5.3.0-x86_64.rpm
sudo rpm -vi packetbeat-5.3.0-x86_64.rpm
```
> Nginx日志采用json
```
log_format htdlog '{"@timestamp":"$time_iso8601",'
'"host":"$server_addr",'
'"clientip":"$remote_addr",'
'"size":$body_bytes_sent,'
'"responsetime":$request_time,'
'"upstreamtime":"$upstream_response_time",'
'"upstreamhost":"$upstream_addr",'
'"http_host":"$host",'
'"url":"$uri",'
'"xff":"$http_x_forwarded_for",'
'"referer":"$http_referer",'
'"agent":"$http_user_agent",'
'"status":"$status"}';
```
> 配置nginx的filebeat参数
```
filebeat.prospectors:
- input_type: log
paths:
- /home/htd/nginx_logs/*.log
document_type: "nginx-public"
output.logstash:
hosts: ["171.16.45.13:5044"]
```
> 配置tomcat的filebeat参数
```
filebeat.prospectors:
- input_type: log
paths:
- /home/htd/logs/mallcenter/error.log
document_type: "mallcenter-error"
multiline.pattern: '^[[:space:]]+|^Caused by:' 多行合并
multiline.negate: false
multiline.match: after
output.logstash:
hosts: ["171.16.45.14:5044"]
```
> 启动filebeat
```
/etc/init.d/filebeat start
/etc/init.d/filebeat stop
```
centos7.2部署最新ELK 5.3的更多相关文章
- 在 CentOS7 上部署 zookeeper 服务
在 CentOS7 上部署 zookeeper 服务 1 用 SecureCRT 或 XShell 等 Linux 客户端工具连接至 CentOS7 服务器: 2 进入到 /usr/local/too ...
- 在阿里云ECS CentOS7上部署基于MongoDB+Node.js的博客
前言:这是一篇教你如何在阿里云的ECS CentOS 7服务器上搭建一个个人博客的教程,教程比较基础,笔者尽可能比较详细的把每一步都罗列下来,包括所需软件的下载安装和域名的绑定,笔者在此之前对Linu ...
- CentOS7上部署ASP.Net Core 2.2应用
前言 在CentOS7上部署ASP.Net Core应用是我的技术路线验证的一部分,下一个产品计划采用ASP.Net Boilerplate Framework开发.因此需要求提前进行一下技术验证,在 ...
- (转)Centos7上部署openstack ocata配置详解
原文:http://www.cnblogs.com/yaohong/p/7601470.html 随笔-124 文章-2 评论-82 Centos7上部署openstack ocata配置详解 ...
- 在 CentOS7 上部署 MySQL 主从
在 CentOS7 上部署 MySQL 主从 通过 SecureCRT 连接至 MySQL 主服务器: 找到 my.cnf 文件所在的目录: mysql --help | grep my.cnf 一般 ...
- GIT-Linux(CentOS7)系统部署git服务器
GIT-Linux(CentOS7)系统部署git服务器 root账号登录 一. 安装并配置必要的依赖关系在CentOS系统上安装所需的依赖:ssh,防火墙,postfix(用于邮件通知) ,wget ...
- linux 实现centos7在线升级最新版本内核
Kernel (内核)是操作系统的核心,掌握所有硬件设备的控制权,也就是说,你所希望计算机帮你完成的各项工作,都需要通过内核的帮助才能完成,当然,如果我们想完成的某个功能是内核没有的,则内核不会操控 ...
- CentOS7.4部署Python3+Django+uWSGI+Nginx
CentOS7.4部署Python3+Django+uWSGI+Nginx http://www.showerlee.com/archives/2590
- CentOS7安装部署zabbix3.4操作记录
CentOS7安装部署zabbix3.4操作记录 1.安装前准备 1.1 查看centos的系统版本 [root@zabbix ~]# cat /etc/redhat-release CentOS L ...
随机推荐
- Android 增量更新
title: Android NDK之增量更新 1.增量更新使用到的库bsdiff和bzip2 bsdiff库是一个开源的二进制差分工具,通过对比Apk的二进制,从而进行差分包的生成. bsdiff库 ...
- 【java基础之jdk源码】集合类
最近在整理JAVA 基础知识,从jdk源码入手,今天就jdk中 java.util包下集合类进行理解 先看图 从类图结构可以了解 java.util包下的2个大类: 1.Collecton:可以理解为 ...
- Java设计模式之《组合模式》及应用场景
摘要: 原创作品,可以转载,但是请标注出处地址http://www.cnblogs.com/V1haoge/p/6489827.html 组合模式,就是在一个对象中包含其他对象,这些被包含的对象可能是 ...
- Visual Studio 20周年,我和VS不得不说的故事(内含福利)
Visual Studio 2017正式版已如期发布(点击这里查看发布全记录)!自去年 11 月正式宣布 Visual Studio 项目之后,微软终于正式推出了“宇宙最强集成开发环境(IDE)”的最 ...
- iOS回顾笔记(05) -- 手把手教你封装一个广告轮播图框架
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...
- ajax删除数据(不跳转页面)
以前我们讲的删除是利用嵌入php代码,跳转到另一个页面,从而降低了删除速度,但我们今天讲的利用ajax不仅可以达到不跳页面快速删除,并且能添加特效来美化页面. AJAX = 异步 JavaScript ...
- Alamofire源码解读系列(六)之Task代理(TaskDelegate)
本篇介绍Task代理(TaskDelegate.swift) 前言 我相信可能有80%的同学使用AFNetworking或者Alamofire处理网络事件,并且这两个框架都提供了丰富的功能,我也相信很 ...
- CDbConnection failed to open the DB connection
打开数据库失败 有我遇到的有寄给问题: 1 Not find Drive 2 SQLSTATE[28000] [1045] Access denied for user 'xxx'@'localhos ...
- idea 中设置成公司规范的代码格式
优雅的编码格式是一个程序员的必备素质. 最近切换到了 idea,想对自己的代码进行格式化的时候希望能自动排版成公司规定的格式,可以做以下设置: 打开 idea 的 preference: 左侧找到 c ...
- C++基础——C面向过程与C++面向对象编程01_圆面积求解
#include "iostream";//包含C++的头文件using namespace std;//使用命名空间std标准的命名空间(在这个命名空间中定义了很多标准定义)vo ...