CentOS 7 下對(duì)rsync學(xué)習(xí)并實(shí)踐記錄

前言

PS:本人純屬服務(wù)端小白,白的不能再白!有些地方可能描述的不是很準(zhǔn)確,還請(qǐng)方家多多指教!

學(xué)習(xí)參考地址:http://man.linuxde.net/rsync
故障排除參考地址:https://www.cnblogs.com/wang-xd/p/6551402.html

概念

rsync的作用

1:本地?cái)?shù)據(jù)同步(類似cp復(fù)制命令)
2:遠(yuǎn)程數(shù)據(jù)同步(類似scp)

PS:與cp和scp 不同點(diǎn)是rsync是進(jìn)行數(shù)據(jù)差異化的同步,也就是所謂的增量拷貝,就是如果數(shù)據(jù)已存在,不會(huì)覆蓋已存在的數(shù)據(jù),只有數(shù)據(jù)存在差異時(shí)候才進(jìn)行同步。

安裝

[root@bogon ~]# yum install -y rsync

安裝完成后一個(gè)本地同步測試示例

# 把/etc/passwd 下的內(nèi)容同步到/tmp/xiaozhong.yy 文件中
[root@bogon ~]# rsync -av /etc/passwd /tmp/xiaozhong.yy 
sending incremental file list
passwd

sent 1082 bytes  received 31 bytes  2226.00 bytes/sec
total size is 1008  speedup is 0.91
[root@bogon ~]# 

查看結(jié)果

[root@bogon ~]# cd /tmp/
[root@bogon tmp]# ll
total 8
-rwx------. 1 root root  836 Jan  7 23:59 ks-script-G_oEI7
drwx------. 3 root root   17 Jan  8 00:03 systemd-private-9882fb72393b441bb98a780056f573ce-vmtoolsd.service-VMJHMD
drwx------. 3 root root   17 Mar  5 09:10 systemd-private-ecd950f7e13240f9980360cc3aa9c10f-vmtoolsd.service-RHgTMS
drwx------. 3 root root   17 Jan  8 07:20 systemd-private-f1f1115c74d6454eb93f0eec2da78736-vmtoolsd.service-LFuDRy
-rw-r--r--. 1 root root 1008 Jan  7 23:59 xiaozhong.yy
-rw-------. 1 root root    0 Jan  7 23:49 yum.log
[root@bogon tmp]# 

[root@bogon tmp]# cat xiaozhong.yy  #查看內(nèi)容
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:998:996:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin
[root@bogon tmp]#

同步目錄時(shí)候需要注意細(xì)節(jié)問題:加'/'和不加'/'的區(qū)別

注意事項(xiàng):rm -rf 很危險(xiǎn)?。。。?!
注意事項(xiàng):rm -rf 很危險(xiǎn)!?。。。?br> 注意事項(xiàng):rm -rf 很危險(xiǎn)!?。。。?/p>

[root@bogon rsync]# rsync -a test1 test2
[root@bogon rsync]# ls test2/
test1
[root@bogon rsync]# rm -f test2
rm: cannot remove ‘test2’: Is a directory
[root@bogon rsync]# rm -rf test2
[root@bogon rsync]# rsync -a test1/ test2/
[root@bogon rsync]# ls test2/
1  123.txt  2  3
[root@bogon rsync]# 

解釋:
加'/' 表示只是把目錄下的內(nèi)容進(jìn)行備份,
不加是連目錄名一同進(jìn)行備份處理!

同步的時(shí)候關(guān)于 --delete

說明:--delete 刪除那些DST中SRC沒有的文件。保持同步數(shù)據(jù)一致性

遠(yuǎn)程同步小示例

準(zhǔn)備兩臺(tái)虛擬服務(wù)器:
192.168.74.128
192.168.74.129

示例1:通過ssh的方式備份數(shù)據(jù)(示例來自跟阿銘學(xué)linux)

