意外错误 error_class=Errno::EADDRINUSE 错误="Address already in use - bind(2) for \"0.0.0.0\"端口 24233"

unexpected error error_class=Errno::EADDRINUSE error="Address already in use - bind(2) for \"0.0.0.0\" port 24233"

我正在使用 Fluentd + ElasticSearch + Kibana 我需要使用 stdout 将 mysql 数据推送到 td-agent.log。当我启动 td-agent 时,它在 td-agent 日志中显示一些错误。

这是我的错误:

2016-06-09 12:21:36 +0530 [info]: Worker 0 finished unexpectedly with status 1
2016-06-09 12:21:37 +0530 [info]: reading config file path="/etc/td-agent/td-agent.conf"
2016-06-09 12:21:37 +0530 [info]: starting fluentd-0.14.0 without supervision
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-mixin-config-placeholders' version '0.4.0'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-mixin-config-placeholders' version '0.3.1'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-mixin-plaintextformatter' version '0.2.6'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-elasticsearch' version '1.5.0'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-grok-parser' version '0.3.1'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-mongo' version '0.7.13'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-mongo' version '0.7.12'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-mysql' version '0.1.3'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-mysql-query' version '0.3.0'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-mysql-replicator' version '0.5.2'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-rewrite-tag-filter' version '1.5.5'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-s3' version '0.6.8'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-s3' version '0.6.5'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-scribe' version '0.10.14'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-secure-forward' version '0.4.1'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-snmp' version '0.0.8'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-tail-ex' version '0.1.1'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-td' version '0.10.28'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-td-monitoring' version '0.2.2'
2016-06-09 12:21:37 +0530 [info]: gem 'fluent-plugin-webhdfs' version '0.4.1'
2016-06-09 12:21:37 +0530 [info]: gem 'fluentd' version '0.14.0'
2016-06-09 12:21:37 +0530 [info]: gem 'fluentd' version '0.12.20'
2016-06-09 12:21:37 +0530 [warn]: 'type' is deprecated parameter name. use '@type' instead.
2016-06-09 12:21:37 +0530 [info]: adding match pattern="replicator.*" type="stdout"
2016-06-09 12:21:37 +0530 [warn]: 'type' is deprecated parameter name. use '@type' instead.
2016-06-09 12:21:37 +0530 [info]: adding source type="forward"
2016-06-09 12:21:37 +0530 [warn]: 'type' is deprecated parameter name. use '@type' instead.
2016-06-09 12:21:37 +0530 [info]: adding source type="http"
2016-06-09 12:21:37 +0530 [warn]: 'type' is deprecated parameter name. use '@type' instead.
2016-06-09 12:21:37 +0530 [info]: adding source type="debug_agent"
2016-06-09 12:21:37 +0530 [warn]: 'type' is deprecated parameter name. use '@type' instead.
2016-06-09 12:21:37 +0530 [info]: adding source type="mysql_replicator"
2016-06-09 12:21:37 +0530 [info]: adding mysql_replicator worker. :tag=>replicator.livechat.chat_chennaibox.${event}.${primary_key} :query=>SELECT chat_name FROM chat_chennaibox; :prepared_query=> :interval=>10sec :enable_delete=>true
2016-06-09 12:21:37 +0530 [info]: using configuration file: <ROOT>
  <source>
    type forward
  </source>
  <source>
    type http
    port 8888
  </source>
  <source>
    type debug_agent
    bind "0.0.0.0"
    port 24233
  </source>
  <source>
    type mysql_replicator
    host "localhost"
    username "root"
    password xxxxxx
    database "livechat"
    query "SELECT chat_name FROM chat_chennaibox;"
    primary_key "chat_id"
    interval "10s"
    enable_delete yes
    tag "replicator.livechat.chat_chennaibox.${event}.${primary_key}"
  </source>
  <match replicator.*>
    type stdout
  </match>
