综合架构--备份
环境
1、两台PC,
PC1 主机名backup eth0:10.0.0.41;eht1:172.16.1.41
PC2 主机名nfs01 eth0:10.0.0.41;eht1:172.16.1.41
2、关闭防火墙,
setenforce 0
3,配置host文件
172.16.1.5 lb01 172.16.1.6 lb02 172.16.1.7 web01 172.16.1.8 web02 172.16.1.9 web03 172.16.1.51 db01 db01.etiantian.org 172.16.1.31 nfs01 172.16.1.41 backup 172.16.1.61 m01
4,更新yum源,安装yum常用包
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install -y wget
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all --- 清除yum源缓存信息
yum install lrzsz nmap tree dos2unix nc telnet net-tools bash-completion bash-completion-extra
配置backup服务端
1,安装部署软件rsync
检查是否安装rsync:rpm -qa rsync
安装rsync:yum install -y rsync
2,编写配置文件(守护进程模式)
vim /etc/rsyncd.conf
#rsync_config #created by HQ at 2017 ##rsyncd.conf start## -- 注释信息 uid = rsync -- 管理备份目录(属主信息是rsync) gid = rsync -- 管理备份目录(属组信息是rsync) port = 873 -- 守护进程服务端口信息 fake super = yes -- 它不需要daemon以root运行,就可以存储文件的完整属性 use chroot = no -- 安全的配置 max connections = 200 -- 同时可以有多少客户端连接rsync服务器 timeout = 300 -- 超时时间,显示空闲连接存活时间 pid file = /var/run/rsyncd.pid --- 保存进程pid号码信息 lock file = /var/run/rsync.lock --- 真正的限制同时的连接数 log file = /var/log/rsyncd.log --- rsync程序日志文件 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 --- 认证用户密码文件(信息:rsync_backup:oldboy123) [backup] --- 模块信息 comment = "backup dir by oldboy" --- 模块注释说明信息 path = /backup --- 定义一个备份目录
3,创建/etc/rsyncd.conf中的虚拟用户名;创建备份目录
useradd -s /sbin/nologin -M rsync mkdir /backup
4,创建认证用户密码文件,并赋予600权限
echo "rsync_backup:oldboy123" >/etc/rsync.password chmod 600 /etc/rsync.password
5,启动rsync服务
systemctl start rsyncd systemctl enable rsyncd
6,给bacukp文件添加虚拟用户组
chown rsync.rsync /backup/
客户端nfs01测试
[root@nfs01 ~]# rsync -avz /etc/hosts rsync_backup@172.16.1.41::backup
Password:
sending incremental file list
hosts
sent 220 bytes received 43 bytes 58.44 bytes/sec
total size is 379 speedup is 1.44
服务端backup验证
[root@backup backup]# cd /backup/
[root@backup backup]# ls
hosts
[root@backup backup]#
[root@backup backup]#
[root@backup backup]# cat hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.5 lb01
172.16.1.6 lb02
172.16.1.7 web01
172.16.1.8 web02
172.16.1.9 web03
172.16.1.51 db01
172.16.1.31 nfs01
172.16.1.41 backup
172.16.1.61 m01
[root@backup backup]#