实现web数据同步的四种方式
=======================================
1、nfs实现web数据共享
2、rsync +inotify实现web数据同步
3、rsync+sersync更快更节约资源实现web数据同步
4、unison+inotify实现web数据双向同步
=======================================
一、nfs实现web数据共享

nfs能实现数据同步是通过NAS(网络附加存储),在服务器上共享一个文件,且服务器需要设置文件系统的权限和配置文件设置的权限,权限两者之间取交集,然后客户端把共享的文件挂载到本地,客户端对文件有读写权限,则实现数据的同步。
nfs+web:服务器端的配置:
1)、安装相关软件,httpd提供web服务,nfs-utils提供nfs服务
[root@jie1 ~]# yum -y install httpd nfs-utils
2)、设置web的相关配置,使得web能够提供web服务
[root@jie1 ~]# vim /etc/httpd/conf/httpd.conf
########################################
ServerName 172.16.22.1:80
#DocumentRoot "/var/www/html" #提供虚拟主机,注释默认存放网页文件的路径
<VirtualHost *:80>
ServerName www.jie.com
DocumentRoot /web/htdocs
</VirtualHost>
#######################################
[root@jie1 ~]# mkdir -pv /web/htdocs #创建存放网页的目录
[root@jie1 ~]# cd /web/htdocs/
[root@jie1 htdocs]# touch index.html test.html test.php
[root@jie1 htdocs]# ls
index.html test.html test.php
[root@jie1 htdocs]# echo "This is Jie1 Web+nfs Server" >index.html
[root@jie1 htdocs]# httpd -t #检查web的配置文件是否有语法错误
Syntax OK
[root@jie1 htdocs]# service httpd start #开启web服务
Starting httpd: [ OK ]
3)、设置nfs的相关配置,共享网页文件
[root@jie1 htdocs]# id apache #安装httpd软件后,系统会创建apache用户,查看apache的id号
uid=48(apache) gid=48(apache) groups=48(apache)
[root@jie1 htdocs]# vim /etc/exports
######################################
/web/htdocs 172.16.22.3(rw,sync,root_squash,anonuid=48,anongid=48)
#nfs是以id号来确定是否能访问共享的文件的,因为两个服务器都安装了httpd软件,都会有apache用户,所以apache用户的id号能访问共享的文件
#/web/htdocs 共享的目录
#172.16.22.3 指定客户端能共享此文件,多个客户端用逗号隔开
#rw,读写权限
#sync,同步方式
#root_squash,压缩root用户的权限








