Ubuntu 下安装Kibana和logstash
原文地址:http://www.cnblogs.com/saintaxl/p/3946667.html
简单来讲他具体的工作流程就是 logstash agent 监控并过滤日志,将过滤后的日志内容发给redis(这里的redis只处理队列不做存储),logstash index将日志收集在一起交给全文搜索服务ElasticSearch 可以用ElasticSearch进行自定义搜索 通过Kibana 来结合 自定义搜索进行页面展示
- ruby 运行Kibana 必须
- rubygems 安装ruby扩展必须
- bundler 功能类似于yum
- JDK 运行java程序必须
- redis 用来处理日志队列
- logstash 收集、过滤日志
- ElasticSearch 全文搜索服务(logstash集成了一个)
kibana 页面展示
首先到 logstash index服务器上面,logstash分为 index和aget ,agent负责监控、过滤日志,index负责收集日志并将日志交给ElasticSearch 做搜索此外 logstash 的收集方式分为 standalone 和 centralized。
standalone 是所有功能都在一个服务器上面,自发自收,centralized 就是集中收集,一台服务器接收所有shipper(个人理解就是logstash agent)的日志。
其实 logstash本身不分 什么 shipper 和 collector ,只不过就是配置文件不同而已,我们这次按照集中的方式来测试
这里有两台服务器
192.168.124.128 logstash index,ElasticSearch,kibana,JDK
192.168.124.132 logstash agent,redis,JDK
准备工作
安装:openssl
卸载旧版本
apt-get remove openssl
apt-get autoremove openssl
下载最新版本
wget http://www.openssl.org/source/openssl-1.0.1i.tar.gz
tar -zxvf openssl-1.0.1i.tar.gz
cd /opt/openssl-1.0.1i
./config --prefix=/usr/local/ssl
make & make install
建立软连接
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
刷新动态配置
vim /etc/ld.so.conf
在文末插入一行
/usr/local/ssl/lib
ldconfig -v
测试
openssl version -a
安装PCRE库
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
tar -zxvf pcre-8.33.tar.gz
cd pcre-8.33
./configure --prefix=/usr/local/pcre-8.33
make & make install
安装zlib
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib-1.2.8
make & make install
安装nginx
wget http://nginx.org/download/nginx-1.6.1.tar.gz
tar -zxvf nginx-1.6.1.tar.gz
cd nginx-1.6.1
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=/opt/openssl-1.0.1i --with-pcre=/opt/pcre-8.33 --with-zlib=/opt/zlib-1.2.8
nginx 命令
启动:/usr/local/nginx/sbin/nginx
重启:/usr/local/nginx/sbin/nginx –s reload
停止:/usr/local/nginx/sbin/nginx -s stop
查看主进程:netstat -ntlp
检查是否启动成功:netstat -ano|grep 80
安装ruby 运行Kibana 必须
sudo apt-get update
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz
./configure --prefix=/usr/local/ruby
make && make install
环境设置
vi /etc/environment
将Ruby的路径加入环境变量 中并保存/etc/environment,如下面内容:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ruby/bin"
修改了环境变量文件后,需要通过source命令让修改马上生效,命令如下:
$ source /etc/environment
为了检查安装是否成功,可以输入下面的命令进行测试 :
$ruby –v
确认安装成功后通过一下命令添加命令链接,目前我也不清楚创建这些链接的目的是什么,按照Ruby“约定大于配置”的原则,应该是一种约定。(keyboardota)
$ sudo ln -s /usr/local/ruby/bin/ruby /usr/local/bin/ruby
$ sudo ln -s /usr/local/ruby/bin/gem /usr/bin/gem
或者:
apt-get install ruby-full
安装rubygems ruby扩展必须
wget http://production.cf.rubygems.org/rubygems/rubygems-2.4.1.tgz
tar -zxvf rubygems-2.4.1.tgz
cd rubygems-2.4.1
ruby setup.rb
安装redis 用来处理日志队列
wget http://download.redis.io/releases/redis-2.8.13.tar.gz

tar -zxvf redis-2.8.13.tar.gz
cd redis-2.8.13
make
vim redis.conf
设置 "daemonize yes"
启动:/usr/local/redis-2.8.13/src/redis-server /usr/local/redis-2.8.13/redis.conf

安装 elasticsearch 全文搜索服务(logstash集成了一个)
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.tar.gz

