rsync"连接被拒绝"错误

时间:2018-05-04 16:12:19

标签: rsync openstack-swift connection-refused

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

如果我从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,因此不允许进行任何更改:)

2 个答案:

答案 0 :(得分:1)

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

sudo su

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

systemctl enable rsync
systemctl start rsync

如果您没有基于systemctl的终端,请改为使用“service”。

service rsync restart

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

答案 1 :(得分:0)

在默认配置下,我总是执行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的目录。