rsync 是一个Unix/Linux系统下的文件同步和传输工具。rsync是用 “rsync 算法”提供了一个客户机和远程文件服务器的文件同步的快速方法。可以用来做备份或镜像。
一、配置文件rsyncd.conf
1. 创建配置目录和文件
# 在/etc目录下创建一个rsyncd的目录,我们用来存放rsyncd.conf 和rsyncd.secrets文件
shell> mkdir /etc/rsyncd
# 创建rsyncd.conf ,这是rsync服务器的配置文件
shell> touch /etc/rsyncd/rsyncd.conf
# 创建rsyncd.secrets ,这是用户密码文件
shell> touch /etc/rsyncd/rsyncd.secrets
# 为了密码的安全性,我们把权限设为600
shell> chmod 600 /etc/rsyncd/rsyncd.secrets
# 服务器欢迎信息
shell> touch /etc/rsyncd/rsyncd.motd 
2. 编辑rsyncd.conf
# This line is required by the /etc/init.d/rsyncd script
pid file = /var/run/rsyncd.pid   
port = 873
address = 192.168.1.201 
uid = root   
gid = root   
use chroot = yes  
read only = yes  
#limit access to private LANs
hosts allow=192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0  
hosts deny=*
max connections = 5 
motd file = /etc/rsyncd/rsyncd.motd
#This will give you a separate log file
#log file = /var/log/rsync.log
#This will log every file transferred - up to 85,000+ per user, per sync
#transfer logging = yes
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
[linuxroot]   
path = /
list=yes 
ignore errors 
auth users = root
secrets file = /etc/rsyncd/rsyncd.secrets
comment = linuxroot
exclude =   home/
注:
(1) address 是服务器IP地址,uid,gid是服务器传输文件发起执行的用户和组
(2) auth users 认证用户。是必须在服务器上存在的真实的系统用户,以,号隔开多个用户
(3) path 指定文件目录所在位置
(4) excude 排除的目录列表
2. 编辑rsyncd.secrets(用户名:密码)
root:123123
3.启动rsync服务器
shell> /usr/bin/rsync --daemon  --config=/etc/rsyncd/rsyncd.conf 
# Linux防火墙是用iptables,所以查看防火墙设置
shell> iptables -A INPUT -p tcp -m state --state NEW  -m tcp --dport 873 -j ACCEPT
# 查看一下防火墙是不是打开了 873端口;
shell> iptables -L 
二、同步数据
1. 查看同步数据情况
#rsync rsync://[认证用户]@[主机]/[模块名]
shell> rsync rsync://feng2@192.168.1.201/linuxroot
2. 客户端同步数据:
客户端创建认证用户密码文件。可以在同步时不用输入密码,也方便crond计划任务。
# rsync -avzP  --progress --delete [认证用户]@[主机名]::[模块名] [目标路径]
shell> su
shell> cd ~
shell> touch rsync.password 
shell> chmod 600 rsync.password 
shell> echo "123123" > rsync.password
shell> rsync -avzP --progress --delete --password-file=rsync.password root@192.168.1.201::linuxroot /(责任编辑:admin)

http://www.net527.cn/a/caozuoxitong/Linux/15822.html

