rsyncopenstack-swiftconnection-refused

rsync "connection refused" error


I'm getting crazy with rsync which gives me a "connection refused" error. Here's my problem: I have two servers, used to store datas, with rsync installed on because I need that both servers stay synchronized. In this way, modifies on one server will cause the same modifies on the other and viceversa. The first node (sn1) works while the second (sn2) do not. In details. - sn1 has 192.168.13.131 as ip address - sn2 has 192.168.13.132 as ip address

If I give rsync rsync://192.168.13.131 from sn1 or sn2, it works fine; while if I give rsync rsync://182.168.13.132 from sn1 or sn2, I get this error:

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]

Here's some information about 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

and /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.

Now some logs. /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]

Output of ps aux | grep rsync command on sn2:

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

Output of ps aux | grep rsync command on sn1:

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

This is the main difference I see between the two nodes.

Output of the command sudo systemctl status rsync on sn1:

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.

Output of the same command in 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'.

Output of the command sudo netstat -lptu | grep rsync on sn1:

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

while in sn2 it returns nothing...

Finally the sn2 /etc/hosts containt

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

And sn1 as well:

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

I'm running ubuntu 18.04 in each server node, on a virtual machine. Can you help me to figure out what is happening? Unfortunately I must use rsync because I'm working on OpenStack Swift, so no change are allowed :)


Solution

  • Ok, I've done. It was simply, just gain super user privilege and then enable and start rsync process:

    sudo su
    

    enter your password, then digit

    systemctl enable rsync
    systemctl start rsync
    

    if you don't have a systemctl based terminal just use "service" instead.

    service rsync restart
    

    You can check that rsync is now working by accessing to /var/log/rsyncd.log. The bind() error is now gone.