命令:rsync test1/ 192.168.74.129:/tmp/test2/

[root@bogon rsync]# rsync test1/ 192.168.74.129:/tmp/test2/
The authenticity of host '192.168.74.129 (192.168.74.129)' can't be established.
ECDSA key fingerprint is b1:95:de:4a:27:95:46:fb:ff:b6:aa:3b:7f:6f:cc:89.
Are you sure you want to continue connecting (yes/no)? yes # 第一次需要輸入yes
Warning: Permanently added '192.168.74.129' (ECDSA) to the list of known hosts.
root@192.168.74.129's password:  #輸入192.168.74.129 root密碼
skipping directory .
[root@bogon rsync]# 

查看192.168.74.129/tmp/test2/目錄下的結(jié)果:
[圖片上傳失敗...(image-67ec29-1520261550264)]

Last login: Wed Feb 28 21:24:48 2018 from 192.168.74.1
[root@bogon ~]# ls /tmp/test2/
[root@bogon ~]# cd /tmp/test2/
[root@bogon test2]# ll
total 0
[root@bogon test2]# 

沒有數(shù)據(jù)!有點(diǎn)奇怪!

原來是因?yàn)槊铄e(cuò)誤!~

問題2:執(zhí)行同步的時(shí)候提示了

[root@localhost ceshi]# rsync jiao/ 192.168.219.129:/data/test2/
root@192.168.219.129's password: 
bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: remote command not found (code 127) at io.c(226) [sender=3.1.2]

似乎也需要再129上安裝rsync ,之后才正常的?。?!

命令:rsync -avL test1/ 192.168.74.129:/tmp/test2/

[root@bogon rsync]# rsync -avL test1/ 192.168.74.129:/tmp/test2/
root@192.168.74.129's password: 
sending incremental file list
./
.123.txt
1
123.txt
2
3

sent 275 bytes  received 110 bytes  23.33 bytes/sec
total size is 0  speedup is 0.00

重新再查看129的目錄下的數(shù)據(jù),已經(jīng)同步成功:

Last login: Wed Feb 28 21:24:48 2018 from 192.168.74.1
[root@bogon ~]# ls /tmp/test2/
[root@bogon ~]# cd /tmp/test2/
[root@bogon test2]# ll
total 0
[root@bogon test2]# ll
total 0
-rw-r--r--. 1 root root 0 Mar  5 09:31 1
-rw-r--r--. 1 root root 0 Mar  5 09:31 123.txt
-rw-r--r--. 1 root root 0 Mar  5 09:31 2
-rw-r--r--. 1 root root 0 Mar  5 09:31 3
[root@bogon test2]# 
示例2:通過ssh的方式免輸入密碼方式備份數(shù)據(jù)(示例來自跟阿銘學(xué)linux)

記得之前學(xué)習(xí)Centos7下-使用密鑰認(rèn)證方式登入服務(wù)器之前已經(jīng)生成了對(duì)應(yīng)的密鑰對(duì)。
地址:http://www.itdecent.cn/p/fba14eadf6be

我們把之前128生成的公鑰也放到129下面的authorized_keys
在128的服務(wù)上使用的命令方式是:

ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.74.129
或
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.74.129

執(zhí)行過程:

[root@bogon rsync]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.74.129
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.74.129's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@192.168.74.129'"
and check to make sure that only the key(s) you wanted were added.

[root@bogon rsync]# 

上面執(zhí)行完成后嘗試,在128服務(wù)器使用ssh連接129看看(登入成功查看對(duì)應(yīng)的IP 說明 免密登入成功):

