实时同步案例(搭建上传作业页面)

该博客详细介绍了如何使用Rsync+NFS解决单点故障问题,通过在web01服务器搭建上传作业平台,nfs服务器搭建NFS服务端,以及backup服务器搭建rsync服务进行实时备份。同时,讲解了在NFS服务端故障时如何切换到backup服务器,并介绍了实时同步工具sersync的安装和配置过程。
摘要由CSDN通过智能技术生成

一、Rsync+NFS解决单点故障

1.准备环境

主机 角色 IP
backup rsync服务端,NFS服务端 172.16.1.41
nfs rsync客户端,NFS服务端 172.16.1.31
web01 rsync客户端,NFS客户端 172.16.1.7,10.0.0.7

在这里插入图片描述

1.服务器创建统一用户

# 客户端
[root@web01 ~]# groupadd www -g 666
[root@web01 ~]# useradd www -u 666 -g 666

#nfs服务端
[root@nfs ~]# groupadd www -g 666
[root@nfs ~]# useradd www -u 666 -g 666

#backup服务端
[root@backup ~]# useradd -M -s /sbin/nologin www

2.web01服务器搭建上传作业平台

1) 安装

[root@web01 ~]# yum install -y  rsync

#安装httpd和php
[root@web01 ~]# yum install -y httpd php
#启动服务
[root@web01 ~]# systemctl start httpd

#安装nfs和rpcbind
[root@web01 ~]# yum install -y nfs-utils rpcbind
#启动服务
[root@web01 ~]# systemctl start rpcbind nfs-server

2) httpd服务配置

#修改httpd.conf文件中的User和Group
[root@web01 ~]# vim /etc/httpd/conf/httpd.conf 
User www
Group www

#重启httpd服务
[root@web01 ~]# systemctl restart httpd
#检测服务启动
[root@lb01 ~]# ps -ef | grep httpd

3) 上传代码

#httpd站点目录
[root@web01 ~]# cd /var/www/html/
[root@web01 /var/www/html]# rz
[root@web01 /var/www/html]# unzip kaoshi.zip

#修改权限
[root@web01 /var/www/html]# chown -R www.www /var/www/html/

2.nfs服务器搭建NFS服务端

1) 安装

[root@nfs ~]# yum install -y  rsync

#安装nfs和rpcbind
[root@nfs ~]# yum install -y nfs-utils rpcbind
#启动服务
[root@nfs ~]# systemctl start rpcbind nfs-server

#检测服务启动
[root@db01 ~]# ps -ef | grep nfs

#rpcbind端口111
[root@db01 ~]# netstat -lntp
tcp6       0      0 :::111                  :::*                    LISTEN      7712/rpcbind

2) NFS服务配置

#NFS服务配置文件写入
[root@nfs ~]# vim /etc/exports
/data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

#重启服务
[root@db01 ~]# systemctl restart nfs-server

#检测服务
[root@db01 ~]# cat /var/lib/nfs/etab
/data	172.16.1.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=666,anongid=666,sec=sys,rw,secure,root_squash,all_squash)

3) 创建目录并授权

[root@nfs ~]# mkdir /data
[root@nfs ~]# chown -R www.www /data

4) web01服务器挂载nfs服务端目录


[root@web01 ~]# showmount -e 172.16.1.51
Export list for 172.16.1.51:
/data 172.16.1.0/24
[root@web01 ~]# mount -t nfs 172.16.1.51:/data /var/www/html/upload


3.backup服务器搭建rsync服务

1) 安装


[root@backup ~]# yum install -y rsync

2) rsyncd服务配置

[root@backup ~]# vim /etc/rsyncd.conf
uid =
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值