【问题标题】:rsync "connection refused" errorrsync“连接被拒绝”错误
【发布时间】:2018-05-04 16:12:19
【问题描述】:

我对 rsync 感到疯狂,这给了我一个“连接被拒绝”的错误。这是我的问题: 我有两台服务器,用于存储数据,安装了 rsync,因为我需要两台服务器保持同步。这样,在一台服务器上的修改将导致另一台服务器上的相同修改,反之亦然。第一个节点 (sn1) 工作,而第二个 (sn2) 不工作。在细节。 - sn1 有 192.168.13.131 作为 ip 地址 - sn2 有 192.168.13.132 作为 ip 地址

如果我从 sn1 或 sn2 给rsync rsync://192.168.13.131,它工作正常;而如果我从 sn1 或 sn2 提供rsync rsync://182.168.13.132,则会收到此错误:

rsync: failed to connect to 192.168.13.132 (192.168.13.132): Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(125) [Receiver=3.1.2]

这里有一些关于 sn2 的信息。 /etc/rsyncd.conf

uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.130.132

[account]
max connections = 20
path = /srv/node/
read only = False
lock file = /var/lock/account.lock

[container]
max connections = 20
path = /srv/node/
read only = False
lock file = /var/lock/container.lock

[object]
max connections = 20
path = /srv/node/
read only = False
lock file = /var/lock/object.lock

/etc/default/rsync

# defaults file for rsync daemon mode
#
# This file is only used for init.d based systems!
# If this system uses systemd, you can specify options etc. for rsync
# in daemon mode by copying /lib/systemd/system/rsync.service to
# /etc/systemd/system/rsync.service and modifying the copy; add required
# options to the ExecStart line.

# start rsync in daemon mode from init.d script?
#  only allowed values are "true", "false", and "inetd"
#  Use "inetd" if you want to start the rsyncd from inetd,
#  all this does is prevent the init.d script from printing a message
#  about not starting rsyncd (you still need to modify inetd's config yourself).
RSYNC_ENABLE=true

# which file should be used as the configuration file for rsync.
# This file is used instead of the default /etc/rsyncd.conf
# Warning: This option has no effect if the daemon is accessed
#          using a remote shell. When using a different file for
#          rsync you might want to symlink /etc/rsyncd.conf to
#          that file.
# RSYNC_CONFIG_FILE=

# what extra options to give rsync --daemon?
#  that excludes the --daemon; that's always done in the init.d script
#  Possibilities are:
#   --address=123.45.67.89              (bind to a specific IP address)
#   --port=8730                         (bind to specified port; default 873)
RSYNC_OPTS=''

# run rsyncd at a nice level?
#  the rsync daemon can impact performance due to much I/O and CPU usage,
#  so you may want to run it at a nicer priority than the default priority.
#  Allowed values are 0 - 19 inclusive; 10 is a reasonable value.
RSYNC_NICE=''

# run rsyncd with ionice?
#  "ionice" does for IO load what "nice" does for CPU load.
#  As rsync is often used for backups which aren't all that time-critical,
#  reducing the rsync IO priority will benefit the rest of the system.
#  See the manpage for ionice for allowed options.
#  -c3 is recommended, this will run rsync IO at "idle" priority. Uncomment
#  the next line to activate this.
# RSYNC_IONICE='-c3'

# Don't forget to create an appropriate config file,
# else the daemon will not start.

现在是一些日志。 /var/log/rsyncd.log

2018/05/04 15:10:16 [889] rsyncd version 3.1.2 starting, listening on port 873
2018/05/04 15:10:16 [889] bind() failed: Cannot assign requested address (address-family 2)
2018/05/04 15:10:16 [889] unable to bind any inbound sockets on port 873
2018/05/04 15:10:16 [889] rsync error: error in socket IO (code 10) at socket.c(555) [Receiver=3.1.2]

sn2 上ps aux | grep rsync 命令的输出:

sn2       1555  0.0  0.1  13136  1060 pts/0    S+   15:46   0:00 grep --color=auto rsync

sn1 上ps aux | grep rsync 命令的输出:

sn1      12875  0.0  0.1  13136  1012 pts/0    S+   15:48   0:00 grep --color=auto rsync
root     21281  0.0  0.2  12960  2800 ?        Ss   13:31   0:00 /usr/bin/rsync --daemon --no-detach

这是我看到的两个节点之间的主要区别。

sn1 上命令sudo systemctl status rsync 的输出:

rsync.service - fast remote file copy program daemon
   Loaded: loaded (/lib/systemd/system/rsync.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-05-04 13:31:10 UTC; 2h 19min ago
 Main PID: 21281 (rsync)
    Tasks: 1 (limit: 1113)
   CGroup: /system.slice/rsync.service
           └─21281 /usr/bin/rsync --daemon --no-detach

May 04 13:31:10 sn1 systemd[1]: Started fast remote file copy program daemon.

sn2中相同命令的输出:

rsync.service - fast remote file copy program daemon
   Loaded: loaded (/lib/systemd/system/rsync.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2018-05-04 15:10:16 UTC; 41min ago
  Process: 889 ExecStart=/usr/bin/rsync --daemon --no-detach (code=exited, status=10)
 Main PID: 889 (code=exited, status=10)

May 04 15:10:15 sn2 systemd[1]: Started fast remote file copy program daemon.
May 04 15:10:16 sn2 systemd[1]: rsync.service: Main process exited, code=exited, status=10/n/a
May 04 15:10:16 sn2 systemd[1]: rsync.service: Failed with result 'exit-code'.

sn1 上命令sudo netstat -lptu | grep rsync 的输出:

tcp        0      0 sn1:rsync               0.0.0.0:*               LISTEN      21281/rsync

在 sn2 中它什么也不返回...

sn2 /etc/hosts 终于包含了

127.0.0.1       localhost.localdomain   localhost
::1             localhost6.localdomain6 localhost6


#ADDED BY ME
#10.0.2.15       sn2
192.168.13.130  proxy-server
192.168.13.131  sn1
192.168.13.132  sn2
#192.168.13.133  sn3
#192.168.13.134  sn4

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

还有 sn1:

127.0.0.1       localhost.localdomain   localhost
::1             localhost6.localdomain6 localhost6


#ADDED BY ME
#10.0.2.15       sn1
192.168.13.130  proxy-server
192.168.13.131  sn1
192.168.13.132  sn2
#192.168.13.133  sn3
#192.168.13.134  sn4

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

我在虚拟机上的每个服务器节点上运行 ubuntu 18.04。 你能帮我弄清楚发生了什么吗?不幸的是,我必须使用 rsync,因为我正在使用 OpenStack Swift,所以不允许更改 :)

【问题讨论】:

    标签: rsync openstack-swift connection-refused


    【解决方案1】:

    好的,我已经完成了。很简单,只需获得超级用户权限,然后启用并启动 rsync 进程:

    sudo su
    

    输入您的密码,然后输入数字

    systemctl enable rsync
    systemctl start rsync
    

    如果您没有基于 systemctl 的终端,请改用“服务”。

    service rsync restart
    

    您可以通过访问 /var/log/rsyncd.log 来检查 rsync 现在是否正常工作。 bind() 错误现在消失了。

    【讨论】:

      【解决方案2】:

      使用默认配置,我总是使用rsync -rtP /home/me/source/ x.x.x.x:/home/someoneelse/source(其中 x.x.x.x 是实际的 IP 地址)。我不知道何时或是否需要将 rsync:// 指定为协议。就我而言,在启用 sshd 之前,我遇到了您的错误。我还安装了 rsync-daemon 但我实际上不知道是否需要。这是整个解决方案(我只在远程计算机上执行此操作——我相信本地计算机,然后我可以在其上成功运行上述命令,只有 openssh 和 rsync 包):

      sudo dnf -y install rsync-daemon openssh
      sudo systemctl enable rsyncd
      sudo systemctl start rsyncd
      sudo systemctl enable sshd
      sudo systemctl start sshd
      

      明确地说,我有 Fedora 27,sudo systemctl status firewalld 说防火墙正在运行,我不必手动创建我知道的防火墙规则(在我的 bash 历史记录中没有防火墙或 iptables 实例) .在成功运行的命令(在此答案的顶部)中,我使用了一些选项,但它们不是必需的:r:递归,t:将时间戳复制到目标文件,P:显示进度。正斜杠 (/) 仅位于源路径的末尾,因此 rsync 不会在目标中创建名为 /home/someoneelse/source/source 的目录。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-18
        • 2016-12-09
        • 2018-04-21
        • 2016-04-25
        • 2015-07-29
        相关资源
        最近更新 更多