[root@bogon rsync]# ssh 192.168.74.129
Last login: Mon Mar  5 09:30:13 2018 from 192.168.74.1
[root@bogon ~]# hostname
bogon
[root@bogon ~]# ipconfig
-bash: ipconfig: command not found
[root@bogon ~]# ifcongif
-bash: ifcongif: command not found
[root@bogon ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.74.129  netmask 255.255.255.0  broadcast 192.168.74.255
        ether 00:0c:29:6a:c4:38  txqueuelen 1000  (Ethernet)
        RX packets 1396  bytes 112339 (109.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 527  bytes 69682 (68.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1  (Local Loopback)
        RX packets 4  bytes 340 (340.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 340 (340.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@bogon ~]# 

再重新嘗試示例1的命令看看是否還需要輸入密碼:

[root@bogon ~]# rsync -avL test1/ 192.168.74.129:/tmp/test2/
sending incremental file list
rsync: change_dir "/root//test1" failed: No such file or directory (2)

sent 12 bytes  received 12 bytes  2.29 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(1052) [sender=3.0.9]

rsync -avL test1/ 192.168.74.129:/tmp/test2/

出現(xiàn)了錯(cuò)誤是因?yàn)椋寒?dāng)前不是在對(duì)應(yīng)的test1目錄下

[root@bogon ~]# cd rsync/
[root@bogon rsync]# ll
total 0
drwxr-xr-x. 2 root root 64 Mar  5 09:32 test1
drwxr-xr-x. 2 root root 64 Mar  5 09:32 test2
[root@bogon rsync]# rsync -avL test1/ 192.168.74.129:/tmp/test2/
sending incremental file list

sent 77 bytes  received 12 bytes  7.74 bytes/sec
total size is 0  spee
示例3:通過后臺(tái)服務(wù)的方式

(來自跟阿銘學(xué)linux)
說明:這種方式是在遠(yuǎn)程主機(jī)上搭建一個(gè)rsync的服務(wù)器,在服務(wù)器上配置好rsync的配置文件信息,然后本機(jī)作為rsync的一個(gè)客戶端連接遠(yuǎn)程的rsync的服務(wù)器。

配置128-rsync服務(wù)器步驟:
(1):在128主機(jī)上建立并配置rsync的配置文件【/etc/rsyncd.conf】。

[root@bogon rsync]# nano /etc/rsyncd.conf

[root@bogon rsync]# nano /etc/rsyncd.conf 

# /etc/rsyncd: configuration file for rsync daemon mode

# See rsyncd.conf man page for more options.

# configuration example:

# uid = nobody
# gid = nobody
# use chroot = yes
# max connections = 4
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
  GNU nano 2.3.1                                        File: /etc/rsyncd.conf                                                                             Modified  

# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

# [ftp]
#        path = /home/ftp
#        comment = ftp export area
port = 873
log file = /var/log/rsync.log
pid file = /var/run/rsyncd.pid  
address = 192.168.74.128

[test]
path = /root/rsync
use chroot = yes
max connections = 4
read only = no
list = true
uid = root
gid = root
auth users = test
secrets file = /ect/rsyncd.password
hosts allow = 192.168.74.129

文件內(nèi)容:

#全局配置
port = 873 
log file = /var/log/rsync.log
pid file = /var/run/rsyncd.pid  
address = 192.168.74.128
#模塊配置(可以配置多模塊,模塊名可以自定義)
[test]
path = /root/rsync
use chroot = yes
max connections = 4
read only = no
list = true
uid = root
gid = root
auth users = test
secrets file = /ect/rsyncd.password
hosts allow = 192.168.74.129

PS:如果想查閱更多的關(guān)于配置文件的參數(shù)信息可以使用:

man rsyncd.conf

參數(shù)信息說明:
port --- 指定在哪個(gè)端口啟動(dòng)rsyncd服務(wù),默認(rèn)873端口

log file --- 指定日志文件

pid file ---指定pid文件,該文件主要的涉及到服務(wù)的啟動(dòng)和停止等進(jìn)程的管理操作

address --- 指定啟動(dòng)rsyncd服務(wù)器的IP,如你的機(jī)器有多個(gè)IP,就可以指定其中一個(gè)為啟動(dòng)IP,如果不指定該參數(shù),則默認(rèn)是在全部的IP上啟動(dòng)。

[] ---:指定模塊的名稱

path --- 指定數(shù)據(jù)存放的路徑

use chroot true|false : 表示在傳輸文件前,首先chroot 到path參數(shù)所指定的目錄下。目的是:實(shí)現(xiàn)額外的完全防護(hù),但缺點(diǎn)是需要root權(quán)限,并且不能備份指向外部的符號(hào)連接所指向的目錄文件(軟連接文件)。默認(rèn)情況是true,但是如果需要同步的目錄下包含有軟連接文件的話,那么就設(shè)置為false!

max connections --- 指定最大的連接數(shù),默認(rèn)是0 ,表示沒限制。

read only true|false --- 如果是true, 則不能上傳到該模塊指定的路徑下。

list --- 表示當(dāng)用戶查詢?cè)摲?wù)器上的可用模塊是,該模塊是否要列出,設(shè)置為true,則顯示出來!反之不顯示!

