首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >rsync“连接拒绝”错误

rsync“连接拒绝”错误
EN

Stack Overflow用户
提问于 2018-05-04 16:12:19
回答 2查看 17.9K关注 0票数 1

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

如果我从sn1或sn2中给出了rsync rsync://182.168.13.132,它会运行得很好;而如果我从sn1或sn2中给出了rsync rsync://182.168.13.132,则会得到以下错误:

代码语言:javascript
复制
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

代码语言:javascript
复制
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

代码语言:javascript
复制
# 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

代码语言:javascript
复制
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]

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

代码语言:javascript
复制
sn2       1555  0.0  0.1  13136  1060 pts/0    S+   15:46   0:00 grep --color=auto rsync

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

代码语言:javascript
复制
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

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

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

代码语言:javascript
复制
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中相同命令的输出:

代码语言:javascript
复制
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'.

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

代码语言:javascript
复制
tcp        0      0 sn1:rsync               0.0.0.0:*               LISTEN      21281/rsync

在sn2的时候它什么也不回..。

最后,sn2 /etc/主机包含

代码语言:javascript
复制
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:

代码语言:javascript
复制
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

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-05-07 10:01:42

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

代码语言:javascript
复制
sudo su

输入密码,然后输入数字

代码语言:javascript
复制
systemctl enable rsync
systemctl start rsync

如果您没有基于systemctl的终端,只需使用"service“即可。

代码语言:javascript
复制
service rsync restart

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

票数 1
EN

Stack Overflow用户

发布于 2018-10-29 16:45:00

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

代码语言:javascript
复制
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/某人/源/源的目录。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50179178

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档