環境搭建
- CentOS Linux release 7.5.1804 (Core)
關閉防火墻和selinux
192.168.153.179 master
192.168.153.178 backup
開始部署
- master backup安裝rsync服務
yum -y install rsync
- master操作
vim /etc/rsyncd.conf
uid = root
gid = root
use chroot = yes
address = 192.168.153.179
port 873
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
hosts allow = 192.168.153.0/24
[git]
path = /opt/git
comment = Document Root of www.51xit.top
read only =no
dont comperss = *.gz *.bz2 *.tgz *.zip *.rar *.z
auth users =root
secrets file = /etc/secrets.pass

創建源目錄
mkdir /opt/git
任意添加檔案,之后測驗時用
[root@localhost git]# pwd
/opt/git
[root@localhost git]# touch a
[root@localhost git]# ls
a
授權的賬號和密碼
vim /etc/secrets.pass

授權
chmod 600 /etc/secrets.pass
啟動rsync服務并查看
rsync --daemon
ss -nltp|grep 873
LISTEN 0 5 192.168.153.179:873 *:*
- backup操作
創建目錄,此目錄以存放服務器備份過來的資料目錄
mkdir /opt/backgit
免密登錄
vim /etc/secrets.backpass

授權
chmod 600 /etc/secrets.backpass
測驗備份服務端資料
rsync -az --password-file=/etc/secrets.backpass root@192.168.153.179::git /opt/backgit
成功備份,加入crontab 定時任務
ls /opt/backgit/
a
定時任務每分鐘 1 次,抓緊時間進行操作
[root@backup ~]# crontab -l
* * * * * rsync -az --password-file=/etc/secrets.backpass root@192.168.153.179::git /opt/backgit
- server端
洗掉檔案 a 創建檔案 xinzeng
pwd
/opt/git
rm -rf a
touch xinzeng
[root@server git]# ls
xinzeng
- backup端
1分鐘后…
可以使用 ll 命令查看時間,這個自行選擇~ _ ~
大功告成!!!
[root@backup backgit]# ls
a
[root@backup backgit]# ls
a xinzeng
[root@backup backgit]# ll
總用量 0
-rw-r--r--. 1 root root 0 10月 29 13:47 a
-rw-r--r--. 1 root root 0 10月 29 14:13 xinzeng
完畢~ _ ~!!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/197072.html
標籤:其他
上一篇:限量!阿里技術官純手打架構師進階寶典全網首發,理論儲備+專案實戰齊飛
下一篇:快速推匯出等比數列的求和公式
