博客
关于我
rsync远程同步
阅读量:511 次
发布时间:2019-03-07

本文共 1081 字,大约阅读时间需要 3 分钟。

第十二章rsync远程同步

实验拓扑:
在这里插入图片描述

实验环境描述:

某公司在深圳,北京各放置了一台网站服务器,分别应对南北大区内不断增长的客户访问需求,两台服务器的网站文档必须保持一致,如图,同步链路已通过VPN专用线路实现
需求描述:
 服务器A(北京)作为rsync发起端,目录/var/www/html作为原始位置
 服务器B(深圳)作为远程rsync服务器,目录/var/www/html作为目标位置
 结合inotify机制实现触发式的上行同步,保持两个站点的网页文档一致
推荐步骤:
 配置rsync服务器(深圳,服务器B)
 通过inotify机制实现实时同步(北京,服务器A)
实验步骤:
一. 配置rsync服务器(深圳,服务器B)
1)安装rsync
在这里插入图片描述

2) 配置rsync文件

[root@centos02 ~]# vim /etc/rsyncd.conf
在这里插入图片描述

3)编写数据文件

[root@centos02 ~]# vim /etc/rsyncd_users.db
在这里插入图片描述

[root@centos02 ~]# chmod 600 /etc/rsyncd_users.db

[root@centos02 ~]# mkdir -p /var/www/html
4)开启服务
[root@centos02 ~]# rsync --daemon
在这里插入图片描述

[root@centos02 ~]# chmod 777 /var/www/html/

二. 通过inotify机制实现实时同步(北京,服务器A)
1)调整inotify内核参数
在这里插入图片描述

2)安装inotify-tools

[root@centos01 ~]# tar zxvf /mnt/inotify-tools-3.14.tar.gz -C /opt
[root@centos01 ~]# cd /opt/inotify-tools-3.14/
[root@centos01 inotify-tools-3.14]# ./configure && make && make install
3)编写同步脚本
[root@centos01 ~]# vim /opt/inotify_rsync.sh
在这里插入图片描述

4)免交互式身份验证

[root@centos01 ~]# ssh-keygen -t RSA
[root@centos01 ~]# ssh-copy-id -i root@192.168.100.20
5)后台运行脚本
[root@centos01 ~]# sh /opt/inotify_rsync.sh &
验证
在这里插入图片描述
在这里插入图片描述

转载地址:http://rfbnz.baihongyu.com/

你可能感兴趣的文章
Nginx 学习总结(16)—— 动静分离、压缩、缓存、黑白名单、性能等内容温习
查看>>
Nginx 学习总结(17)—— 8 个免费开源 Nginx 管理系统,轻松管理 Nginx 站点配置
查看>>
Nginx 学习(一):Nginx 下载和启动
查看>>
nginx 常用指令配置总结
查看>>
Nginx 常用配置清单
查看>>
nginx 常用配置记录
查看>>
nginx 开启ssl模块 [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx
查看>>
Nginx 我们必须知道的那些事
查看>>
Nginx 源码完全注释(11)ngx_spinlock
查看>>
Nginx 的 proxy_pass 使用简介
查看>>
Nginx 的 SSL 模块安装
查看>>
Nginx 的优化思路,并解析网站防盗链
查看>>
Nginx 的配置文件中的 keepalive 介绍
查看>>
Nginx 相关介绍(Nginx是什么?能干嘛?)
查看>>
Nginx 知识点一网打尽:动静分离、压缩、缓存、跨域、高可用、性能优化...
查看>>
nginx 禁止以ip形式访问服务器
查看>>
NGINX 端口负载均衡
查看>>
Nginx 结合 consul 实现动态负载均衡
查看>>
Nginx 负载均衡与权重配置解析
查看>>
Nginx 负载均衡详解
查看>>