如何保持Linux伺服器間的檔案同步
具體操作步驟:
配置/etc/rsyncd.conf檔案:
uid = nobody
gid = nobody
use chroot = no
max connections = 4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log
[test01]
path = /front/test01
ignore errors
read only = true
list = false
hosts allow = 192.168.1.252
hosts deny = 192.168.1.0/24
auth users = test01
secrets file = /etc/rsync.secret
[back]
path = /front/back
ignore errors
read only = true
list = false
hosts allow = 192.168.1.252
hosts deny = 192.168.1.0/24
配置test01目錄需要密碼,back使用者不需要
建立密碼檔案
[root@tonykorn front]# cat /etc/rsync.secret
test01:test01
[root@tonykorn front]#
修改啟動rsync檔案
[root@tonykorn etc]# cat /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it
# allows crc checksumming etc.
service rsync
{
# disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
[root@tonykorn etc]#
啟動服務端
[root@tonykorn front]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@tonykorn front]#
也有的地方說需要執行:rsync --daemon,經過試驗不需要
沒有執行rsync --daemon的時候程式狀態是:
[root@tonykorn front]# ps -ef | grep rsync
root 24033 15043 0 17:40 pts/0 00:00:00 grep rsync
執行後為:
[root@tonykorn front]# rsync --daemon
[root@tonykorn front]# ps -ef | grep rsync
root 24035 1 0 17:40 ? 00:00:00 rsync --daemon
root 24042 15043 0 17:40 pts/0 00:00:00 grep rsync
[root@tonykorn front]#
客戶端操作
客戶端同步出錯:
[test01@tonykorn02 ~]$ rsync -vzrtopg --progress test01@192.168.1.250::test01 /front/test01
Password:
@ERROR: auth failed on module test01
rsync error: error starting client-server protocol (code 5) at main.c(1296) [receiver=2.6.8]
[test01@tonykorn02 ~]$
原因:
secret file的檔案屬性有問題,該檔案屬性要是600的
[root@tonykorn etc]# ls -al rsync.secret
-rw-r--r-- 1 root root 14 Apr 2 17:04 rsync.secret
[root@tonykorn etc]# chmod 600 rsync.secret
[root@tonykorn etc]#
此時執行,test01需要密碼,輸入密碼後可以,back不需要密碼,直接可以同步
[root@tonykorn02 front]# rsync -vzrtopg --progress test01@192.168.1.250::test01 /front/test01
Password:
receiving file list ...
421 files to consider
sent 98 bytes received 8031 bytes 2322.57 bytes/sec
total size is 134589856 speedup is 16556.75
[root@tonykorn02 front]# rsync -vzrtopg --progress back@192.168.1.250::back /front/back
receiving file list ...
50 files to consider
sent 62 bytes received 1007 bytes 2138.00 bytes/sec
total size is 12629876 speedup is 11814.66
[root@tonykorn02 front]#
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/312079/viewspace-245849/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 「譯」如何保持 GitHub Fork 專案同步Github
- Linux-檔案寫入和檔案同步Linux
- Linux使用ntp時間伺服器同步時間Linux伺服器
- 如何傳輸檔案到linux伺服器?Linux伺服器
- Linux 檔案同步工具之 rsyncLinux
- 前端如何保持與伺服器時間同步(如何解決客戶端與服務端時間不對稱的問題)?前端伺服器客戶端服務端
- 如何在Linux系統安裝檔案同步工具:FreeFileSync?Linux
- 伺服器時間同步引發的"慘案"伺服器
- 如何使用 logrotate 命令保持日誌檔案更新logrotate
- Linux的時鐘及常用的時間同步伺服器地址Linux伺服器
- 企業總部與分支之間如何實現檔案同步?
- 在Linux中,rsync 同步資料時,如何過濾出所有.txt的檔案不同步?Linux
- mac下用scp命令實現本地檔案與伺服器Linux檔案之間的相互傳輸Mac伺服器Linux
- linux 利用rsync實現檔案增量同步Linux
- Linux伺服器上傳檔案傳送檔案Linux伺服器
- Linux刪除指定時間之前的檔案Linux
- Linux Shell檔案之間的包含關係Linux
- Linux 伺服器下如何建立檔案防篡改規則Linux伺服器
- Linux伺服器下如何建立檔案防篡改規則Linux伺服器
- Linux伺服器---apache配置檔案Linux伺服器Apache
- Linux有哪些好用的雙向檔案同步軟體?Linux
- Linux 伺服器如何實現資料同步?Linux伺服器
- linux伺服器目錄檔案的命令操作Linux伺服器
- Linux基礎命令---ntpstat顯示時間伺服器同步Linux伺服器
- Linux叢集環境下NTP伺服器時間同步Linux伺服器
- 使用 Syncthing 在多個裝置間同步檔案
- Linux ntpdate同步時間Linux
- 伺服器上傳檔案至linux伺服器伺服器Linux
- 如何在Ubuntu上使用FreeFileSync同步檔案Ubuntu
- 如何識別 Linux 上的檔案分身Linux
- Linux Centos7 同步伺服器時鐘為北京時間LinuxCentOS伺服器
- 雲伺服器Linux系統設定時間同步設定伺服器Linux
- Windows 與 Linux (CentOS7) 之間的檔案共享WindowsLinuxCentOS
- 記一次Linux伺服器磁碟空間佔用,大檔案查詢Linux伺服器
- Linux 網路時間同步Linux
- LINUX 時間操作及其同步Linux
- Linux檔案刪除空間未釋放Linux
- linux中如何解決檔案已刪除但空間不釋放的案例Linux
- windows伺服器間自動傳輸檔案Windows伺服器