rsync安装出现failed to connect to解决办法
今天在安装rsync的时候疯狂出现了一个错误,我本以为是自己错误,在重新做了三遍之后发现确实有其他原因致使我出错。我中间也去在博客上搜了关于其他人记录的问题,都没有解决。先找到了解决办法,分享给大家。
我当时是报这样的错误:
首先去看了自己两边的防火墙,都关闭了,这不是我错误的原因。
在我找了很久之后查看了服务的开启状态
客户端:
[root@client ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 694/rpcbind
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1632/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1125/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1123/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1282/master
tcp6 0 0 :::3306 :::* LISTEN 1411/mysqld
tcp6 0 0 :::111 :::* LISTEN 694/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1125/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1123/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1282/master
[root@client ~]# systemctl status rsyncd
● rsyncd.service - fast remote file copy program daemon
Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
##rsync是inactive状态说明我的rsync服务没有开启
解决:
客户端
##启动服务
[root@client ~]# systemctl start rsyncd
[root@client rsync_test]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2287/rsync
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 694/rpcbind
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1632/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1125/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1123/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1282/master
tcp6 0 0 :::873 :::* LISTEN 2287/rsync
tcp6 0 0 :::3306 :::* LISTEN 1411/mysqld
tcp6 0 0 :::111 :::* LISTEN 694/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1125/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1123/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1282/master
##出现了rsync服务端口873
[root@client rsync_test]# systemctl status rsyncd
● rsyncd.service - fast remote file copy program daemon
Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2022-11-06 20:41:17 CST; 4min 38s ago
Main PID: 2287 (rsync)
Tasks: 1
CGroup: /system.slice/rsyncd.service
└─2287 /usr/bin/rsync --daemon --no-detach
Nov 06 20:41:17 client systemd[1]: Started fast remote file copy program daemon.
##状态也是活跃的
服务器端:
[root@192 ~]# rsync -a --password-file=/etc/rsync.password /tmp/ rsync_user1@192.168.119.140::rsync_test
##不再报错
客户端:
##服务端的/tmp下的文件成功被同步到了客户端
[root@client rsync_test]# ls
mysql.sock
mysql.sock.lock
ssh-5NHQMHVjJkaV
systemd-private-bba2d6ea29ee499eb7f64d5ffc2d0a68-bolt.service-G1Qa2R
systemd-private-bba2d6ea29ee499eb7f64d5ffc2d0a68-chronyd.service-Oy46SL
systemd-private-bba2d6ea29ee499eb7f64d5ffc2d0a68-colord.service-qFl11f
systemd-private-bba2d6ea29ee499eb7f64d5ffc2d0a68-cups.service-PwgDX1
systemd-private-bba2d6ea29ee499eb7f64d5ffc2d0a68-fwupd.service-Ird9fg
systemd-private-bba2d6ea29ee499eb7f64d5ffc2d0a68-rtkit-daemon.service-feNVts
systemd-private-d7aa5276b2b442f79a5fd52fdd26c37c-bolt.service-WDDloq
systemd-private-d7aa5276b2b442f79a5fd52fdd26c37c-chronyd.service-fK0yOr
systemd-private-d7aa5276b2b442f79a5fd52fdd26c37c-colord.service-XZePyz
systemd-private-d7aa5276b2b442f79a5fd52fdd26c37c-cups.service-YGv3d8
systemd-private-d7aa5276b2b442f79a5fd52fdd26c37c-rtkit-daemon.service-3UqZGW
tracker-extract-files.0
vmware-root_715-4281843213
vmware-root_721-4290559889
vmware-root_742-2991137376
yum_save_tx.2022-11-06.19-44.eo3jjz.yumtx
总结:在用yum安装了rsync的时候,我默认了rsync服务是开启的,所以导致了后面查看服务没有开启而报错。