安装

1
yum -y install rsync

---------------------服务器安装-------------------------------

创建基础配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#vim /etc/rsyncd.conf
  
uid = root 
gid = root   
use chroot = no 
max connections = 5 
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock 
log file = /var/log/rsyncd.log  
  
[www]  
path = /usr/local/nginx/html/down/ 
ignore errors    
read only = true
list = false        
auth users = rsync
secrets file = /etc/rsync.pas

创建密码配置文件

1
2
#vi /etc/rsync.pas
rsync:yourpassword

将rsync.pas设置为root所有, 权限为600

1
2
chown root.root /etc/rsync.pas
chmod 600 /etc/rsync.pas

启动:

1
/usr/bin/rsync --daemon

打开防火墙设置873端口:编辑/etc/sysconfig/iptables文件,添加873端口

关闭selinux:打开/etc/selinux/config文件,修改SELINUX=disabled

------------------------------客户端安装-----------------------------------------

创建基础配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#vim /etc/rsyncd.conf
 
uid = root  
gid = root    
use chroot = no  
max connections = 5  
pid file = /var/run/rsyncd.pid 
lock file = /var/run/rsync.lock  
log file = /var/log/rsyncd.log   
 
[www]   
path = /usr/local/test/
ignore errors     
read only = true
list = false         
auth users = rsync 
secrets file = /etc/rsync.pas

创建密码配置文件

1
2
#vi /etc/rsync.pas
yourpassword

将rsync.pas设置为root所有, 权限为600

1
2
chown root.root /etc/rsync.pas
chmod 600 /etc/rsync.pas

执行同步命令:

1
rsync -vrtup -R --delete rsync@10.10.10.10::www --password-file=/etc/rsync.pas /usr/local/test/

命令解析:

1
2
3
4
5
6
7
8
9
10
11
12
-v, --verbose 详细模式输出
-r, --recursive 对子目录以递归模式处理
-t, --times 保持文件时间信息
-u, --update 仅仅进行更新,也就是跳过所有已经存在于DST,并且文件时间晚于要备份的文件。(不覆盖更新的文件)
-p, --perms 保持文件权限
 
rsync@10.10.10.10::www
rsync - 登陆用户名
10.10.10.10 - 服务器IP
www - 主配置文件中的段名
--password-file=/etc/rsync.pas  - 指定密码文件
/usr/local/test/ - 要同步到的本地目标文件夹

设置自动运行脚本,每5秒执行一次同步

1
2
3
4
5
6
7
#!/bin/bash
 
while [ 1 ]
do
rsync -vrtup -R rsync@10.10.10.10::www --delete --password-file=/etc/rsync.pas /usr/local/nginx/html/down
sleep 5
done

设置脚本自启动:

在centos5 和 centos6中,方法不太一样。centos6可以参见另一篇文章:

http://hi.baidu.com/solohac/item/9a89bf4257a97eeaa5c066cd