tar -zxvf elasticsearch-1.3.2.tar.gz
cd elasticsearch-1.3.2
启动:
/usr/local/elasticsearch-1.3.2/bin/elasticsearch -d
访问
http://localhost:9200

安装:logstash 收集、过滤日志
wget https://download.elasticsearch.org/logstash/logstash/logstash-1.4.2.tar.gz
tar -zxvf logstash-1.4.2.tar.gz
启动
nohup /usr/local/logstash-1.4.2/bin/logstash -f /usr/local/logstash-1.4.2/agent.conf &
nohup /usr/local/logstash-1.4.2/bin/logstash -f /usr/local/logstash-1.4.2/indexer.conf &
vim /usr/local/logstash-1.4.2/agent.conf

input {
file {
path => [ "/var/log/*.log", "/var/log/messages", "/var/log/syslog", "/var/log/denyhosts", "/var/log/dmesg", "/var/log/faillog", "/var/log/aptitude" ]
start_position => beginning
}
file {
type => "nginx-access"
path => "/var/log/nginx/access.log"
}
}
output {
redis{
host =>"192.168.124.128"
data_type => "list"
key => "logstash"
}
}

vim /usr/local/logstash-1.4.2/indexer.conf

input {
redis {
host => "192.168.124.128"
data_type => "list"
key => "logstash"
}
}
output {
elasticsearch {
host => "192.168.124.132" #指定elasticsearch服务位置
}
}

安装Kibana
wget https://download.elasticsearch.org/kibana/kibana/kibana-3.1.0.tar.gz
tar -zxvf kibana-3.1.0.tar.gz
vim /usr/local/kibana-3.1.0/config/ 可以通过whereis kibana找到kibana具体物理地址 在config目录下有个kibana.yml配置文件
搜索"elasticsearch"参数,并对其进行修改以适应您的环境:
elasticsearch: "http://192.168.124.132:9200",
您还可以修改default_route参数,默认打开logstash仪表板而不是Kibana欢迎页面:
default_route : '/dashboard/file/logstash.json', (这个在哪里配置,没看到...)
下载配置模板
wget https://raw.github.com/elasticsearch/kibana/master/sample/nginx.conf
修改Nginx配置
vim /usr/local/nginx/conf/nginx.conf
增加Server节点

#
# Nginx proxy for Elasticsearch + Kibana
#
# In this setup, we are password protecting the saving of dashboards. You may
# wish to extend the password protection to all paths.
#
# Even though these paths are being called as the result of an ajax request, the
# browser will prompt for a username/password on the first request
#
# If you use this, you'll want to point config.js at http://FQDN:80/ instead of
# http://FQDN:9200
#
server {
listen *:80 ; server_name localhost;
access_log /usr/local/nginx/logs/kibana.access.log; location / {
root /usr/local/kibana-3.1.0;
index index.html index.htm;
} location ~ ^/_aliases$ {
proxy_pass http://127.0.0.1:9200;
proxy_read_timeout 90;
}
location ~ ^/.*/_aliases$ {
proxy_pass http://127.0.0.1:9200;
proxy_read_timeout 90;
}
location ~ ^/_nodes$ {
proxy_pass http://127.0.0.1:9200;
proxy_read_timeout 90;
}
location ~ ^/.*/_search$ {
proxy_pass http://127.0.0.1:9200;
proxy_read_timeout 90;
}
location ~ ^/.*/_mapping {
proxy_pass http://127.0.0.1:9200;
proxy_read_timeout 90;
} # Password protected end points
location ~ ^/kibana-int/dashboard/.*$ {
proxy_pass http://127.0.0.1:9200;
proxy_read_timeout 90;
limit_except GET {
proxy_pass http://127.0.0.1:9200;
auth_basic "Restricted";
auth_basic_user_file /usr/local/nginx/kibana.myhost.org.htpasswd;
}
}
location ~ ^/kibana-int/temp.*$ {
proxy_pass http://127.0.0.1:9200;
proxy_read_timeout 90;
limit_except GET {
proxy_pass http://127.0.0.1:9200;
auth_basic "Restricted";
auth_basic_user_file /usr/local/nginx/kibana.myhost.org.htpasswd;
}
}
}

