Rsync 備份服務部署
阿新 • • 發佈:2018-12-08
Rsync 全網備份
=========== 運維之路 - 環境如下
# 服務端 IP:10.0.0.100
# 客戶端 IP:10.0.0.101
[root@Centos ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@Centos ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1 )
[root@Centos ~]# getenforce
Disabled
Rsync 服務端部署
- 檢測軟體是否安裝
[root@Centos ~]# rpm -qa|grep rsync
rsync-3.1.2-4.el7.x86_64
- 編寫服務配置檔案
[root@Centos ~]# vi /etc/rsyncd.conf
#rsync_config
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = false
list = false
hosts allow = 10.0 .0.101
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
[backup]
path = /backup
- 新增程序管理使用者
[root@Centos ~]# useradd rsync -s /sbin/nologin -M
- 建立程式所需目錄
# 建立資料備份目錄
[root@Centos ~]# mkdir -p /backup
# 授權資料備份目錄
[root@Centos ~]# chown -R rsync.rsync /backup/
[root@Centos ~]# ll -d /backup/
drwxr-xr-x 2 rsync rsync 6 Sep 11 18:21 /backup/
- 進行安全相關配置
# 建立檔案認證資訊
[root@Centos ~]# echo "rsync_backup:123456" >/etc/rsync.password
# 修改認證檔案許可權
[root@Centos ~]# chmod 600 /etc/rsync.password
[root@Centos ~]# ll -d /etc/rsync.password
-rw------- 1 root root 20 Sep 11 18:26 /etc/rsync.password
- 執行程式服務程序
# 啟動rsync程式守護程序
[root@Centos ~]# rsync --daemon
# 停止rsync程式守護程序
[root@Centos ~]# killall rsync
- 檢查服務是否啟動
[root@Centos ~]# ps -ef|grep rsync
root 16632 1 0 18:55 ? 00:00:00 rsync --daemon
root 16634 1176 0 18:56 pts/0 00:00:00 grep --color=auto rsync
[root@Centos ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 16632/rsync
Rsync 客戶端部署
- 檢測軟體是否安裝
[root@Centos ~]# rpm -qa|grep rsync
rsync-3.1.2-4.el7.x86_64
- 進行安全相關配置
# 建立檔案認證資訊
[root@Centos ~]# echo "123456" >/etc/rsync.password
# 修改認證檔案許可權
[root@Centos ~]# chmod 600 /etc/rsync.password
[root@Centos ~]# ll -d /etc/rsync.password
-rw------- 1 root root 20 Sep 11 18:26 /etc/rsync.password
- 進行服務應用設定
# 確認備份資料傳輸
[root@Centos ~]# rysnc -avzP /etc/hosts [email protected]::backup
# 確認備份資料傳輸,採用免金鑰進行傳輸
[root@Centos ~]# rysnc -avzP /etc/hosts [email protected]::backup --password-file=/etc/rsync.password