惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
博客园 - 【当耐特】
月光博客
月光博客
Vercel News
Vercel News
D
Docker
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 叶小钗
MongoDB | Blog
MongoDB | Blog
GbyAI
GbyAI
有赞技术团队
有赞技术团队
雷峰网
雷峰网
博客园 - 聂微东
小众软件
小众软件
Y
Y Combinator Blog
腾讯CDC
L
LangChain Blog
The GitHub Blog
The GitHub Blog
宝玉的分享
宝玉的分享
Stack Overflow Blog
Stack Overflow Blog
大猫的无限游戏
大猫的无限游戏
T
The Blog of Author Tim Ferriss

博客园 - Nuke'Blog

Web网站压力及性能测试工具WebBench使用指南 url 中文转码 Linux Crontab 定时任务 命令详解 404、500、502等HTTP状态码介绍 谈谈IT公司常见的离职潮 网易组图新闻显示效果,代码刚抠下来整理好分享大家 土鳖网站是怎样炼成的 SQL语法操作全集 在 Apache 上实现 META 切换 请执行sp_addlinkedserver 将该服务器添加到sysserver解决办法 C#.Net的WinForm中使用水晶报表 iBATIS的like 经典,句句噎死人! 表单元素与提示文字无法对齐的问题(input,checkbox文字对齐) 前台JS限制上传图片质量大小和尺寸 - Nuke'Blog - 博客园 关于网络的IP地址 使用正则表达式过滤html标签,属性,样式表,挂马脚本 - Nuke'Blog - 博客园 linux 解压命令总结 JVM内存模型以及垃圾回收 Siege for linux
Linux下架设rsync服务器
Nuke'Blog · 2013-03-21 · via 博客园 - Nuke'Blog

rsync 是一个Unix系统下的文件同步和传输工具。rsync是用 “rsync 算法”提供了一个客户机和远程文件服务器的文件同步的快速方法。


Some features of rsync include
 rsync 包括如下的一些特性:
* can update whole directory trees and filesystems
能更新整个目录和树和文件系统;
* optionally preserves symbolic links, hard links, file ownership, permissions, devices and times
有选择性的保持符号链链、硬链接、文件属于、权限、设备以及时间等;
* requires no special privileges to install
对于安装来说,无任何特殊权限要求;
* internal pipelining reduces latency for multiple files
对于多个文件来说,内部流水线减少文件等待的延时;
* can use rsh, ssh or direct sockets as the transport
能用rsh、ssh 或直接端口做为传输入端口;
* supports anonymous rsync which is ideal for mirroring
支持匿名rsync 同步文件,是理想的镜像工具;
 
安装配置过程:
 一。建相应的文件及文件夹
[root@estals60:~]#mkdir /etc/rsyncd  --在/etc目录下创建一个rsyncd的目录,我们用来存放rsyncd.conf 和rsyncd.secrets文件;
[root@estals60:~]#touch /etc/rsyncd/rsyncd.conf  --创建rsyncd.conf ,这是rsync服务器的配置文件;
[root@estals60:~]#touch /etc/rsyncd/rsyncd.secrets --创建rsyncd.secrets ,这是用户密码文件;
[root@estals60:~]#chmod 600 /etc/rsyncd/rsyncd.secrets  --为了密码的安全性,我们把权限设为600;
[root@estals60:~]#ls -lh /etc/rsyncd/rsyncd.secrets
 -rw------- 1 root root 14 2007-07-15 10:21 /etc/rsyncd/rsyncd.secrets
 [root@estals60:~]#touch /etc/rsyncd/rsyncd.motd
  
二。 修改 rsyncd.conf 和rsyncd.secrets 和rsyncd.motd
 rsyncd.conf 是rsync服务器主要配置文件,我们来个简单的示例;比如我们要备份服务器上的 /nsn_talko_production/talko/var/www/html/Talko/talko.next/repository/
  
 # Minimal configuration file for rsync daemon
 # See rsync(1) and rsyncd.conf(5) man pages for help
 # This line is required by the /etc/init.d/rsyncd script
 pid file = /var/run/rsyncd.pid
 port = 873
 address = estals60
 #uid = nobody
 #gid = nobody
 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
 [P_repositor]
 path = /nsn_talko_production/talko/var/www/html/Talko/talko.next/repository/
 list=yes      --list 意思是把rsync 服务器上提供同步数据的目录在服务器上模块是否显示列出来。默认是yes 。如果你不想列出来,就no ;如果是no是比较安全的,至少别人不知道你的服务器上提供了哪些目录。你自己知道就行了
ignore errors                               --忽略IO错误
auth users = root                           --用户账号 (这个必须得是系统中已经存在的账号)
secrets file = /etc/rsyncd/rsyncd.secrets   --存放密码的地方
comment = P_repositor          --相当于是一种接口名字,等服务跑起来了客户端可以直接用这名字调用相关服务器的文件夹内容信息
#exclude =   beinan/  samba/    --无视这两个文件夹的内容
 
rsyncd.secrets的内容如下类似
root:123456
 yofee:123456
  
 rsyncd.motd 文件
 它是定义rysnc 服务器信息的,也就是用户登录信息。比如让用户知道这个服务器是谁提供的等.
 +++++++++++++++++++++++++++
 + Yofee Packages rsync    +
 +++++++++++++++++++++++++++
  
  
三、启动rsync服务器
[root@estals60:~]#/usr/bin/rsync --daemon  --config=/etc/rsyncd/rsyncd.conf
  
四、防火墙的设置
[root@estals60:~]#iptables -A INPUT -p tcp -m state --state NEW  -m tcp --dport 873 -j ACCEPT
 [root@estals60:~]#iptables -L  查看一下防火墙是不是打开了 873端口;
 
五、执行同步命令
rsync -avzP root@estals60::P_repositor /nsn_talko/talko/var/www/html/Talko/talko.next/
这时会要求输入root的密码,然后就没啥问题了。
 另外其实也可以考虑把他建在系统任务里面定时运行。道理都是一样的,用crontab,这里就不再重述了。


 


######################
uid = nobody
 gid = nobody
 use chroot = no
 read only = false
 max connections = 5
 port = 873
 motd file = /etc/rsyncd/rsyncd.motd
 pid file = /tmp/rsyncd.pid
 lock file = /tmp/rsync.lock
 log format = %t %a %m %f %b
 log file = /tmp/rsyncd.log
 timeout = 300


[update]
 path = /data/autoupdate/
 ignore errors = yes
 list = false
 comment = update
 secrets file = /etc/rsyncd/rsyncd.secrets
 hosts allow = *
 #hosts deny = 0.0.0.0/32
 ###########################################