Rsync文件同步服务器配置的更多相关文章

  1. Rsync文件同步

    Rsync文件同步 本章结构 关于rsync 1.一款增量备份工具,remote sync,远程同步,支持本地复制或者与其他SSH.rsync主机同步,官方网站:http://rsync.samba. ...

  2. CentOS系统rsync文件同步 安装配置

    rsync是类unix系统下的数据镜像备份工具,从软件的命名上就可以看出来了——remote sync 它的特性如下: 可以镜像保存整个目录树和文件系统. 可以很容易做到保持原来文件的权限.时间.软硬 ...

  3. rsync 文件同步和备份

    rsync 是同步文件的利器,一般用于多个机器之间的文件同步与备份,同时也支持在本地的不同目录之间互相同步文件.在这种场景下,rsync 远比 cp 命令和 ftp 命令更加合适,它只会同步需要更新的 ...

  4. Rsync文件同步工具

    前段时间因公司需求,需要把备份的文件进行同步保存,后面就想到了我们大家都最熟悉的文件同步工作Rsync,于是就捣鼓了一下午时间,然后总结了下大概过程和参数详情. 首先了解了下rsync同步的大致原理: ...

  5. linux 下的 rsync 文件同步

    rsync是linux下的一款快速增量备份工具Remote Sync,是一款实现远程同步功能的软件,它在同步文件的同时,可以保持原来文件的权限.时间.软硬链接等附加信息.rsync是用 “rsync ...

  6. inotify 与 rsync文件同步实现与问题

    首先分别介绍inotify 与 rsync的使用,然后用两者实现实时文件同步,最后说一下这样的系统存在什么样的问题. 1. inotify 这个具体使用网上很多,参考 inotify-tools 命令 ...

  7. rsync文件同步、Inotify-tools参数详解

    inotifywait用于等待文件或文件集上的一个待定事件,可以监控任何文件和目录设置,并且可以递归地监控整个目录树: inotifywatch用于收集被监控的文件系统计数据,包括每个inotify事 ...

  8. [rsync]——rsync文件同步和备份

    实验环境 (1) Rsync服务器:10.0.10.158 (2) Rsync客户端:10.0.10.173 Rsync服务器端的配置 1. 安装xinetd和rsync # yum install ...

  9. Centos6.5下rsync文件同步安装配置及遇到的问题解决方法

    实验节点如下: 源节点:192.168.0.111 备份节点:192.168.0.112 ------------------------------以下部分在两个节点上执行1.防火墙开放873端口( ...

随机推荐

  1. Jewel Magic UVA - 11996 || bzoj1014: [JSOI2008]火星人prefix

    Jewel Magic UVA - 11996 这是一道用splay/非旋treap做的题(这里用的是非旋treap) 1/2/3是splay/非旋treap的常规操作.对于操作4,可以用哈希法求LC ...

  2. [转]在asp.net mvc中使用PartialView返回部分HTML段

    本文转自:http://blog.csdn.net/sandy945/article/details/6307750 问题链接: MVC如何实现异步调用输出HTML页面 该问题是个常见的 case, ...

  3. jquery各种选择器示例

    $("#itemExpressionHidden>b:last")   选择id为itemExpressionHidden中的最后一个b标签 $("#itemExp ...

  4. [BZOJ1088][SCOI2005]扫雷Mine DP

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1088 记录下每一个格子对应左边格子放的雷的情况,然后dp转移就好了. #include&l ...

  5. Elasticsearch--集群&时光之门和恢复控制

    节点发现 启动一个Elasticsearch节点时,该节点会开始寻找具有相同集群名字并且可见的主节点.如果找到主节点,该节点加入一个已经组成了的集群:如果没有找到,该节点成为主节点(如果配置允许).形 ...

  6. 【CSS】3种CSS方法设置元素垂直水平居中

    1. 宽高固定 设置要水平垂直居中的 div 的 position 为 absolute,left:50%; margin-left为负的这个元素宽度的一半,同理,top:50%;margin-top ...

  7. IntelliJ IDEA安装与破解

    1.软件下载 文中使用到的安装包下载 2.部署 安装一路下一步即可. 把下载的JetbrainsCrack-3.1-release-enc.jar放在安装目录的bin目录下 3.修改配置文件 在安装的 ...

  8. Spring data jpa中Query和@Query分别返回map结果集

    引用: http://blog.csdn.net/yingxiake/article/details/51016234 http://blog.csdn.net/yingxiake/article/d ...

  9. Java编程思想总结笔记Chapter 3

    本章需要总结的不多,但细节的东西需要注意,有些很容易遗忘. 第三章 目录: 3.1 更简单的打印语句 3.2 使用Java操作符 3.3 优先级 3.4 赋值 3.5 算数操作符 3.6 自动递增和递 ...

  10. Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser]

    严重: Exception sending context initialized event to listener instance of class org.springframework.we ...