﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-The NoteBook of EricKong-随笔分类-日志管理</title><link>http://www.blogjava.net/jjshcc/category/54849.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 12 Jun 2015 05:15:31 GMT</lastBuildDate><pubDate>Fri, 12 Jun 2015 05:15:31 GMT</pubDate><ttl>60</ttl><item><title>安装logstash+kibana+elasticsearch+redis搭建集中式日志分析平台  </title><link>http://www.blogjava.net/jjshcc/archive/2015/06/12/425647.html</link><dc:creator>Eric_jiang</dc:creator><author>Eric_jiang</author><pubDate>Fri, 12 Jun 2015 03:30:00 GMT</pubDate><guid>http://www.blogjava.net/jjshcc/archive/2015/06/12/425647.html</guid><wfw:comment>http://www.blogjava.net/jjshcc/comments/425647.html</wfw:comment><comments>http://www.blogjava.net/jjshcc/archive/2015/06/12/425647.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jjshcc/comments/commentRss/425647.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jjshcc/services/trackbacks/425647.html</trackback:ping><description><![CDATA[<p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">本文是参考logstash官方文档实践的笔记，搭建环境和所需组件如下：</p><ul style="line-height: 25px; margin: 15px 0px; padding: 0px 0px 0px 30px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;"><li style="line-height: 26px; box-sizing: border-box;">Redhat 5.7 64bit / CentOS 5.x</li><li style="line-height: 26px; box-sizing: border-box;">JDK 1.6.0_45</li><li style="line-height: 26px; box-sizing: border-box;">logstash 1.3.2 (内带kibana)</li><li style="line-height: 26px; box-sizing: border-box;">elasticsearch 0.90.10</li><li style="line-height: 26px; box-sizing: border-box;">redis 2.8.4</li></ul><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">搭建的集中式日志分析平台流程如下：&nbsp;</p><div style="line-height: 28px; font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; widows: auto; background-color: #ffffff;"><img alt="安装logstash+kibana+elasticsearch+redis搭建日志分析平台 - 傲风 - 0与1构筑世界，程序员创造时代" src="http://img0.ph.126.net/ycmJtSvQLMqqBIhCHxnRRg==/3303108851799736440.png" style="border: 0px; max-width: 100%; height: auto; margin: 0px 10px 0px 0px;" /></div><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">&nbsp;</p><h2>elasticsearch</h2><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">1、下载elasticsearch。</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; border: 1px solid #dddddd; border-radius: 3px; overflow: auto; background-color: #f8f8f8;"><code style="line-height: 21px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; padding: 0px; color: inherit; white-space: pre; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: none; margin: 0px;">wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.10.tar.gz </code></pre><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">2、解压后，进入bin目录。执行如下命令，让elasticsearch以前台方式启动：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; border: 1px solid #dddddd; border-radius: 3px; overflow: auto; background-color: #f8f8f8;"><code style="line-height: 21px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; padding: 0px; color: inherit; white-space: pre; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: none; margin: 0px;">./elasticsearch -f </code></pre><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; overflow: auto; background-color: #ffffff;">[2014-01-16 16:21:31,825][INFO ][node                     ] [Saint Elmo] version[0.90.10], pid[32269], build[0a5781f/2014-01-10T10:18:37Z] [2014-01-16 16:21:31,826][INFO ][node                     ] [Saint Elmo] initializing ... [2014-01-16 16:21:31,836][INFO ][plugins                  ] [Saint Elmo] loaded [], sites [] [2014-01-16 16:21:35,425][INFO ][node                     ] [Saint Elmo] initialized [2014-01-16 16:21:35,425][INFO ][node                     ] [Saint Elmo] starting ... [2014-01-16 16:21:35,578][INFO ][transport                ] [Saint Elmo] bound_address {inet[/0.0.0.0:9300]}, publish_address {inet[/10.0.2.15:9300]} </pre><h2>Redis</h2><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">1、其安装方式可以参考我的另一篇文章<a href="http://aofengblog.blog.163.com/blog/static/6317021201401634134695/" style="color: #4183c4; line-height: 26px; text-decoration: none; box-sizing: border-box;">Redis编译安装</a>。</p><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">2、进入其bin目录，执行如下命令，使之在控制台输出debug信息：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; border: 1px solid #dddddd; border-radius: 3px; overflow: auto; background-color: #f8f8f8;"><code style="line-height: 21px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; padding: 0px; color: inherit; white-space: pre; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: none; margin: 0px;">./redis-server --loglevel verbose </code></pre><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; overflow: auto; background-color: #ffffff;">[32470] 16 Jan 16:45:57.330 * The server is now ready to accept connections on port 6379 [32470] 16 Jan 16:45:57.330 - 0 clients connected (0 slaves), 283536 bytes in use </pre><h2>logstash日志生成器（shipper）</h2><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">1、新建一个配置文件：<code style="line-height: 21px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; padding: 0px 5px; color: #c7254e; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; margin: 0px 2px; border: 1px solid #dddddd;">shipper.conf</code>，其内容如下：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; border: 1px solid #dddddd; border-radius: 3px; overflow: auto; background-color: #f8f8f8;">input {     stdin {         type =&gt; "example"     } }  output {     stdout {         codec =&gt; rubydebug     }     redis {         host =&gt; "127.0.0.1"         port =&gt; 6379         data_type =&gt; "list"         key =&gt; "logstash"     } } </pre><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">2、启动shipper。执行如下命令：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; border: 1px solid #dddddd; border-radius: 3px; overflow: auto; background-color: #f8f8f8;"><code style="line-height: 21px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; padding: 0px; color: inherit; white-space: pre; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: none; margin: 0px;">java -jar logstash-1.3.2-flatjar.jar agent -f shipper.conf  </code></pre><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">终端窗口将出现如下提示信息：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; overflow: auto; background-color: #ffffff;">Using milestone 2 output plugin 'redis'. This plugin should be stable, but if you see strange behavior, please let us know! For more information on plugin milestones, see http://logstash.net/docs/1.3.2/plugin-milestones {:level=&gt;:warn} </pre><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">然后在终端窗口直接按回车，将出现如下信息：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; overflow: auto; background-color: #ffffff;">{        "message" =&gt; "",       "@version" =&gt; "1",     "@timestamp" =&gt; "2014-01-16T08:15:19.400Z",           "type" =&gt; "example",           "host" =&gt; "redhat" } </pre><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">这个json信息将发送给redis， 同时redis的终端窗口将出现类似下面的提示信息：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; overflow: auto; background-color: #ffffff;">[32470] 16 Jan 17:09:23.604 - Accepted 127.0.0.1:44640 [32470] 16 Jan 17:09:27.127 - DB 0: 1 keys (0 volatile) in 4 slots HT. [32470] 16 Jan 17:09:27.127 - 1 clients connected (0 slaves), 304752 bytes in use </pre><h2>logstash日志索引器（indexer）</h2><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">1、新建一个配置文件：<code style="line-height: 21px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; padding: 0px 5px; color: #c7254e; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; margin: 0px 2px; border: 1px solid #dddddd;">indexer.conf</code>，其内容如下：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; border: 1px solid #dddddd; border-radius: 3px; overflow: auto; background-color: #f8f8f8;">input {   redis {     host =&gt; "127.0.0.1"     # these settings should match the output of the agent     data_type =&gt; "list"     key =&gt; "logstash"      # We use the 'json' codec here because we expect to read     # json events from redis.     codec =&gt; json   } }  output {   stdout { debug =&gt; true debug_format =&gt; "json"}    elasticsearch {     host =&gt; "127.0.0.1"   } } </pre><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">2、启动日志索引器。执行如下命令：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; border: 1px solid #dddddd; border-radius: 3px; overflow: auto; background-color: #f8f8f8;"><code style="line-height: 21px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; padding: 0px; color: inherit; white-space: pre; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: none; margin: 0px;">java -jar logstash-1.3.2-flatjar.jar agent -f indexer.conf  </code></pre><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">终端窗口将出现如下提示信息：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; overflow: auto; background-color: #ffffff;">Using milestone 2 input plugin 'redis'. This plugin should be stable, but if you see strange behavior, please let us know! For more information on plugin milestones, see http://logstash.net/docs/1.3.2/plugin-milestones {:level=&gt;:warn} You are using a deprecated config setting "debug_format" set in stdout. Deprecated settings will continue to work, but are scheduled for removal from logstash in the future.  If you have any questions about this, please visit the #logstash channel on freenode irc. {:name=&gt;"debug_format", :plugin=&gt;<logstash outputsstdout="" ---="" style="line-height: 21px; box-sizing: border-box;">, :level=&gt;:warn} </logstash></pre><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">索引器从Redis接收到信息，在终端窗口会显示类似如下的信息：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; overflow: auto; background-color: #ffffff;">{"message":"","@version":"1","@timestamp":"2014-01-16T17:10:03.831+08:00","type":"example","host":"redhat"}{"message":"","@version":"1","@timestamp":"2014-01-16T17:13:20.545+08:00","type":"example","host":"redhat"}{ </pre><h2>logstash WEB界面（kibana）</h2><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">1、启动kibana。执行如下命令：</p><pre style="line-height: 19px; white-space: pre-wrap; widows: auto; box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; word-wrap: break-word; padding: 6px 10px; color: #333333; word-break: break-all; border: 1px solid #dddddd; border-radius: 3px; overflow: auto; background-color: #f8f8f8;"><code style="line-height: 21px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; padding: 0px; color: inherit; white-space: pre; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; border: none; margin: 0px;">java -jar logstash-1.3.2-flatjar.jar web </code></pre><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;">2、打开浏览器（<code style="line-height: 21px; box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; padding: 0px 5px; color: #c7254e; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; margin: 0px 2px; border: 1px solid #dddddd;">须支持HTML5</code>），输入地址：http://127.0.0.1:9292/index.html#/dashboard/file/logstash.json。界面效果如下：&nbsp;</p><div style="line-height: 28px; font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; widows: auto; background-color: #ffffff;"><div><a target="_blank" href="http://img2.ph.126.net/ZZ_s9EHgJmLCrNoDeG7hxg==/6608407930561742180.png" style="color: #3366cc; text-decoration: none;"><img alt="安装logstash+kibana+elasticsearch+redis搭建日志分析平台 - 傲风 - 0与1构筑世界，程序员创造时代" src="http://img2.ph.126.net/ZZ_s9EHgJmLCrNoDeG7hxg==/6608407930561742180.png" style="border: 0px; max-width: 100%; height: auto; margin: 0px 10px 0px 0px;" /></a></div>&nbsp;</div><p style="line-height: 25px; margin: 15px 0px; padding: 0px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;"><span style="line-height: 54px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 2em;">参考资料</span></p><ul style="line-height: 25px; margin: 15px 0px; padding: 0px 0px 0px 30px; widows: auto; box-sizing: border-box; color: #333333; font-family: Helvetica, arial, sans-serif; font-size: 15px; background-color: #ffffff;"><li style="line-height: 26px; box-sizing: border-box;"><a rel="nofollow" href="http://logstash.net/docs/1.3.2/tutorials/getting-started-centralized" style="color: #4183c4; text-decoration: none; box-sizing: border-box;">logstash-getting-started-centralized</a></li><li style="line-height: 26px; box-sizing: border-box;"><a rel="nofollow" href="http://www.infoq.com/cn/articles/review-the-logstash-book" style="color: #4183c4; text-decoration: none; box-sizing: border-box;">访谈与书评：《LogStash，使日志管理更简单》</a></li></ul><img src ="http://www.blogjava.net/jjshcc/aggbug/425647.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jjshcc/" target="_blank">Eric_jiang</a> 2015-06-12 11:30 <a href="http://www.blogjava.net/jjshcc/archive/2015/06/12/425647.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>fluentd结合kibana、elasticsearch实时搜索分析hadoop集群日志</title><link>http://www.blogjava.net/jjshcc/archive/2015/06/12/425645.html</link><dc:creator>Eric_jiang</dc:creator><author>Eric_jiang</author><pubDate>Fri, 12 Jun 2015 03:05:00 GMT</pubDate><guid>http://www.blogjava.net/jjshcc/archive/2015/06/12/425645.html</guid><wfw:comment>http://www.blogjava.net/jjshcc/comments/425645.html</wfw:comment><comments>http://www.blogjava.net/jjshcc/archive/2015/06/12/425645.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/jjshcc/comments/commentRss/425645.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/jjshcc/services/trackbacks/425645.html</trackback:ping><description><![CDATA[<p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">Fluentd是一个开源收集事件和日志系统，它目前提供150+扩展插件让你存储大数据用于日志搜索，数据分析和存储。</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">官方地址<a target="_blank" href="http://fluentd.org/" style="color: #336699; text-decoration: none;">http://fluentd.org/</a>&nbsp; 插件地址<a target="_blank" href="http://fluentd.org/plugin/" style="color: #336699; text-decoration: none;">http://fluentd.org/plugin/</a></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">Kibana 是一个为 ElasticSearch 提供日志分析的 Web ui工具，可使用它对日志进行高效的搜索、可视化、分析等各种操作。官方地址<a target="_blank" href="http://www.elasticsearch.org/overview/kibana/" style="color: #336699; text-decoration: none;">http://www.elasticsearch.org/overview/kibana/</a><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">elasticsearch&nbsp;是开源的（Apache2协议），分布式的，RESTful的，构建在Apache Lucene之上的的搜索引擎.</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">官方地址<a target="_blank" href="http://www.elasticsearch.org/overview/" style="color: #336699; text-decoration: none;">http://www.elasticsearch.org/overview/</a>&nbsp; &nbsp; 中文地址&nbsp;<a target="_blank" href="http://es-cn.medcl.net/" style="color: #336699; text-decoration: none;">http://es-cn.medcl.net/</a><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">具体的工作流程就是利用fluentd 监控并过滤hadoop集群的系统日志，将过滤后的日志内容发给全文搜索服务ElasticSearch, 然后用ElasticSearch结合Kibana 进行自定义搜索web页面展示.</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">下面开始说部署方法和过程。以下安装步骤在centos 5 64位测试通过</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-size: 24px;">一、 &nbsp;elasticsearch安装部署</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">elasticsearch 官方提供了几种安装包，适用于windows的zip压缩包，适用于unix/linux的tar.gz压缩包，适用于centos系统的rpm包和ubuntu的deb包。大家可以自己选择安装使用。<br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="color: #ff0000;">因为elasticsearch 需要java环境运行，首先需要安装jdk,安装步骤就省略了。</span><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">使用.tar.gz压缩包安装部署的话，先下载压缩包</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"># wget &nbsp;https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.5.tar.gz</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"># tar zxvf&nbsp;elasticsearch-0.90.5.tar.gz</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">////////////如果是单机部署</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"># cd&nbsp;elasticsearch-0.90.5</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">#&nbsp;elasticsearch-0.90.5/bin/elasticsearch -f</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">就可以启动搜索服务了，查看端口9200是否打开，如果打开说明启动正常。</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">////////////////如果是部署集群的话，需要进行配置</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">例如在192.168.0.1 &nbsp; 192.168.0.2 两台服务器部署，两台服务器都安装好jdk，下载elasticsearch 解压缩，然后编辑配置文件</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">//////////////////////192.168.0.1 &nbsp; 服务器编辑文件</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">vi&nbsp;elasticsearch-0.90.5/config/elasticsearch.yml</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">删除cluster.name 前面注释，修改集群名称&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">cluster.name: es_cluster<br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">删除node.name前注释 ，修改节点名称，不修改的话，系统启动后会生成随即node名称。</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">node.name: "elastic_inst1"</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">node.master: true &nbsp; &nbsp;设置该节点为主节点<br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">/////////////////////////192.168.0.2 &nbsp;编辑文件</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">vi&nbsp;elasticsearch-0.90.5/config/elasticsearch.yml</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">删除cluster.name 前面注释，修改集群名称&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">cluster.name: es_cluster<br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">删除node.name前注释 ，修改节点名称，不修改的话，系统启动后会生成随即node名称。</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">node.name: "elastic_inst2"</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">node.master: false &nbsp; &nbsp;设置该节点为主节点</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">分别启动两台服务器的服务后，在192.168.0.2的日志中会看到</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="color: #ff0000;">&nbsp;[elastic_inst2] detected_master [elastic_inst1]&nbsp;</span>&nbsp; &nbsp; 日志信息。说明集群连接成功。<br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-size: 24px;">二、安装部署fluentd</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-size: 12px;">在需要监控分析的hadoop集群节点中安装fluentd，安装步骤很简单</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-size: 12px;"><br /></span></p><pre name="code" style="white-space: pre-wrap; word-wrap: break-word; widows: auto; border: 1px solid #3f464c; font-size: 11px; margin-top: 0px; margin-bottom: 22px; outline: 0px; padding: 12px; vertical-align: baseline; line-height: 18px; overflow-y: auto; color: #f8f8f8; font-family: Monaco, monospace; background-color: #434e56;">curl -L http://toolbelt.treasure-data.com/sh/install-redhat.sh | sh</pre><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"></p><span style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">安装完成后，编辑配置文件</span><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"># vim /etc/td-agent/td-agent.conf</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"></p><div bg_html"="" style="width: 700.90625px; color: #333333; line-height: 26px; widows: auto;"><div><div><strong>[html]</strong>&nbsp;<a href="http://blog.csdn.net/jiedushi/article/details/12003171#" title="view plain">view plain</a><a href="http://blog.csdn.net/jiedushi/article/details/12003171#" title="copy">copy</a><a href="http://blog.csdn.net/jiedushi/article/details/12003171#" title="print">print</a><a href="http://blog.csdn.net/jiedushi/article/details/12003171#" title="?">?</a><a href="https://code.csdn.net/snippets/199331" target="_blank" title="在CODE上查看代码片"><img src="https://code.csdn.net/assets/CODE_ico.png" width="12" height="12" alt="在CODE上查看代码片" style="border: none; max-width: 100%; position: relative; top: 1px; left: 2px;" /></a><a href="https://code.csdn.net/snippets/199331/fork" target="_blank" title="派生到我的代码片"><img src="https://code.csdn.net/assets/ico_fork.svg" width="12" height="12" alt="派生到我的代码片" style="border: none; max-width: 100%; position: relative; top: 2px; left: 2px;" /></a><div style="position: absolute; left: 602px; top: 2345px; width: 29px; height: 14px; z-index: 99;"></div></div></div><ol start="1"><li style="line-height: 24px;"><span style="color: #993300; font-weight: bold;">&lt;</span><span style="color: #993300; font-weight: bold;">source</span><span style="color: #993300; font-weight: bold;">&gt;</span>&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;type&nbsp;tail&nbsp;&nbsp;####&nbsp;tail方式采集日志&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;path&nbsp;/var/log/hadoop/mapred/hadoop-mapred-tasktracker-node-128-70.log&nbsp;&nbsp;&nbsp;###&nbsp;hadoop日志路径&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;pos_file&nbsp;/var/log/td-agent/task-access.log.pos&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;tag&nbsp;task.mapred&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;format&nbsp;/^(?<span style="color: #993300; font-weight: bold;">&lt;</span><span style="color: #993300; font-weight: bold;">message</span><span style="color: #993300; font-weight: bold;">&gt;</span>.+(WARN|ERROR).+)$/&nbsp;&nbsp;&nbsp;####&nbsp;收集error&nbsp;或者warn&nbsp;日志。&nbsp;&nbsp;</li><li style="line-height: 24px;"><span style="color: #993300; font-weight: bold;">&lt;/</span><span style="color: #993300; font-weight: bold;">source</span><span style="color: #993300; font-weight: bold;">&gt;</span>&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;</li><li style="line-height: 24px;"><span style="color: #993300; font-weight: bold;">&lt;</span><span style="color: #993300; font-weight: bold;">match</span>&nbsp;task.**<span style="color: #993300; font-weight: bold;">&gt;</span>&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;host&nbsp;192.168.0.1&nbsp;&nbsp;#####&nbsp;&nbsp;<span style="color: #993300; font-weight: bold;">&lt;</span><span style="color: #993300; font-weight: bold;">span</span>&nbsp;<span style="color: red;">style</span>=<span style="color: blue;">"font-family:Arial,Helvetica,sans-serif"</span><span style="color: #993300; font-weight: bold;">&gt;</span>elasticsearch&nbsp;服务器地址<span style="color: #993300; font-weight: bold;">&lt;/</span><span style="color: #993300; font-weight: bold;">span</span><span style="color: #993300; font-weight: bold;">&gt;</span>&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;type&nbsp;elasticsearch&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;logstash_format&nbsp;true&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;flush_interval&nbsp;5s&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;include_tag_key&nbsp;true&nbsp;&nbsp;</li><li style="line-height: 24px;">&nbsp;&nbsp;tag_key&nbsp;mapred&nbsp;&nbsp;</li><li style="line-height: 24px;"><span style="color: #993300; font-weight: bold;">&lt;/</span><span style="color: #993300; font-weight: bold;">match</span><span style="color: #993300; font-weight: bold;">&gt;</span>&nbsp;&nbsp;</li></ol></div><br style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">启动fluentd 服务</span><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"># service td-agent start</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-size: 24px;">三、安装部署kibana 3</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">kibana 3 是<span style="font-family: Helvetica, arial, freesans, clean, sans-serif;"><span style="font-size: 15px; line-height: 25px;">使用html 和javascript 开发的web ui前端工具。</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-family: Helvetica, arial, freesans, clean, sans-serif;"><span style="font-size: 15px; line-height: 25px;">下载&nbsp;wget http://download.elasticsearch.org/kibana/kibana/kibana-latest.zip</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-family: Helvetica, arial, freesans, clean, sans-serif;"><span style="font-size: 15px; line-height: 25px;">解压缩 unzip&nbsp;kibana-latest.zip</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">安装apache &nbsp; &nbsp;yum -y install httpd</p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;">cp -r&nbsp;&nbsp;<span style="font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px;">kibana-latest /var/www/html</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px;">因为我将kibana3 安装在和elasticsearch同一台服务器中，所以不用修改配置文件</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px;">启动apache &nbsp;service httpd start</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px;">打开浏览器 http://ip/kibana 就可以看到kibana 界面</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px;">初次使用kibana 需要自己定义模块</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><span style="font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; line-height: 25px;"><img src="http://img.blog.csdn.net/20140222121433046?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamllZHVzaGk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" style="border: none; max-width: 100%;" /><br /></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; widows: auto; background-color: #ffffff;"><br /></p><img src ="http://www.blogjava.net/jjshcc/aggbug/425645.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/jjshcc/" target="_blank">Eric_jiang</a> 2015-06-12 11:05 <a href="http://www.blogjava.net/jjshcc/archive/2015/06/12/425645.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>