1. 程式人生 > >【CentOS 7筆記49】,rsync通過服務同步1#

【CentOS 7筆記49】,rsync通過服務同步1#

shallow丿ove


rsync

  • rsync通過ssh方式同步

  • rsync -av test1/ 192。168.133.132:/tmp/test2/

  • rsync -av -e "ssh -p 22" test1/ 192.168.133.132:/tmp/test2/

  • rsync 通過服務的方式服務

  • 要編輯配置檔案/etc/rsyncd.conf

  • 啟動服務rsync --daemon

  • 格式:rsync -av test1/ 192.168.133.130::module/dir/

  • rsync.conf樣例

  • Linux主機A:192.168.9.134

[root@localhost ~]# vi /etc/rsyncd.conf
port=873
log file=/var/log/rsync.log
pid file=/var/run/rysncd.pid
address=192.168.9.134
[test]
path=/tmp/rsync
use chroot=true
max connections=4
read only=no
list=true
uid=root
gid=root
auth users=test
secrets file=/etc/rsyncd.passwd
hosts allow=192.168.9.233
[root@localhost ~]# rsync --daemon
[root@localhost ~]# ps aux | grep rsync
root       2959  0.0  0.0 114656   524 ?        Ss   04:37   0:00 rsync --daemon
root       2961  0.0  0.0 112656   972 pts/0    S+   04:38   0:00 grep --color=auto rsync
[root@localhost ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2465/master         
tcp        0      0 0.0.0.0:50458           0.0.0.0:*               LISTEN      1513/rpc.statd      
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -                   
tcp        0      0 192.168.9.134:873       0.0.0.0:*               LISTEN      2959/rsync          
tcp        0      0 0.0.0.0:45289           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:20048           0.0.0.0:*               LISTEN      1892/rpc.mountd     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1412/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      2465/master         
tcp6       0      0 :::56409                :::*                    LISTEN      1513/rpc.statd      
tcp6       0      0 :::2049                 :::*                    LISTEN      -                   
tcp6       0      0 :::59244                :::*                    LISTEN      -                   
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::20048                :::*                    LISTEN      1892/rpc.mountd     
tcp6       0      0 :::22                   :::*                    LISTEN      1412/sshd 
[root@localhost ~]# mkdir /tmp/rsync
[root@localhost ~]# chmod 777 /tmp/rsync
  • Linux主機B:192.168.9.233
[root@centos11233 ~]# rsync -avp /tmp/hello.txt 192.168.9.134::test/world.txt
rsync: failed to connect to 192.168.9.134 (192.168.9.134): No route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(122) [sender=3.0.9]
[root@centos11233 ~]# ping 192.168.9.134
PING 192.168.9.134 (192.168.9.134) 56(84) bytes of data.
64 bytes from 192.168.9.134: icmp_seq=1 ttl=64 time=0.229 ms
64 bytes from 192.168.9.134: icmp_seq=2 ttl=64 time=0.460 ms
64 bytes from 192.168.9.134: icmp_seq=3 ttl=64 time=0.317 ms
^C
--- 192.168.9.134 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.229/0.335/0.460/0.096 ms
[root@centos11233 ~]# telnet 192.168.9.134 873
-bash: telnet: command not found

檢測埠是否通過

[root@centos11233 ~]# yum install -y telnet
Loaded plugins: fastestmirror
base                                                                        | 3.6 kB  00:00:00     
extras                                                                      | 3.4 kB  00:00:00     
updates                                                                     | 3.4 kB  00:00:00     
updates/7/x86_64/primary_db                                                 | 4.5 MB  00:00:09     
Determining fastest mirrors
 * base: mirrors.nwsuaf.edu.cn
 * extras: mirrors.sohu.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package telnet.x86_64 1:0.17-64.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================
 Package              Arch                 Version                        Repository          Size
===================================================================================================
Installing:
 telnet               x86_64               1:0.17-64.el7                  base                64 k

Transaction Summary
===================================================================================================
Install  1 Package

Total download size: 64 k
Installed size: 113 k
Downloading packages:
telnet-0.17-64.el7.x86_64.rpm                                               |  64 kB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:telnet-0.17-64.el7.x86_64                                                     1/1 
  Verifying  : 1:telnet-0.17-64.el7.x86_64                                                     1/1 

Installed:
  telnet.x86_64 1:0.17-64.el7                                                                      

Complete!

[root@centos11233 ~]# telnet 192.168.9.134 873
Trying 192.168.9.134...
telnet: connect to address 192.168.9.134: No route to host

埠不通檢測iptables是否有問題

[root@centos11233 ~]# iptables -nvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
 1324 5324K ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
    7   828 INPUT_direct  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    7   828 INPUT_ZONES_SOURCE  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    7   828 INPUT_ZONES  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate INVALID
    5   692 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
    0     0 FORWARD_direct  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 FORWARD_IN_ZONES_SOURCE  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 FORWARD_IN_ZONES  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 FORWARD_OUT_ZONES_SOURCE  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 FORWARD_OUT_ZONES  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate INVALID
    0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT 1092 packets, 85012 bytes)
 pkts bytes target     prot opt in     out     source               destination         
 1092 85012 OUTPUT_direct  all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain FORWARD_IN_ZONES (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 FWDI_public  all  --  ens33  *       0.0.0.0/0            0.0.0.0/0           [goto] 
    0     0 FWDI_public  all  --  +      *       0.0.0.0/0            0.0.0.0/0           [goto] 

Chain FORWARD_IN_ZONES_SOURCE (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD_OUT_ZONES (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 FWDO_public  all  --  *      ens33   0.0.0.0/0            0.0.0.0/0           [goto] 
    0     0 FWDO_public  all  --  *      +       0.0.0.0/0            0.0.0.0/0           [goto] 

Chain FORWARD_OUT_ZONES_SOURCE (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD_direct (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain FWDI_public (2 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 FWDI_public_log  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 FWDI_public_deny  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 FWDI_public_allow  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain FWDI_public_allow (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain FWDI_public_deny (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain FWDI_public_log (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain FWDO_public (2 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 FWDO_public_log  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 FWDO_public_deny  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 FWDO_public_allow  all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain FWDO_public_allow (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain FWDO_public_deny (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain FWDO_public_log (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain INPUT_ZONES (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    7   828 IN_public  all  --  ens33  *       0.0.0.0/0            0.0.0.0/0           [goto] 
    0     0 IN_public  all  --  +      *       0.0.0.0/0            0.0.0.0/0           [goto] 

Chain INPUT_ZONES_SOURCE (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain INPUT_direct (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain IN_public (2 references)
 pkts bytes target     prot opt in     out     source               destination         
    7   828 IN_public_log  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    7   828 IN_public_deny  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    7   828 IN_public_allow  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    1    84 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain IN_public_allow (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    1    52 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            tcp dpt:22 ctstate NEW

Chain IN_public_deny (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain IN_public_log (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT_direct (1 references)
 pkts bytes target     prot opt in     out     source               destination 
[root@centos11233 ~]# systemctl stop firewalld
[root@centos11233 ~]# iptables -nvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination  
  • Linux主機A:192.168.9.134
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# iptables -nvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination 
  • Linux主機B:192.168.9.233
[root@centos11233 ~]# telnet 192.168.9.134 873
Trying 192.168.9.134...
Connected to 192.168.9.134.
Escape character is '^]'.
@RSYNCD: 30.0
^]	#按ctrl+u+]
telnet> quit
Connection closed.
[root@centos11233 ~]# rsync -avP /tmp/hello.txt 192.168.9.134::test/world.txt
Password: ^C

  • Linux主機A:192.168.9.134

將/etc/rsyncd.conf的兩行註釋掉 #auth users=test #secrets file=/etc/rsyncd.passwd

  • Linux主機B:192.168.9.233
[root@centos11233 ~]# rsync -avP /tmp/hello.txt 192.168.9.134::test/world.txt
sending incremental file list
hello.txt

sent 69 bytes  received 27 bytes  192.00 bytes/sec
total size is 0  speedup is 0.00

  • Linux主機A:192.168.9.134
[root@localhost ~]# ls /tmp/rsync/
world.txt

  • Linux主機B:192.168.9.233
[root@centos11233 ~]# rsync -avP 192.168.9.134::test/world.txt /tmp/hello1.txt
receiving incremental file list
world.txt

sent 45 bytes  received 100 bytes  290.00 bytes/sec
total size is 0  speedup is 0.00
[root@centos11233 ~]# ls /tmp
hello1.txt  systemd-private-9d76b816a2074ccbac53b674b052d8ed-vgauthd.service-x2RRBN
hello.txt   systemd-private-9d76b816a2074ccbac53b674b052d8ed-vmtoolsd.service-tdPncX

rysncd.conf配置檔案詳解: port:指定在哪個埠啟動rsyncd服務,預設埠號為873。 log file:指定日誌檔案。 pid file:指定pid檔案,這個檔案的作用涉及服務的啟動、停止等程序管理操作。 address:指定啟動rsyncd服務的ip。加入你的機器有多個ip,就可以指定由其中一個啟動rsyncd服務,如果不指定該引數,預設是在全部IP上啟動。 []:指定模組名。裡面內容自定義。 path:指定資料存放的路徑。 use chroot true|false:表示在傳輸檔案前首先chroot到path引數所指定的目錄下。這樣做的原因是實現額外的安全防護,但缺點是需要以roots許可權,並且不能備份指定外部的符號連線所指向的目錄檔案。預設情況下chroot值為true,如果你的資料當中有軟連結檔案,建議設定成false。

  • Linux主機A:192.168.9.134
[root@localhost ~]# cat /var/log/rsync.log 
2017/12/07 04:33:04 [2931] rsyncd version 3.0.9 starting, listening on port 873
2017/12/07 04:33:04 [2931] bind() failed: Cannot assign requested address (address-family 2)
2017/12/07 04:33:04 [2931] unable to bind any inbound sockets on port 873
2017/12/07 04:33:04 [2931] rsync error: error in socket IO (code 10) at socket.c(555) [Receiver=3.0.9]
2017/12/07 04:34:29 [2936] rsyncd version 3.0.9 starting, listening on port 873
2017/12/07 04:34:29 [2936] bind() failed: Cannot assign requested address (address-family 2)
2017/12/07 04:34:29 [2936] unable to bind any inbound sockets on port 873
2017/12/07 04:34:29 [2936] rsync error: error in socket IO (code 10) at socket.c(555) [Receiver=3.0.9]
2017/12/07 04:37:58 [2959] rsyncd version 3.0.9 starting, listening on port 873
2017/12/07 04:40:24 [2967] rsync: failed to create pid file /var/run/rysncd.pid: File exists (17)
2017/12/07 04:40:24 [2967] rsync error: error in file IO (code 11) at clientserver.c(995) [Receiver=3.0.9]
2017/12/07 04:40:50 [2969] rsync: failed to create pid file /var/run/rysncd.pid: File exists (17)
2017/12/07 04:40:50 [2969] rsync error: error in file IO (code 11) at clientserver.c(995) [Receiver=3.0.9]
2017/12/07 04:55:09 [3073] Badly formed boolean in configuration file: "np".
2017/12/07 04:55:09 [3073] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 04:55:09 [3073] connect from UNKNOWN (192.168.9.233)
2017/12/07 04:57:19 [3073] rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
2017/12/07 04:57:19 [3073] rsync error: error in rsync protocol data stream (code 12) at io.c(605) [Receiver=3.0.9]
2017/12/07 04:57:54 [3074] Badly formed boolean in configuration file: "np".
2017/12/07 04:57:54 [3074] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 04:57:54 [3074] connect from UNKNOWN (192.168.9.233)
2017/12/07 04:57:58 [3074] auth failed on module test from unknown (192.168.9.233): unauthorized user
2017/12/07 05:00:33 [3078] Badly formed boolean in configuration file: "np".
2017/12/07 05:00:33 [3078] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:00:33 [3078] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:00:33 [3078] rsync to test/world.txt from unknown (192.168.9.233)
2017/12/06 21:00:33 [3078] ERROR: module is read only
2017/12/06 21:00:33 [3078] rsync error: syntax or usage error (code 1) at main.c(879) [Receiver=3.0.9]
2017/12/07 05:01:29 [3079] Badly formed boolean in configuration file: "np".
2017/12/07 05:01:29 [3079] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:01:29 [3079] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:01:29 [3079] rsync to test/world.txt from unknown (192.168.9.233)
2017/12/06 21:01:29 [3079] ERROR: module is read only
2017/12/06 21:01:29 [3079] rsync error: syntax or usage error (code 1) at main.c(879) [Receiver=3.0.9]
2017/12/07 05:02:27 [3081] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:02:27 [3081] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:02:27 [3081] rsync to test/world.txt from unknown (192.168.9.233)
2017/12/06 21:02:27 [3081] receiving file list
2017/12/06 21:02:28 [3081] sent 54 bytes  received 88 bytes  total size 0
2017/12/07 05:05:26 [3090] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:05:26 [3090] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:05:26 [3090] rsync on test/world.txt from unknown (192.168.9.233)
2017/12/06 21:05:26 [3090] building file list
2017/12/06 21:05:26 [3090] sent 115 bytes  received 46 bytes  total size 0

  • Linux主機A:192.168.9.134
[root@localhost ~]# ln -s /etc/passwd /tmp/rsync/12.txt
[root@localhost ~]# ls -l /tmp/rsync/
total 0
lrwxrwxrwx 1 root root 11 Dec  7 05:39 12.txt -> /etc/passwd
-rw-r--r-- 1 root root  0 Dec  7 04:42 world.txt

  • Linux主機B:192.168.9.233
[root@centos11233 ~]# rsync -avP 192.168.9.134::test/ /tmp/test/
receiving incremental file list
./
12.txt -> /etc/passwd

sent 32 bytes  received 112 bytes  288.00 bytes/sec
total size is 11  speedup is 0.08


[root@centos11233 ~]# ls -l /tmp/test/
total 0
lrwxrwxrwx. 1 root root 11 Dec  7 05:39 12.txt -> /etc/passwd
-rw-r--r--. 1 root root  0 Dec  7 04:42 world.txt

[root@centos11233 ~]# rm -rf /tmp/test/*
[root@centos11233 ~]# rsync -avLP 192.168.9.134::test/ /tmp/test/
receiving incremental file list
symlink has no referent: "/12.txt" (in test)
./
world.txt
           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=0/2)

sent 48 bytes  received 168 bytes  432.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1518) [generator=3.0.9]
[root@centos11233 ~]# ls -l /tmp/test/
total 0
-rw-r--r--. 1 root root 0 Dec  7 04:42 world.txt

  • Linux主機A:192.168.9.134
[root@localhost ~]# cat /var/log/rsync.log 
2017/12/07 04:33:04 [2931] rsyncd version 3.0.9 starting, listening on port 873
2017/12/07 04:33:04 [2931] bind() failed: Cannot assign requested address (address-family 2)
2017/12/07 04:33:04 [2931] unable to bind any inbound sockets on port 873
2017/12/07 04:33:04 [2931] rsync error: error in socket IO (code 10) at socket.c(555) [Receiver=3.0.9]
2017/12/07 04:34:29 [2936] rsyncd version 3.0.9 starting, listening on port 873
2017/12/07 04:34:29 [2936] bind() failed: Cannot assign requested address (address-family 2)
2017/12/07 04:34:29 [2936] unable to bind any inbound sockets on port 873
2017/12/07 04:34:29 [2936] rsync error: error in socket IO (code 10) at socket.c(555) [Receiver=3.0.9]
2017/12/07 04:37:58 [2959] rsyncd version 3.0.9 starting, listening on port 873
2017/12/07 04:40:24 [2967] rsync: failed to create pid file /var/run/rysncd.pid: File exists (17)
2017/12/07 04:40:24 [2967] rsync error: error in file IO (code 11) at clientserver.c(995) [Receiver=3.0.9]
2017/12/07 04:40:50 [2969] rsync: failed to create pid file /var/run/rysncd.pid: File exists (17)
2017/12/07 04:40:50 [2969] rsync error: error in file IO (code 11) at clientserver.c(995) [Receiver=3.0.9]
2017/12/07 04:55:09 [3073] Badly formed boolean in configuration file: "np".
2017/12/07 04:55:09 [3073] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 04:55:09 [3073] connect from UNKNOWN (192.168.9.233)
2017/12/07 04:57:19 [3073] rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
2017/12/07 04:57:19 [3073] rsync error: error in rsync protocol data stream (code 12) at io.c(605) [Receiver=3.0.9]
2017/12/07 04:57:54 [3074] Badly formed boolean in configuration file: "np".
2017/12/07 04:57:54 [3074] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 04:57:54 [3074] connect from UNKNOWN (192.168.9.233)
2017/12/07 04:57:58 [3074] auth failed on module test from unknown (192.168.9.233): unauthorized user
2017/12/07 05:00:33 [3078] Badly formed boolean in configuration file: "np".
2017/12/07 05:00:33 [3078] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:00:33 [3078] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:00:33 [3078] rsync to test/world.txt from unknown (192.168.9.233)
2017/12/06 21:00:33 [3078] ERROR: module is read only
2017/12/06 21:00:33 [3078] rsync error: syntax or usage error (code 1) at main.c(879) [Receiver=3.0.9]
2017/12/07 05:01:29 [3079] Badly formed boolean in configuration file: "np".
2017/12/07 05:01:29 [3079] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:01:29 [3079] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:01:29 [3079] rsync to test/world.txt from unknown (192.168.9.233)
2017/12/06 21:01:29 [3079] ERROR: module is read only
2017/12/06 21:01:29 [3079] rsync error: syntax or usage error (code 1) at main.c(879) [Receiver=3.0.9]
2017/12/07 05:02:27 [3081] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:02:27 [3081] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:02:27 [3081] rsync to test/world.txt from unknown (192.168.9.233)
2017/12/06 21:02:27 [3081] receiving file list
2017/12/06 21:02:28 [3081] sent 54 bytes  received 88 bytes  total size 0
2017/12/07 05:05:26 [3090] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:05:26 [3090] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:05:26 [3090] rsync on test/world.txt from unknown (192.168.9.233)
2017/12/06 21:05:26 [3090] building file list
2017/12/06 21:05:26 [3090] sent 115 bytes  received 46 bytes  total size 0
2017/12/07 05:35:43 [3128] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:35:43 [3128] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:35:43 [3128] rsync on test/world.txt from unknown (192.168.9.233)
2017/12/06 21:35:43 [3128] building file list
2017/12/06 21:35:43 [3128] sent 115 bytes  received 46 bytes  total size 0
2017/12/07 05:36:19 [3129] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:36:19 [3129] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:36:19 [3129] rsync on test/ from unknown (192.168.9.233)
2017/12/06 21:36:19 [3129] building file list
2017/12/06 21:36:19 [3129] sent 93 bytes  received 30 bytes  total size 0
2017/12/07 05:39:48 [3140] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:39:48 [3140] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:39:48 [3140] rsync on test/ from unknown (192.168.9.233)
2017/12/06 21:39:48 [3140] building file list
2017/12/06 21:39:48 [3140] sent 127 bytes  received 33 bytes  total size 11
2017/12/07 05:50:47 [3143] name lookup failed for 192.168.9.233: Name or service not known
2017/12/07 05:50:47 [3143] connect from UNKNOWN (192.168.9.233)
2017/12/06 21:50:47 [3143] rsync on test/ from unknown (192.168.9.233)
2017/12/06 21:50:47 [3143] building file list
2017/12/06 21:50:47 [3143] symlink has no referent: "/12.txt" (in test)
  • Linux主機A:192.168.9.134

將/etc/rsyncd.conf的use chroot=false

  • Linux主機B:192.168.9.233
[root@centos11233 ~]# rsync -avLP 192.168.9.134::test/ /tmp/test/
receiving incremental file list
12.txt
        1432 100%    1.37MB/s    0:00:00 (xfer#1, to-check=1/3)

sent 45 bytes  received 1565 bytes  3220.00 bytes/sec
total size is 1432  speedup is 0.89
[root@centos11233 ~]# ls -l /tmp/test/
total 4
-rw-r--r--. 1 root root 1432 Dec  5 09:43 12.txt
-rw-r--r--. 1 root root    0 Dec  7 04:42 world