簡介
rsync命令是一個遠程數(shù)據(jù)同步工具,可通過LAN/WAN快速同步多臺主機間的文件。
編譯和測試方式
1.選擇操作環(huán)境
本文選用華為鯤鵬云服務ECS KC1實例做測試
2. 獲取源代碼
執(zhí)行命令,安裝rsync。
yum install rsync* -y
3.測試已完成編譯的軟件
1)修改rsync配置文件“/etc/rsyncd.conf”。內(nèi)容如下:
uid = root
gid = root
use chroot = no
max connections = 4
# pid file = /var/run/rsyncd.pid
exclude = lost+found/
transfer logging = yes
timeout = 900
ignore nonreadable = yes
dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
log file = /var/log
# [ftp]
# path = /home/ftp
# comment = ftp export area
#
[test_rsync]
path=/tmp/rsync
comment=test_rsync
ignore errors
read only=yes
write only=no
list=no
auth users=rsyncuser
secrets file=/etc/rsyncd.passwd
hosts allow=*
2)執(zhí)行以下命令,創(chuàng)建密鑰文件。
echo 'rsyncuser:[password]'>/etc/rsyncd.passwd
[password]代表密碼,請結合自己情況設置相應的密碼即可。
chmod 600/etc/rsyncd.passwd
3)啟動rsync服務。
systemctl start rsyncd.servicesystemctl enable rsyncd.service
4)創(chuàng)建文件。
mkdir /tmp/rsync
cd /tmp/rsync
touch huawei
5)在另一臺安裝有rsync的ECS上,執(zhí)行以下命令并輸入第2步設置的密碼,拉取遠程服務上“test_rsync”下的文件。
rsync -aux rsyncuser@[ECS IP]::test_rsync ./