centos rsync安装配置的更多相关文章

  1. Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)

    Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)   关于LAMP的各种知识,还请大家自行百度谷歌,在这里就不详细的介绍了,今天主要是介绍一下在Centos下安装,搭建一 ...

  2. CentOS 7安装配置Apache HTTP Server

    原文 CentOS 7安装配置Apache HTTP Server   RPM安装httpd # yum -yinstall httpd //安装httpd会自动安装一下依赖包: apr apr-ut ...

  3. CentOS 7 安装配置 NFS

    CentOS 7  安装配置 NFS 环境 nps 192.168.1.97 client 192.168.1.98 一.yum 安装 yum -y install nfs-utils rpcbind ...

  4. 分布式文件系统 FastDFS 5.0.5 & Linux CentOS 7 安装配置(单点安装)——第一篇

    分布式文件系统 FastDFS 5.0.5 & Linux CentOS 7 安装配置(单点安装)--第一篇 简介 首先简单了解一下基础概念,FastDFS是一个开源的轻量级分布式文件系统,由 ...

  5. CentOS 7安装配置Samba服务器

    CentOS 7安装配置Samba服务器 CentOS 7下Samba服务器安装配置过程笔记. 假设我们有这样一个场景 共享名 路径 权限 SHAREDOC /smb/docs 所有人员包括来宾均可以 ...

  6. CentOS 7安装配置Samba服务器(挂载共享文件夹)

    CentOS 7安装配置Samba服务器 CentOS 7下Samba服务器安装配置过程笔记. 假设我们有这样一个场景 共享名 路径 权限 SHAREDOC /smb/docs 所有人员包括来宾均可以 ...

  7. 记录:CentOS 7 安装配置分布式文件系统 FastDFS 5.1.1

    CentOS 7 安装配置分布式文件系统 FastDFS 5.1.1 软件下载:http://download.csdn.net/download/qingchunwuxian1993/9897458 ...

  8. CentOS gitlab 安装配置

    CentOS gitlab 安装配置 2018-11-02 11:23:09   Visit  5 在/etc/yum.repos.d 目录下创建文件gitlab-ce.repo,使用国内的安装源 b ...

  9. <转>CentOS 7 安装配置 NFS

    CentOS 7  安装配置 NFS 环境 nps 192.168.1.97 client 192.168.1.98 一.yum 安装 yum -y install nfs-utils rpcbind ...

随机推荐

  1. 三味书屋 bbb

    为学日益 ,为道日损 .损之又损,以至于无为

  2. PAT1075. PAT Judge

    //终于A了,不难却觉着坑多的的题,注意-1的处理,感觉我是受memset置0的束缚了,可以把初试成绩置-1.就不用debug怎么久,注意对于-1的处理,不然漏洞百出 #include<cstd ...

  3. 【MongoBD】MongoBD持久化

    参考:http://f.dataguru.cn/thread-139560-1-1.html 参考:http://blog.mongodb.org/post/33700094220/how-mongo ...

  4. ios开发经典语录锦集

    原文链接: iPhone开发经典语录集锦 前言:iPhone是个极具艺术性的平台,相信大家在开发过程中一定有很多感触,希望能写出来一起交流,所以开了这个帖子,以后还会维护. 如果大家和我一样有感触的话 ...

  5. 检查字符串长度 检查字符串是否为空 用正则表达式验证出版物的ISBN号 用正则表达式验证邮证编码 验证字符串中是否含有汉字

    <?php /** * 常用的正则表达式来验证信息.如:网址 邮箱 手机号等 */ class check { /** * 正则表达式验证email格式 * * @param string $s ...

  6. grep,awk和sed的常用命令和语法

    Grep的常用命令语法 1. 双引号引用和单引号引用在g r e p命令中输入字符串参数时,最好将其用双引号括起来.例如:“m y s t r i n g”.这样做有两个原因,一是以防被误解为 s h ...

  7. CICS中设置程序常驻内存

    CICS中设置程序常驻内存 Permanent=no 修改为Permanent=yse --------------------- 对CICS的参数进行调节,RD中

  8. 必须会的SQL语句(七)字符串函数、时间函数

    字符串函数   1.大小写转换    --upper 转化成大写    --lower  转换成小写    select upper('AsaR')   2.长度    --len 字数    --d ...

  9. Windows 7/8/8.1 硬盘安装法实现 ubuntu 14.04 双系统

    一.软件准备 1. 下载 Ubuntu 系统镜像:http://www.ubuntu.com/download/desktop/ : 这里使用的是 ubuntu 14.04.1 LTS 64bit 版 ...

  10. 最简单删除SQL Server中所有数据的方法

     最简单删除SQL Server中所有数据的方法 编写人:CC阿爸 2014-3-14 其实删除数据库中数据的方法并不复杂,为什么我还要多此一举呢,一是我这里介绍的是删除数据库的所有数据,因为数据之间 ...