您的位置:首页 > 其它

Flume-ng禁用自动加载配置文件功能

2017-03-20 16:56 405 查看
默认情况下,Flume中的
PollingPropertiesFileConfigurationProvider
会每隔30秒去重新加载Flume
agent的配置文件,如果监听到配置文件变化了,Flume会试图重新加载变化的配置文件。判断配置文件是否变化主要是基于文件的最后修改时间来的,代码片段如下:

/////////////////////////////////////////////////////////////////////
User: 过往记忆
Date: 2015-08-19
Time: 23:59
bolg: https://www.iteblog.com 本文地址:https://www.iteblog.com/archives/1467
过往记忆博客,专注于hadoop、hive、spark、shark、flume的技术博客,大量的干货
过往记忆博客微信公共帐号:iteblog_hadoop
/////////////////////////////////////////////////////////////////////
@Override
public void run() {
LOGGER.debug("Checking file:{} for changes", file);

counterGroup.incrementAndGet("file.checks");

long lastModified = file.lastModified();

if (lastModified > lastChange) {
LOGGER.info("Reloading configuration file:{}", file);

counterGroup.incrementAndGet("file.loads");

lastChange = lastModified;

try {
eventBus.post(getConfiguration());
} catch (Exception e) {
LOGGER.error("Failed to load configuration data. Exception follows.",
e);
} catch (NoClassDefFoundError e) {
LOGGER.error("Failed to start agent because dependencies were not " +
"found in classpath. Error follows.", e);
} catch (Throwable t) {
// caught because the caller does not handle or log Throwables
LOGGER.error("Unhandled error", t);
}
}
}

然而,通常情况下,用户修改了配置文件之后就不会再去修改,而且让Flume自动去加载配置文件有时还会出现问题。不过值得高兴的是,我们可以在启动Flume的时候通过加上
--no-reload-conf
配置来禁止Flume自动加载配置文件。这个属性在Flume的官方文档并没有介绍;而且只有Apache的Flume存在这个参数,如果你使用的是Cloudera的Flume发行版,这个参数是不支持的,不过有人在
https://issues.cloudera.org/browse/DISTRO-648
里面提到这个参数,如果你感兴趣可以去看下。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: