1

我正在尝试从 /home/cloudera/Documents/flume/ 读取日志文件,并使用 apache flume 将其写入 hdfs。我使用以下命令在 hdfs 创建 flumeLogTest 文件夹:

sudo -u hdfs hadoop fs -mkdir flumeLogTest
sudo -u hdfs hadoop fs -chown flume:flume flumeLogTest

我的配置文件是:

agent.sources = src
agent.channels = ch
agent.sinks = snk

agent.sources.src.type = exec
agent.sources.src.command = tail -f Documents/flume/vmware-0.log
agent.sources.src.channels = ch

agent.sinks.snk.channel = ch
agent.sinks.snk.type = hdfs
agent.sinks.snk.hdfs.path = hdfs://localhost.localdomain:8020/user/hdfs/flumeLogTest
agent.sinks.snk.hdfs.fileType = DataStream
agent.sinks.snk.hdfs.writeFormat = Text

agent.channels.ch.type = memory
agent.channels.ch.capacity = 100

我通过以下命令启动了水槽代理:

/usr/bin/flume-ng agent --conf Documents/flume --conf-file Documents/flume/Example1.conf --name agent

其中 Documents/flume 是 /home/cloudera/ 中的一个文件夹,该文件夹包含以下文件

  1. 水槽-conf.properties.template
  2. log4j.properties
  3. 水槽-env.sh.template
  4. 水槽-env.sh
  5. Example1.conf

我收到以下错误:

log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /var/log/flume-ng/flume.log (Permission denied)
    at java.io.FileOutputStream.openAppend(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:192)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:116)
    at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
    at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
    at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
    at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
    at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
    at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
    at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
    at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
    at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:254)
    at org.apache.flume.node.Application.<clinit>(Application.java:58)

我希望我对这个问题很清楚。请帮我解决这个问题。提前致谢。

4

1 回答 1

0

检查 /var/log/flume-ng/flume.log 的文件权限并更改它。

sudo chown flume /var/log/flume-ng/flume.log

[java.io.FileNotFoundException:/var/log/flume-ng/flume.log(权限被拒绝)]

于 2014-06-12T09:45:37.520 回答