uid/gid --- 指定傳輸文件是以那個(gè)用戶/組的身份進(jìn)行傳輸。

auth users --- 指定傳輸時(shí)要使用的用戶名。

secrets file --- 指定密碼文件,該參數(shù)聯(lián)通上面的uth users 參數(shù)如果不指定,則不使用密碼驗(yàn)證。另外注意:該密碼文件的權(quán)限一定要設(shè)置為 600 。

hosts allow --- 表示可以連接該模塊的主機(jī),可以是ip或網(wǎng)段, 如果是多個(gè),中間使用空格分開。

PS:配置文件修改完成后,不需要重啟rsyncd服務(wù)!修改完后會(huì)直接的生效。

(2):編輯secrets file并保持且賦予600權(quán)限。

[root@bogon rsync]# nano /etc/rsyncd.password

  GNU nano 2.3.1                                       File: /etc/rsyncd.password                                                                                    

test:test123


[root@bogon rsync]# chmod 600 /etc/rsyncd.password 
[root@bogon rsync]# 

(3):開始后臺(tái)啟動(dòng)rsyncd服務(wù)

[root@bogon rsync]# rsync --daemon --config=/etc/rsyncd.conf 

(4) 查看啟動(dòng)日志,并查看啟動(dòng)端口:

[root@bogon rsync]# cat /var/log/rsync.log 
2018/03/05 10:49:56 [2570] rsyncd version 3.0.9 starting, listening on port 873
[root@bogon rsync]# 

PS: 如果需要開啟啟動(dòng)rsyncd服務(wù),需把

rsync --daemon --config=/etc/rsyncd.conf 

寫入到:

/etc/rc.d/rc.local

(5)先關(guān)閉兩臺(tái)服務(wù)器的防火墻,后期線上在進(jìn)行設(shè)置相關(guān)端口規(guī)則
分別執(zhí)行:

[root@bogon rsync]# systemctl stop firewalld
[root@bogon rsync]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@bogon rsync]#

(6)在客戶機(jī)129上執(zhí)行相關(guān)的同步命令

[root@bogon test2]# rsync -avL test@192.168.74.128::test/test1/ /tmp/test5/

錯(cuò)誤現(xiàn)象:

[root@bogon test2]# rsync -avL test@192.168.74.128::test/test1/ /tmp/test5/
Password: 
@ERROR: auth failed on module test
rsync error: error starting client-server protocol (code 5) at main.c(1516) [Receiver=3.0.9]
[root@bogon test2]# 

輸入的密碼是:test123 結(jié)果認(rèn)證錯(cuò)!

在128上修改模塊的密碼為123456 并且重啟一下服務(wù)器:

[root@bogon rsync]# rsync --daemon --config=/etc/rsyncd.conf 
[root@bogon rsync]# failed to create pid file /var/run/rsyncd.pid: File exists

