1.1 backup主机配置
1.1.1 安装rsync服务
1.安装rsync
[root@backup ~]# yum install rsync -y
2.配置rsync
[root@backup ~]# vi /etc/rsyncd.conf
uid = www gid = www port = 873 fake super = yes use chroot = no max connections = 200 timeout = 600 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 log file = /var/log/rsyncd.log ##################################### [backup] comment = welcome to backup! path = /backup [nfs] path = /data/www
#创建rsync运行程序用户(设置为www用户是为了做NFS系统做准备)
[root@backup ~]# groupadd -g 666 www
[root@backup ~]# useradd -u 666 -g www www
[root@backup ~]# id www
uid=666(www) gid=666(www) groups=666(www)
#建立虚拟账户对应的用户名与密码(用于客户端连接的账户和密码)
[root@backup ~]# echo 'rsync_backup:123456' >/etc/rsync.password
[root@backup ~]# cat /etc/rsync.password
rsync_backup:123456
[root@backup-41 ~]# chmod 600 /etc/rsync.password
#创建仓库目录,授权属主和属组
[root@backup ~]# mkdir /backup
[root@backup ~]# chown -R www.www /backup
[root@backup ~]# mkdir /data/www -p
[root@backup ~]# chown -R www.www /data/www/
3.启动服务及加入自启动
[root@backup ~]# systemctl start rsyncd
[root@backup ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
#检查开机自启动
[root@backup ~]# systemctl is-enabled rsyncd
enabled
#检查服务状态
[root@backup ~]# systemctl status rsyncd
● rsyncd.service - fast remote file copy program daemon
Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2018-07-28 01:03:28 CST; 16s ago
Main PID: 1084 (rsync)
CGroup: /system.slice/rsyncd.service
└─1084 /usr/bin/rsync --daemon --no-detach
Jul 28 01:03:28 backup systemd[1]: Started fast remote file copy program daemon.
Jul 28 01:03:28 backup systemd[1]: Starting fast remote file copy program daemon...
Jul 28 01:03:28 backup rsyncd[1084]: params.c:Parameter() - Ignoring badly formed line in config file: ignore errors
Jul 28 01:03:28 backup rsyncd[1084]: rsyncd version 3.1.2 starting, listening on port 873
#检查端口
[root@backup ~]# netstat -lntp|grep 'rsync'
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 1084/rsync
tcp6 0 0 :::873 :::* LISTEN 1084/rsync