如果有防火墙需要放开这些端口:
- port 80 (for the web interface)
- port 5544 (to receive remote syslog messages)
- port 6379 (for the redis broker)
- port 9200 (so the web interface can access elasticsearch)
Ubuntu 下安装Kibana和logstash的更多相关文章
- 在Ubuntu下安装ovs-dpdk
在Ubuntu下安装ovs-dpdk 参考资料:https://software.intel.com/zh-cn/articles/using-open-vswitch-with-dpdk-on-ub ...
- Ubuntu 下安装QT
Ubuntu 下安装QT 本文使用的环境 QT Library: qt-everywhere-opensource-src-4.7.4.tar.gz QT Creator: qt-creator-li ...
- Ubuntu下安装JDK以及相关配置
1.查看系统位数,输入以下命令即可 getconf LONG_BIT 2.下载对应的JDK文件,我这里下载的是jdk-8u60-linux-64.tar.gz 3.创建目录作为JDK的安装目录,这里选 ...
- Ubuntu下安装mod_python报错(GIT错误)
Ubuntu下安装mod_python3.4.1版本报出如下错误: writing byte-compilation script '/tmp/tmpE91VXZ.py' /usr/bin/pytho ...
- TODO:Ubuntu下安装Node
TODO:Ubuntu下安装Node Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境.Node.js 使用了一个事件驱动.非阻塞式 I/O 的模型,使其轻量又高 ...
- Ubuntu杂记——Ubuntu下安装VMware
转战Ubuntu,不知道能坚持多久,但是自己还是要努力把转战过程中的学习到的给记录下来.这次就来记录一下,Ubuntu下如何安装VMware. 就我所知,Linux下有VirtualBox和VMwar ...
- 来杯Caffe——在ubuntu下安装Caffe框架并测试
Caffe是一种深度学习框架...blablabla...... Caffe要在ubuntu下安装 1. 安装依赖 sudo apt-get install libatlas-base-dev sud ...
- Ubuntu 下安装 Mysql
这里讲用Ubuntu下安装MySql ubuntu上安装mysql非常简单只需要几条命令就可以完成. 1. sudo apt-get install mysql-server 2. apt-get ...
- ubuntu下安装配置OpenCV
Cmake的安装 我用的是ubuntu-software自动下载安装的. Ubuntu 下安装 OpenCV 首先下载安装相关包,然后下载OpenCV 系统:ubuntu16.04 OpenCV:2. ...
随机推荐
- WebRTC 音视频开发之路
早在2014年就通过WebRTC实现了PC客户端的实时视频语音,那时P2P连接的建立使用的WebRTC自带的libjingle库,使用peerconnection的API实现的.后来在做远程桌面,文件 ...
- ABP手机端调用API时的CORS
这个问题其实很早就考虑了,当时因为也没有特别着急去解决这个问题,就一直拖着.... 好吧,拖延症是不好的,所有不懒得做的,终将会逼着你去再很短的时间内去解决问题...实现项目 改写一个已有的webfo ...
- ci验证码
ci 之验证码 为了方便,把 system/system/helpers/captcha_helper.php复制放在 application/helpers/文件夹里面 手册上面推荐用数据库,但个人 ...
- Google Map 自定义 infowindow
最近做的东西用到了infowindow,不过google提供的样式太难看了,于是想改变一下样式.看了一下好像infowindow的样式不太好改. 查了半天资料,看到一个infobox,感觉真的挺好用. ...
- 查看 MySQL 数据库中每个表占用的空间大小
TABLE_SCHEMA : 数据库名TABLE_NAME:表名ENGINE:所使用的存储引擎TABLES_ROWS:记录数DATA_LENGTH:数据大小INDEX_LENGTH:索引大小 SELE ...
- 【VB6 学习文档管理系统源码】
VB6写的一款笔记软件的源码,里面包含有很多窗体控件的使用技巧,比如MSHFlexgrid表格.TreeView的动态加载.Ado的增删改查等. 本软件提供对日常生活.工作中的学习笔记.图文并茂存储以 ...
- Python 命令行参数解析
方法1: Python有一个类可以专门处理命令行参数,先看代码: #!/usr/bin/env python # encoding: utf-8 from optparse import Option ...
- ARM中的PC和AXD的PC
R15 (PC)总是指向“正在取指”的指令,而不是指向“正在执行”的指令或正在“译码”的指令.一般来说,人们习惯性约定将“正在执行的指令作为参考点”,称之为当前第一条指令,因此PC 总是指向第三条指令 ...
- 二师兄VPN加速器
http://www.2-vpn2.org/home.action?ic=B003CC4C47
- 个人学习笔记--MyBatis-的搭建及第一个程序
1.导入Jar包 2.设置全局配置文件 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE c ...