[root@bogon rsync]# 
[root@bogon rsync]# ps -ef|grep rsyncd
root       2694   2443  0 11:06 pts/1    00:00:00 grep --color=auto rsyncd
[root@bogon rsync]# rm -rf /var/run/rsyncd.pid 
[root@bogon rsync]# rsync --daemon --config=/etc/rsyncd.conf 
[root@bogon rsync]# 

發(fā)現(xiàn)問題所在是因?yàn)榕渲梦募畔⒚艽a路徑有誤。

/ect/rsyncd.password
改為
/etc/rsyncd.password

最終修正一下相關(guān)配置文件信息為:

port = 873
log file = /var/log/rsync.log
pid file = /var/run/rsyncd.pid
address = 192.168.74.128

[test]
path = /root/rsync
use chroot = false
max connections = 4
read only = no
list = true
uid = root
gid = root
auth users = test
secrets file = /etc/rsyncd.password
hosts allow = 192.168.74.129

PS:如果use chroot = true,則同步的時(shí)候會(huì)出現(xiàn)軟件文件權(quán)限的問題,因?yàn)樵?28服務(wù)器下有一個(gè)軟連接的文件。
需要修改為 :use chroot = false

(7)在129服務(wù)器上執(zhí)行同步命令的時(shí)候,還是需要輸入密碼的方式,為了實(shí)現(xiàn)免輸入密碼的方式,可以再129的地方建立一個(gè)自動(dòng)輸入密碼的文件

主要的方式是:
(7.1)在客戶端(129)指定密碼文件,如把密碼文件放置到 /etc/pass下

[root@localhost test5]# nano /etc/pass

  GNU nano 2.3.1                                          File: /etc/pass                                                                                            

xiaozhong

PS:注意此密碼和128中配置的用戶名對(duì)應(yīng)的密碼是一致的喲!

[root@localhost test5]# cat /etc/pass
xiaozhong
[root@localhost test5]# 

(7.2)修改文件權(quán)限

[root@localhost test5]# chmod 600 /etc/pass
[root@localhost test5]# 

(7.3)修改同步的命令,指定密碼

rsync -avL test@192.168.74.128::test/test1/ /tmp/test8/ --password-file=/etc/pass

[root@localhost test5]# rsync -avL test@192.168.74.128::test/test1/ /tmp/test8/ --password-file=/etc/pass
receiving incremental file list
created directory /tmp/test8
./
.123.txt
1
123.txt
2
3

sent 152 bytes  received 343 bytes  990.00 bytes/sec
total size is 0  speedup is 0.00
[root@localhost test5]# 
》在129上把本機(jī)一些目錄同步到128服務(wù)端的命令測試:
[root@localhost test5]# rsync -avzP  --delete --password-file='/etc/pass' --exclude-from=/etc/rsync_exclude.list  /etc/pass test@192.168.74.128::test  
sending incremental file list
pass
          10 100%    0.00kB/s    0:00:00 (xfer#1, to-check=0/1)

sent 111 bytes  received 27 bytes  276.00 bytes/sec
total size is 10  speedup is 0.07
[root@localhost test5]# 

查看一下128同步的結(jié)果

[root@localhost rsync]# ll
total 4
-rw-------. 1 root root 10 Mar  5 21:54 pass
drwxr-xr-x. 2 root root 64 Mar  5 09:32 test1
drwxr-xr-x. 2 root root 64 Mar  5 09:32 test2
[root@localhost rsync]# cat pass 
xiaozhong
[root@localhost rsync]# 

[root@localhost www]# rsync -avzP --delete --password-file='/etc/pass' --exclude-from=/etc/rsync_exclude.list /data/ test@192.168.74.128::test

[root@localhost rsync]# ll
total 0
-rwxr-xr-x.  1 root root   0 Feb 28 21:26 343.txt
drwxr-xr-x. 10 root root 175 Jan 15 21:36 app
drwxr-xr-x.  6 root root 187 Jan 11 04:26 bak
drwxr-xr-x.  2 root root  24 Jan 10 01:55 logs
drwxr-xr-x.  2 root root   6 Jan 10 01:45 redis
drwxr-xr-x.  3 root root  41 Jan 10 02:05 www
[root@localhost rsync]# 

[root@localhost www]# rsync -avzP --delete --password-file='/etc/pass' --exclude-from=/etc/rsync_exclude.list /data/www/ test@192.168.74.128::test

[root@localhost rsync]# ll
total 4
drwxr-xr-x. 2 root root   6 Jan 10 21:24 __pycache__
-rw-r--r--. 1 root root 874 Jan 10 21:23 tasks.py
[root@localhost rsync]# 

遇到的問題處理:

1:啟動(dòng)rsyncd服務(wù)的時(shí)候失?。?br> 查看日志信息顯示:


2018/03/05 21:05:48 [2192] rsyncd version 3.0.9 starting, listening on port 873
2018/03/05 21:05:48 [2192] bind() failed: Cannot assign requested address (address-family 2)
2018/03/05 21:05:48 [2192] unable to bind any inbound sockets on port 873
2018/03/05 21:05:48 [2192] rsync error: error in socket IO (code 10) at socket.c(555) [Receiver=3.0.9]

可能原因:因?yàn)槎丝跊]開,或是因?yàn)榉阑饓]關(guān)閉@@@,可能是虛擬機(jī)重啟后防火墻設(shè)置失效了!再重新進(jìn)行關(guān)閉進(jìn)行測試!

