rsync同步

rsync概述

快速增量备份的工具
remote sync,支持远程同步
支持本地复制,或者与其他SSH,rsync主机同步

常用选项

 

实操

rsync本地复制

[root@rsync ~]# mkdir /www
[root@rsync ~]# cd /www
[root@rsync www]# touch test test1
[root@rsync www]# mkdir /hhh
[root@rsync www]# rsync -avz /www /hhh                #将/www带目录复制到/hhh下
sending incremental file list
www/
www/test
www/test1

sent 160 bytes  received 58 bytes  436.00 bytes/sec
total size is 0  speedup is 0.00
[root@rsync www]# ls /hhh                            #查看结果显示联通目录一起复制
www
[root@rsync www]# rsync -avz /www/ /hhh                #原目录后加上/表示仅复制目录下的文件
sending incremental file list
./
test
test1

sent 148 bytes  received 57 bytes  410.00 bytes/sec        
total size is 0  speedup is 0.00
[root@rsync www]# ls /hhh                            #查看结果
test  test1  www

配置源服务器


[root@rsync www]# yum install -y rsync                    
[root@rsync www]# vim /etc/rsyncd.conf                     
##删除原本内容,添加以下内容
uid = root                                            
默认是nobody
gid = root                                        
use chroot = yes                                                                                      
address = 192.168.118.100                                
port 873                                                                    
log file = /var/log/rsyncd.log                            # 日志文件位置                  
pid file = /var/run/rsyncd.pid                            # 存放进程id的文件位置
hosts allow = 192.168.118.0/24                            
[wwwroot]                                                                                
path = /var/www/html                                                    
comment = Document Root of www.ljm.com    
read only = yes                                                                        
dont comperss = *.gz *.bz2 *.tgz *.zip *.rar *.z          
auth users = backuper                                   
secrets file = /etc/users.db                             
[root@rsync ~]# vim /etc/user.db                        
whd:abc123
[root@rsync ~]# chmod 600 /etc/user.db                 
[root@rsync ~]# mkdir -p /var/www/html                
[root@rsync ~]# chmod +r /var/www/html/
[root@rsync ~]# ls -ld /var/www/html/
drwxr-xr-x. 2 root root 6 八月 11 05:27 /var/www/html/
[root@rsync ~]# rsync --daemon                        #开启服务
[root@rsync ~]# netstat -antp | grep rsync
tcp        0      0 192.168.118.100:873     0.0.0.0:*               LISTEN      88951/rsync  

查看同步

客户端交互同步

inotify安装

修改rsync配置文件

重启服务

修改客户端参数

[root@client aaa]# vim /etc/sysctl.conf                 
fs.inotify.max_queued_events = 32768                    
fs.inotify.max_user_instances = 1024                    
fs.inotify.max_user_watches = 1048576                    
8192
[root@client aaa]# sysctl -p
fs.inotify.max_queued_events = 32768
fs.inotify.max_user_instances = 1024
fs.inotify.max_user_watches = 1048576

安装inotify-tools

触发同步脚本

查看

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值