我有3种服务器都在本地运行Ubuntu 10.04:
hadoop -agent-1:这是生成所有日志的代理
hadoop-collector-1:这是收集所有日志的收集器(来自hadoop-agent-1,agent-2,agent-3等)
hadoop-master-1:这是发送所有命令的水槽主节点
要添加CDH3存储库:
使用以下内容创建一个新文件/etc/apt/sources.list.d/cloudera.list:
deb http://archive.cloudera.com/debian <RELEASE>-cdh3 contrib
deb-src http://archive.cloudera.com/debian <RELEASE>-cdh3 contrib
哪里:
是分发的名称,可以通过运行lsb_release -c来找到它。 例如,要为Ubuntu Lucid安装CDH3,请在上面的命令中使用lucid-cdh3。
(要在Debian系统上安装CDH的其他版本,请在deb命令的-cdh3部分中指定所需的版本号。例如,要为Ubuntu Maverick安装CDH3 Update 0,请在上面的命令中使用maverick-cdh3u0。 )
(可选)添加存储库密钥。 通过执行以下命令,将Cloudera Public GPG密钥添加到您的存储库:
$ curl -s http://archive.cloudera.com/debian/archive.key | sudo apt-key add -
此密钥使您可以验证是否正在下载正版软件包
最初设定
在hadoop-agent-1和hadoop-collector-1上,都必须安装flume-node(flume-node包含运行代理或收集器所需的文件)。
sudo apt-get update
sudo apt-get install flume-node
在hadoop-master-1上:
sudo apt-get update
sudo apt-get install flume-master
首先,让我们跳到代理上并进行设置。 适当调整hadoop-master-1和hadoop-collector-1变量,但将/etc/flume/conf/flume-site.xml更改为:
<configuration>
<property>
<name>flume.master.servers</name>
<value>hadoop-master-1</value>
<description>This is the address for the config servers status server (http)</description>
</property>
<property>
<name>flume.collector.event.host</name>
<value>hadoop-collector-1</value>
<description>This is the host name of the default 'remote' collector.</description>
</property>
<property>
<name>flume.collector.port</name>
<value>35853</value>
<description>This default tcp port that the collector listens to in order to receive events it is collecting.</description>
</property>
<property>
<name>flume.agent.logdir</name>
<value>/tmp/flume-${user.name}/agent</value>
<description> This is the directory that write-ahead logging data
or disk-failover data is collected from applications gets
written to. The agent watches this directory.
</description>
</property>
</configuration>
现在到收集器。 同一文件,不同配置。
<configuration>
<property>
<name>flume.master.servers</name>
<value>hadoop-master-1</value>
<description>This is the address for the config servers status server (http)</description>
</property>
<property>
<name>flume.collector.event.host</name>
<value>hadoop-collector-1</value>
<description>This is the host name of the default 'remote' collector.</description>
</property>
<property>
<name>flume.collector.port</name>
<value>35853</value>
<description>This default tcp port that the collector listens to in order to receive events it is collecting.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://hadoop-master-1:8020</value>
</property>
<property>
<name>flume.agent.logdir</name>
<value>/tmp/flume-${user.name}/agent</value>
<description> This is the directory that write-ahead logging data
or disk-failover data is collected from applications gets
written to. The agent watches this directory.
</description>
</property>
<property>
<name>flume.collector.dfs.dir</name>
<value>file:///tmp/flume-${user.name}/collected</value>
<description>This is a dfs directory that is the the final resting
place for logs to be stored in. This defaults to a local dir in
/tmp but can be hadoop URI path that such as hdfs://namenode/path/
</description>
</property>
<property>
<name>flume.collector.dfs.compress.gzip</name>
<value>true</value>
<description>Writes compressed output in gzip format to dfs. value is
boolean type, i.e. true/false</description>
</property>
<property>
<name>flume.collector.roll.millis</name>
<value>60000</value>
<description>The time (in milliseconds)
between when hdfs files are closed and a new file is opened
(rolled).
</description>
</property>
</configuration>
基于网络的设置
我选择通过主Web界面进行单机设置。 您可以在http:// hadoop-master-1:35871 /(将hadoop-master-1替换为Flume Master的公共/私有DNS IP或为主机名设置/ etc / hosts)上指向网络浏览器。 确保通过安全设置可从外部访问端口。 在这一点上,最简单的方法是确保所有运行flume的主机都可以与运行flume的所有其他主机上的所有端口进行通信。 一旦一切正常运行,您当然可以将其锁定到各个端口以确保安全。
此时,您应该转到hadoop-agent-1和hadoop-collector-1运行/etc/init.d/flume-node start。 如果一切顺利,则应通知主服务器(在其配置中指定了IP)。 现在,您可以从Web配置它们。 单击配置链接,然后按如下所示填写文本行(使用粗体显示):
代理节点:hadoop-agent-1
来源:tailDir(“ / var / logs / apache2 /",".*。log”)
接收器:agentBESink(“ hadoop-collector-1?,35853) 注意:我选择使用tailDir,因为我将控制自己旋转日志。 我也使用agentBESink,因为如果发生这种情况,我可以丢失日志行。
现在单击提交查询,然后返回到配置页面以设置收集器:
代理节点:hadoop-collector-1
资料来源:collectorSource(35853)
接收器:collectorSink(“ hdfs:// hadoop-master-1:8020 / flume / logs /%Y /%m /%d /%H00 ?,“服务器”) 这将告诉收集器,我们将使用初始文件夹'flume'进入HDFS。 然后它将以“ flume / logs / YYYY / MM / DD / HH00?”登录到子文件夹。 (或2011/02/03/1300 / server-.log)。 现在,单击Submit Query并转到“ master”页面,您应该在命令历史记录中看到2个命令列为“ SUCCEEDED”。 如果他们没有成功,请确保已完成一些操作(可能还有更多操作,但这是一个方便的开始:
始终使用双引号(“),因为单引号(')的解释不正确。 更新:单引号正确解释,只是不被有意接受(感谢jmhsieh)
在您的正则表达式中,请使用“。* \\。log”之类的“。” 是正则表达式的一部分。 在您的正则表达式中,确保正确地转义了黑色斜线:“ foo \\ bar”是尝试匹配“ foo \ bar”的正确版本。
此外,还有“节点状态”和“节点配置”表。 这些应该与您认为的配置相匹配。
此时一切都应该正常工作。 诚然,到这一点,我遇到了很多麻烦。 但是在#flume中irc.freenode.net上的Cloudera员工和用户的帮助下,我得以使事情顺利进行。 遗憾的是,在大多数情况下,日志在这里并没有太大帮助(但是无论如何,它们看起来可能会比为我提供的信息多给您提供更多信息)。 如果我错过了这篇文章中的任何内容,或者有其他我不知道的内容,请告诉我。
参考: Evan Conkle博客博客中的JCG合作伙伴 Evan Conkle提供的带有HDFS Sink的分布式Apache Flume安装程序 。
翻译自: https://www.javacodegeeks.com/2012/10/distributed-apache-flume-setup-with.html