[root@bogon rsync]# systemctl stop firewalld
[root@bogon rsync]# systemctl disable firewalld

可是關(guān)閉了還是不行??!后來發(fā)現(xiàn)是登入錯(cuò)了服務(wù)器?。。?!不是在128里啟動(dòng)的服務(wù)器!

2:取消使用用戶認(rèn)證后,


image.png

在129上進(jìn)行同步出現(xiàn)了
錯(cuò)誤信息:


image.png

原因:
原因是有文件沒有寫的權(quán)限,導(dǎo)致備份數(shù)據(jù)庫權(quán)限不夠,兩種解決辦法:

1)、將服務(wù)端rsyncd.conf配置文件的uid和gid分別修改成root,重載下,/etc/rc.d/init.d/xinetd reload,再次執(zhí)行同步,同步成功

2)、將需要同步的文件夾及下屬文件賦予777權(quán)限(chmod -R 777 xxx),再次執(zhí)行同步,同步成功

注意:如果使用第一種辦法,那么在執(zhí)行完同步后,為了安全,記得將uid和gid修改回來,或修改成nobody

3),問題的原始因?yàn)榕渲梦募锏?br> use chroot = true 默認(rèn)是開啟的true

use chroot = false 即可

3:恢復(fù)使用用戶認(rèn)證繼續(xù)測試..@ERROR: auth failed on module test

錯(cuò)誤原因:
128配置文件的密碼目錄寫錯(cuò)

secrets file = /ect/rsyncd.password
應(yīng)該是:
secrets file = /etc/rsyncd.password

#全局配置
port = 873 
log file = /var/log/rsync.log
pid file = /var/run/rsyncd.pid  
address = 192.168.74.128
#模塊配置(可以配置多模塊,模塊名可以自定義)
[test]
path = /root/rsync
use chroot = yes
max connections = 4
read only = no
list = true
uid = root
gid = root
auth users = test
secrets file = /ect/rsyncd.password
hosts allow = 192.168.74.129

此類異常問題解決總結(jié):

  1. 密碼真的輸入錯(cuò)誤,用戶名真的錯(cuò)誤

  2. secrets file = /etc/rsync.password指定的密碼文件和實(shí)際密碼文件名稱不一致

  3. /etc/rsync.password文件權(quán)限不是600

  4. rsync_backup:123456密碼配置文件后面注意不要有空格

  5. rsync客戶端密碼文件中只輸入密碼信息即可,不要輸入虛擬認(rèn)證用戶名稱

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容