flume在另一台服务器上侦听syslog时发生绑定异常

ny6fqffe  于 2021-06-04  发布在  Flume
关注(0)|答案(1)|浏览(362)

环境

我有两台Ubuntu14.04服务器,运行在windows 7机器上的oracle虚拟机上,它们可以通过ping看到对方:
serverone有一个syslogng组件(ip:192.168.1.1)监听postgresql数据库
服务器2有apache flume(ip:192.168.1.2)

服务器1具有以下syslog-ng.conf文件(部分):


# POSTGRESQL_LOGGER

destination logpgsql { file("/var/log/pgsql"); };
destination loghost {tcp("192.168.1.2" port(41414));};  # IP of Server TWO. Is it Correct? 
filter f_postgres { facility(local0); };
filter f_sql_insert {match(".*INSERT INTO prova.*;");};
log { source(s_src); 
      filter(f_postgres); 
      filter(f_sql_insert); 
      destination(loghost);
      destination(logpgsql);};

(服务器1正确接收来自s\u src的消息,并将它们正确地保存在pgsql日志文件中)

服务器2有以下flume-syslog.conf文件:


# Name the components on this agent

a1.sources = r1
a1.sinks = k1
a1.channels = c1

# TCP based Syslog source

a1.sources.r1.type = syslogtcp    
a1.sources.r1.port = 41414
a1.sources.r1.host = 192.168.1.1   # IP of Server ONE. Is it Correct?

# Describe the sink

a1.sinks.k1.type = logger

# Channel which buffers events in memory

a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Source and sinks to the channel

a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

当我启动flume应用程序时:

flume-ng agent --conf conf --conf-file conf/flume-syslog.conf --name a1 -Dflume.root.logger=INFO,console

我有个例外:

2015-04-25 11:58:39,236 (lifecycleSupervisor-1-1) [INFO - org.apache.flume.source.SyslogTcpSource.start(SyslogTcpSource.java:118)] Syslog TCP Source starting...
2015-04-25 11:58:39,237 (lifecycleSupervisor-1-1) [ERROR - org.apache.flume.lifecycle.LifecycleSupervisor$MonitorRunnable.run(LifecycleSupervisor.java:253)] Unable to start EventDrivenSourceRunner: { source:org.apache.flume.source.SyslogTcp
Source{name:r1,state:IDLE} } - Exception follows.
org.jboss.netty.channel.ChannelException: Failed to bind to: /192.168.1.1:41414
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:297)
    at org.apache.flume.source.SyslogTcpSource.start(SyslogTcpSource.java:123)
    at org.apache.flume.source.EventDrivenSourceRunner.start(EventDrivenSourceRunner.java:44)
    at org.apache.flume.lifecycle.LifecycleSupervisor$MonitorRunnable.run(LifecycleSupervisor.java:251)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293
)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.BindException: Cannot assign requested address
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.bind(NioServerSocketPipelineSink.java:140)
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleServerSocket(NioServerSocketPipelineSink.java:90)
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:64)

    at org.jboss.netty.channel.Channels.bind(Channels.java:569)
    at org.jboss.netty.channel.AbstractChannel.bind(AbstractChannel.java:189)
    at org.jboss.netty.bootstrap.ServerBootstrap$Binder.channelOpen(ServerBootstrap.java:342)
    at org.jboss.netty.channel.Channels.fireChannelOpen(Channels.java:170)
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannel.<init>(NioServerSocketChannel.java:80)
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:158)
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:86)
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:276)
    ... 10 more

该怎么办?谢谢你的期待。

pcww981p

pcww981p1#

在服务器1上的flume-syslog.conf中,ip应该是自己的:


# TCP based Syslog source

a1.sources.r1.type = syslogtcp    
a1.sources.r1.port = 41414
a1.sources.r1.host = 192.168.1.2

相关问题