Rsync安裝部署
1.Rsync 簡介
Rsync 是一款開源的、快速的 多功能的 可以實現全量以及增量的本地或者是遠程的數據同步備份的優秀工具,並且可以不進行改變原有的數據屬性信息,實現數據的備份和遷移的特性 ,Rsync 軟件適用於 Linux/unix/windows 等多種操作系統上 。
2.Rsync可以實現的備份方式 ;
本地備份; 遠程備份; 無差異備份;
3.Rsync實現方式介紹 ;
全量備份數據 增量備份數據
4.查看軟件是否安裝
[root@pre2 ~]# rpm -qa | grep rsync rsync-3.0.9-17.el7.x86_64 puppet-rsync-0.4.0-3.447685fgit.el7.noarch
5.查看版本信息
[root@pre2 ~]# rsync --version rsync version 3.0.9 protocol version 30 Copyright (C) 1996-2011 by Andrew Tridgell, Wayne Davison, and others. Web site: http://rsync.samba.org/ Capabilities: 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, append, ACLs, xattrs, iconv, symtimes rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public Licence for details.
6.配置rsync軟件的配置文件
cat >/etc/rsyncd.conf<<EOF 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 = 192.168.3.0/24 hosts deny = 0.0.0.0/32 auth users = rsync_backup secrets file = /etc/rsync.password [backup] path = /root/backup EOF
7.配置文件注釋
#rsync_config ##rsyncd.conf start## uid = rsync # 用戶 遠端的命令使用rsync訪問共享目錄 gid = rsync # 用戶組 use chroot = no # 安全相關 max connections = 200 # 最大連接數 timeout = 300 # 超時時間 pid file = /var/run/rsyncd.pid # 進程對應的進程號文件 lock file = /var/run/rsyncd.lock # 鎖文件 log file = /var/log/rsyncd.log # 日志文件 ignore errors # 忽略錯誤 read only = false # 可寫 list = false # 不能列表 hosts allow = 172.16.1.0/24 # 允許連接的服務器 hosts deny = 0.0.0.0/32 # 后勤組連接的服務器 auth users = rsync_backup # 虛擬用戶 secrets file = /etc/rsync.password # 虛擬用戶對應的用戶和密碼文件 [backup] # 模塊名稱 path = /backup # 服務端提供訪問的目錄
8.創建備份存儲的目錄,和創建管理用戶用戶組
[root@pre2 ~]# mkdir -p backup #創建目錄 [root@rsync ~]# ls backup install.log install.log.syslog optimize-init_sys.sh sysctl.conf [root@pre2 ~]# useradd rsync -s /sbin/nologin -M #創建rsync備份目錄的管理用戶與用戶組 [root@pre ~]# chown -R rsync.rsync backup/ #授權
第二步;創建服務端和客戶端的身份認證文件
[root@pre2 ~]# echo "rsync_backup:rsync123" >/etc/rsync.password [root@pre2 ~]# chmod 600 /etc/rsync.password #配置文件權限只允許 root 用戶查看 [root@pre2 ~]# cat /etc/rsync.password rsync_backup:rsync123
啟動 rsync 服務
[root@pre2 ~]# rsync --daemon [root@pre2 ~]# netstat -lntup |grep rsync tcp6 0 0 :::873 :::* LISTEN 14564/rsync
CentOS 默認以 xinetd 方式運行 rsync 服務。rsync 的 xinetd 配置文件 在 /etc/xinetd.d/rsync。
要配置以 xinetd 運行的 rsync 服務需要執行如下的命令,也可以rsync --daemon 這樣獨立運行 。
# chkconfig rsync on # service xinetd restart
9.客戶端配置
[root@pre1 ~]# rpm -qa|grep rsync rsync-3.0.9-17.el7.x86_64 puppet-rsync-0.4.0-3.447685fgit.el7.noarch [root@pre1 ~]# echo "rsync123" >/etc/rsync.password [root@pre1 ~]# cat /etc/rsync.password rsync123 [root@pre1 ~]# chmod 600 /etc/rsync.password [root@pre1 ~]# ls -ld /etc/rsync.password -rw-r--r-- 1 root root 9 May 13 17:15 /etc/rsync.password