<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[CentOS 5 + rsync 同步2台服务器的文件,默认端口是873]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Sun, 12 Jun 2011 09:06:29 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	Always use rsync over ssh<br/>Since rsync does not provide any security while transferring data it is recommended that you use rsync over ssh . This allows a secure remote connection. Now let us see some examples of rsync.<br/><br/>rsync command common options<br/>--delete : delete files that don&#039;t exist on sender (system) <br/>-v : Verbose (try -vv for more detailed information) <br/>-e &quot;ssh options&quot; : specify the ssh as remote shell <br/>-a : archive mode <br/>-r : recurse into directories <br/>-z : compress file data <br/>Task : Copy file from a local computer to a remote server<br/>Copy file from /www/backup.tar.gz to a remote server called openbsd.nixcraft.in<br/><br/>$ rsync -v -e ssh /www/backup.tar.gz jerry@openbsd.nixcraft.in:~<br/>Output:<br/><br/>Password:<br/>sent 19099 bytes&nbsp;&nbsp;received 36 bytes&nbsp;&nbsp;1093.43 bytes/sec<br/>total size is 19014&nbsp;&nbsp;speedup is 0.99Please note that symbol ~ indicate the users home directory (/home/jerry).<br/><br/>Task : Copy file from a remote server to a local computer<br/>Copy file /home/jerry/webroot.txt from a remote server openbsd.nixcraft.in to a local computer /tmp directory:<br/><br/>$ rsync -v -e ssh jerry@openbsd.nixcraft.in:~/webroot.txt /tmp<br/>Password<br/><br/>Task: Synchronize a local directory with a remote directory<br/>$ rsync -r -a -v -e &quot;ssh -l jerry&quot; --delete openbsd.nixcraft.in:/webroot/ /local/webroot<br/>Task: Synchronize a remote directory with a local directory<br/>$ rsync -r -a -v -e &quot;ssh -l jerry&quot; --delete /local/webroot openbsd.nixcraft.in:/webroot<br/>Task: Synchronize a local directory with a remote rsync server<br/>$ rsync -r -a -v --delete rsync://rsync.nixcraft.in/cvs /home/cvs<br/>Task: Mirror a directory between my &quot;old&quot; and &quot;new&quot; web server/ftp<br/>You can mirror a directory between my &quot;old&quot; (my.old.server.com) and &quot;new&quot; web server with the command (assuming that ssh keys are set for password less authentication)<br/><br/>$ rsync -zavrR --delete --links --rsh=&quot;ssh -l vivek&quot; my.old.server.com:/home/lighttpd /home/lighttpd<br/>===================================================<br/><br/>当需要把服务器上的文件复制到另外的机器上，可用rsync来同步文件。<br/><br/>一、服务器端配置：<br/># yum -y install xinetd<br/><br/># vi /etc/xinetd.d/rsync<br/>将如下代码<br/><br/>service rsync<br/>&#123;<br/>disable = yes<br/>socket_type = stream<br/>wait = no<br/>user = root<br/>server = /usr/bin/rsync<br/>server_args = –daemon<br/>log_on_failure += USERID<br/>&#125;<br/>中的 disable = yes 改成 disable = no<br/><br/>然后启动 xinetd<br/># /etc/init.d/xinetd start<br/>注意：如果服务器上装有防火墙记得要打开端口，默认端口是873<br/><br/># telnet 127.0.0.1 873<br/>Trying 127.0.0.1...<br/>telnet: connect to address 127.0.0.1: Connection refused<br/># iptables -A INPUT -s 192.168.0.0/255.255.255.0 -p tcp -m tcp --dport 873 -j ACCEPT<br/># iptables -A INPUT -p tcp -m tcp --dport 873 -j DROP<br/># vi /etc/rsyncd.conf<br/><br/>[backup]<br/>path = /www<br/>auth users = admin<br/>uid = root<br/>gid = root<br/>secrets file = /etc/rsyncd.secrets<br/>read only = no<br/>[服务器代号]<br/>path = 备份文件路径<br/>auth users = 授权帐号<br/>uid = 执行时的uid<br/>gid = 执行时的gid<br/>secrets file = 密码文件位置<br/>read only = 是否只读<br/><br/># vi /etc/rsyncd.secrets<br/><br/>admin:1234 ＃用户名:密碼<br/>给文件正确的权限<br/># chown root:root /etc/rsyncd.secrets<br/># chmod 600 /etc/rsyncd.secrets<br/><br/>二、client 端进行同步<br/>客户端默认好像已经装了rsync，没有的话装下：<br/># yum -y install rsync<br/><br/>执行异步同步操作：<br/><br/>/usr/bin/rsync -avz –progress&nbsp;&nbsp;admin@192.168.1.105::backup /www<br/>同步命令说明：<br/><br/>1 显示目录内容<br/><br/>命令<br/>——<br/>a) rsync<br/>b) rsync -r<br/>c) rsync jack@192.168.0.1::<br/>d) rsync ssh_user@192.168.0.1:<br/><br/>命令说明<br/>———<br/>a) 显示目录内容(第一层)<br/>b) 递归显示目录内容<br/>c) 显示远程主机目录内容<br/>*注1：端口模式, 基于rsync用户的身份验证<br/>*注2：rsync server上的目录必须具有xx7的权限.<br/>d) 查看远程主机目录内容<br/>*注1：remote shell模式, 通过ssh连接的基于系统本地用户的身份验证<br/>*注2：这里只使用了一个冒号(:)，同时用户名是远程主机的ssh 用户，密码也是ssh用户对应的密码。<br/>*注3：使用””，则列出文件夹本身的信息。若要列出文件夹内容，应使用”/”。<br/><br/>参数说明<br/>———<br/>-r 对目录进行递归操作<br/><br/>2 本地目录之间同步<br/><br/>命令<br/>——<br/>a) rsync -av –progress / *** 注意(/) ***<br/>b) rsync -av –progress<br/>c) rsync -avu –progress –delete /<br/>d) rsync -av –progress –temp-dir=/tmp /<br/><br/>命令说明<br/>———<br/>a) 同步src-dir目录下所有文件到dst-dir目录下<br/>b) 同步src-dir目录下所有文件到dst-dir/src-dir目录下<br/>c) 对src-dir目录内容向dst-dir目录下进行差异更新，有增加/更新则添加替换，有减少则对其删减<br/>d) 比a)多了–temp-dir=/tmp，即指定/tmp为临时交换区，这样可以避免因目标目录空间不够引起的无法同步文件的错误。<br/><br/>参数说明<br/>———<br/>-a 相当于 -rlptgoD 的集合<br/>-u 等同于 –update，在目标文件比源文件新的情况下不更新<br/>-v 显示同步的文件<br/>–progress 显示文件同步时的百分比进度、传输速率<br/>–delete 删除目标目录中多于源目录的文件<br/><br/>3 异地主机之间同步<br/>命令<br/>——<br/>a) rsync -avz –progress jack@192.168.0.1::/<br/>b) rsync -avz –progress jack@192.168.0.1::/ –password-file=/home/jack/rsync.jack<br/>c) rsync -avuz –progress –delete jack@192.168.0.1::/ –password-file=/home/jack/rsync.jack<br/>d) rsync -avz –progress jack@192.168.0.1::/<br/><br/>命令说明<br/>———<br/>a) 同步本地目录的内容到远程主机192.168.0.1的目录下，jack是rsync数据库用户(参见3. /etc/rsync.secrets)<br/>b) 通过自动读取用户密码而实现非交互登录文件同步<br/>c) 较b)多了-u和–delete<br/>d) 同步远程主机内容到本地目录<br/><br/>来源：http://www.21andy.com/blog/20100925/1966.html
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] CentOS 5 + rsync 同步2台服务器的文件,默认端口是873]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>