安装

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. 学习练习 java练习小题题目:判断一个整数能被几个9整除

    题目:判断一个整数能被几个9整除 package com.hanqi.lianxi; import java.io.*; public class Test1 { //判断能否被9整除 static ...

  2. [设计模式 3] 用设计模式的眼光看MVC框架

    导读:之前一直在区分MVC和设计模式的区别,但是,既然有些人认为MVC是一种设计模式,那么它们之间肯定是有共通之处的.所以,本篇博客,就用设计模式的眼光来看MVC框架.仅是本人对于MVC的粗鄙看法,还 ...

  3. 线程中CreateEvent和SetEvent及WaitForSingleObject的用法

    首先介绍CreateEvent是创建windows事件的意思,作用主要用在判断线程退出,线程锁定方面. CreateEvent 函功能描述:创建或打开一个命名的或无名的事件对象. EVENT有两种状态 ...

  4. 智能指针(三):unique_ptr使用简介

    我们知道auto_ptr通过复制构造或者通过=赋值后,原来的auto_ptr对象就报废了.所有权转移到新的对象中去了.而通过shared_ptr可以让多个智能指针对象同时拥有某一块内存的访问权.但假如 ...

  5. SQLServer、MySQL、Oracle语法差异小集锦

    一.差异集锦 在建表的时候,只有自增的语法不同. 下面给出3种数据库通用的建表与初始化测试语句: CREATE TABLE Country( Id int PRIMARY KEY, Name ) ); ...

  6. Qt 信号和槽函数

    信号和槽是一种高级接口,应用于对象之间的通信,它是 QT 的核心特性.当某个信号被发射,就需要调用与之相绑定的槽函数.这与Windows下的消息机制类似,消息机制是基于回调函数.一个回调即是一个函数的 ...

  7. Oracle笔记 十四、查询XML操作、操作系统文件

    --1.随机数 select dbms_random.value from dual; select mod(dbms_random.random, 10) from dual; --0-9随机数 s ...

  8. 索引 使用use index优化sql查询

    好博客:MySQL http://webnoties.blog.163.com/blog/#m=0&t=1&c=fks_08407108108708107008508508609508 ...

  9. Spring框架搭建遇到的问题汇总

    1.The resource is not on the build path of a Java project 然后把相应的依赖加入构建路径 2.Type mismatch: cannot con ...

  10. CentOS6.5_python2.7.3下virt-manager无法启动

    配置virt-manager: 1.安装virt-manager, libvirt, qemu-kvm 2.配置libvirtd开机启动: chkconfig libvirtd on   #取消开机启 ...