</ROOT>
2016-06-09 12:21:37 +0530 [warn]: super was not called in #start: called it forcedly plugin=Fluent::MysqlReplicatorInput
2016-06-09 12:21:37 +0530 [info]: listening dRuby uri="druby://0.0.0.0:24233" object="Engine"
2016-06-09 12:21:37 +0530 [error]: unexpected error error_class=Errno::EADDRINUSE error="Address already in use - bind(2) for \"0.0.0.0\" port 24233"
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/drb/drb.rb:879:in `initialize'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/drb/drb.rb:879:in `open'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/drb/drb.rb:879:in `open_server'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/drb/drb.rb:764:in `block in open_server'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/drb/drb.rb:762:in `each'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/drb/drb.rb:762:in `open_server'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/2.1.0/drb/drb.rb:1373:in `initialize'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/plugin/in_debug_agent.rb:55:in `new'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/plugin/in_debug_agent.rb:55:in `start'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/compat/call_super_mixin.rb:42:in `start'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/root_agent.rb:138:in `block in start'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/root_agent.rb:127:in `block (2 levels) in lifecycle'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/root_agent.rb:126:in `each'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/root_agent.rb:126:in `block in lifecycle'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/root_agent.rb:113:in `each'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/root_agent.rb:113:in `lifecycle'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/root_agent.rb:137:in `start'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/engine.rb:211:in `start'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/engine.rb:175:in `run'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/supervisor.rb:580:in `run_engine'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/supervisor.rb:382:in `block in run_worker'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/supervisor.rb:509:in `call'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/supervisor.rb:509:in `main_process'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/supervisor.rb:378:in `run_worker'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/lib/fluent/command/fluentd.rb:266:in `<top (required)>'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluentd-0.14.0/bin/fluentd:5:in `<top (required)>'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/bin/fluentd:23:in `load'
  2016-06-09 12:21:37 +0530 [error]: /opt/td-agent/embedded/bin/fluentd:23:in `<top (required)>'
  2016-06-09 12:21:37 +0530 [error]: /usr/sbin/td-agent:7:in `load'
  2016-06-09 12:21:37 +0530 [error]: /usr/sbin/td-agent:7:in `<main>'
2016-06-09 12:21:37 +0530 [error]: unexpected error error="Address already in use - bind(2) for \"0.0.0.0\" port 24233"
  2016-06-09 12:21:37 +0530 [error]: suppressed same stacktrace

这是我的配置文件:

 ####
## Output descriptions:
##

# Treasure Data (http://www.treasure-data.com/) provides cloud based data
# analytics platform, which easily stores and processes data from td-agent.
# FREE plan is also provided.
# @see http://docs.fluentd.org/articles/http-to-td
#
# This section matches events whose tag is td.DATABASE.TABLE
#<match td.*.*>
#  type tdlog
#  apikey YOUR_API_KEY

#  auto_create_table
#  buffer_type file
#  buffer_path /var/log/td-agent/buffer/td

#  <secondary>
#    type file
#    path /var/log/td-agent/failed_records
#  </secondary>
#</match>

## match tag=debug.** and dump to console
#<match debug.**>
#  type stdout
#</match>

####
## Source descriptions:
##

## built-in TCP input
## @see http://docs.fluentd.org/articles/in_forward
<source>
  type forward
</source>

## built-in UNIX socket input
#<source>
#  type unix
#</source>

# HTTP input
# POST http://localhost:8888/<tag>?json=<json>
# POST http://localhost:8888/td.myapp.login?json={"user"%3A"me"}
# @see http://docs.fluentd.org/articles/in_http
<source>
  type http
  port 8888
</source>

## live debugging agent
<source>
  type debug_agent
  bind 0.0.0.0
  #port 24230
  port 24233
</source>

####
## Examples:
##

## File input
## read apache logs continuously and tags td.apache.access
#<source>
#  type tail
#  format apache
#  path /var/log/httpdaccess.log
#  tag td.apache.access
#</source>

## File output
## match tag=local.** and write to file
#<match local.**>
#  type file
#  path /var/log/td-agent/apache.log
#</match>

## Forwarding
## match tag=system.** and forward to another td-agent server
#<match system.**>
#  type forward
#  host 192.168.0.11
#  # secondary host is optional
#  <secondary>
#    host 192.168.0.12
#  </secondary>
#</match>

## Multiple output
## match tag=td.*.* and output to Treasure Data AND file
#<match td.*.*>
#  type copy
#  <store>
#    type tdlog
#    apikey API_KEY
#    auto_create_table
#    buffer_type file
#    buffer_path /var/log/td-agent/buffer/td
#  </store>
#  <store>
#    type file
#    path /var/log/td-agent/td-%Y-%m-%d/%H.log
#  </store>
#</match>
#<source>
#  @type tail
#  format apache
#  tag apache.access
#  path /var/log/td-agent/apache_log/ssl_access_log.1
#  read_from_head true
# pos_file /var/log/httpd/access_log.pos
#</source>
#<match apache.access*>
#  type stdout
#</match>

#<source>
#  @type tail
#  format magento_system 
#  tag magento.access
#  path /var/log/td-agent/Magento_log/system.log
#  pos_file /tmp/fluentd_magento_system.pos
#  read_from_head true 
#</source>

#<match apache.access
#  type stdout
#</match>
#<source>
#  @type http
#  port 8080
#  bind localhost
#  body_size_limit 32m
#  keepalive_timeout 10s
#</source>
#<match magento.access*>
# type stdout
#</match>
#<match magento.access*>
#  @type elasticsearch
#  logstash_format true
#  host localhost
# port 9200
#</match>
<source>
  type mysql_replicator
  host localhost
  username root
  password gworks.mobi2
  database livechat
  query SELECT chat_name FROM chat_chennaibox;
  #query SELECT t2.firstname,t2.lastname, t1.* FROM status t1 INNER JOIN student_detail t2 ON t1.number = t2.number;
  primary_key chat_id # specify unique key (default: id)
  interval 10s  # execute query interval (default: 1m)
  enable_delete yes
  tag replicator.livechat.chat_chennaibox.${event}.${primary_key}
</source>
<match replicator.*>
type stdout
</match>

提示我我错了?以及如何解决这个问题?

您 post 的主题说明了原因:地址已用于端口 24233。 通过lsof命令或其他方式搜索使用24233端口的进程,然后kill掉。

我解决了我的问题。我的问题是 ruby 运行 多个 PID。

所以,我发现 Ruby 运行 PID 使用此命令:

  ps aux | grep ruby 

上面的命令显示所有 ruby 运行 端口 然后,杀死所有进程。然后 运行 td-agent。 它为我工作。