<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[运维进行时]]></title> 
<link>https://blog.liuts.com/index.php</link> 
<description><![CDATA[互联网运维与架构]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[运维进行时]]></copyright>
<item>
<link>https://blog.liuts.com/post/59/</link>
<title><![CDATA[实践rsync+ssh实现代码同步[原创]]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[Linux]]></category>
<pubDate>Tue, 21 Aug 2007 15:20:05 +0000</pubDate> 
<guid>https://blog.liuts.com/post/59/</guid> 
<description>
<![CDATA[ 
	-------------------------从服务器配置-------------------------<br/>#cd /home/ && mkdir rsync && cd rsync<br/>#ssh-keygen -t dsa -b 2048 -f rsync-key<br/>呵呵，生成了：rsync-key rsync-key.pub两个文件，其中rsync-key为私钥,rnync-key.pub是公钥，要传到主服务器做认证的。写从服务器端脚本：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>#!/bin/sh<br/>RSYNC=/usr/bin/rsync #rsync位置<br/>SSH=/usr/bin/ssh #ssh位置<br/>KEY=/home/rsync/rsync-key #私钥位置<br/>RUSER=rsyncuser #主服务器帐号<br/>RHOST=192.168.100.5 #主服务器IP<br/>RPATH=/home/web #主服务器端代码目录<br/>LPATH=/home #从服务器代码目录/home/web，这时只能写/home<br/><br/>$RSYNC -avu --delete --exclude "WEB-INF/logs/" --exclude "WEB-INF/work/" -e "$SSH -i $KEY" $RUSER@$RHOST:$RPATH $LPATH<br/>#--exclude不要同步WEB-INF/logs/、WEB-INF/work/这两个目录。<br/>#--delete主服务器删除文件，从服务器也要删除。<br/>#-a --archive 归档模式，表示以递归方式传输文件，并保持所有文件属性。<br/>#-v, --verbose 详细模式输出。<br/>#-u, --update 仅仅进行更新，也就是跳过所有已经存在于DST，并且文件时间晚于要备份的文件。(不覆盖更新的文件) 。<br/></div></div><br/>定作业：<br/>crontab -e<br/>*/5 * * * * /home/rsync/rsync.sh #每5分钟运行一次。<br/><br/><br/>------------------------主服务器配置--------------------------<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>#useradd rsyncuser<br/>#su rsyncuser<br/>#cd /home/rsyncuser<br/>#if [ ! -d .ssh ]; then mkdir .ssh ; chmod 700 .ssh ; fi<br/>#mv rsync-key.pub(从服务器生成的公钥) .ssh/<br/>#cd .ssh/<br/>SSH1:#cat rsync-key.pub >> authorized_keys<br/>SSH2:#ssh-keygen -X -f rsync-key.pub >> authorized_keys2<br/>chmod 600 authorized_keys //这一步一定要做，特殊权限要求。<br/>我用的是SSH2，但用SSH2的方式有一个提示长度越界的错误，那就用SSH1的方法也没问题。<br/></div></div><br/>Tags - <a href="https://blog.liuts.com/tags/rsync/" rel="tag">rsync</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/59/#blogcomment41</link>
<title><![CDATA[[评论] 实践rsync+ssh实现代码同步[原创]]]></title> 
<author>一生何求 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 17 Mar 2010 02:19:53 +0000</pubDate> 
<guid>https://blog.liuts.com/post/59/#blogcomment41</guid> 
<description>
<![CDATA[ 
	你好,这里的主从是指LVS-HA的主从吗,&nbsp;&nbsp;我的理解RSYNC是同步LVS-HA数据到管理端再画图.&nbsp;&nbsp; 这里做LVS间的SSH是什么用处?谢谢!
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/59/#blogcomment43</link>
<title><![CDATA[[评论] 实践rsync+ssh实现代码同步[原创]]]></title> 
<author>GG &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 17 Mar 2010 04:11:10 +0000</pubDate> 
<guid>https://blog.liuts.com/post/59/#blogcomment43</guid> 
<description>
<![CDATA[ 
	master是tianyaLVS的管理端吗,slave是 LVS虚IP端?
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/59/#blogcomment921</link>
<title><![CDATA[[评论] 实践rsync+ssh实现代码同步[原创]]]></title> 
<author>john &lt;boy_nice@163.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 23 Sep 2011 07:12:32 +0000</pubDate> 
<guid>https://blog.liuts.com/post/59/#blogcomment921</guid> 
<description>
<![CDATA[ 
	从服务器配置和主服务器配置分别在哪里执行？
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/59/#blogcomment922</link>
<title><![CDATA[[评论] 实践rsync+ssh实现代码同步[原创]]]></title> 
<author>john &lt;boy_nice@163.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 23 Sep 2011 07:19:46 +0000</pubDate> 
<guid>https://blog.liuts.com/post/59/#blogcomment922</guid> 
<description>
<![CDATA[ 
	你说的同步指得是什么？
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/59/#blogcomment923</link>
<title><![CDATA[[评论] 实践rsync+ssh实现代码同步[原创]]]></title> 
<author>john &lt;boy_nice@163.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 23 Sep 2011 11:53:25 +0000</pubDate> 
<guid>https://blog.liuts.com/post/59/#blogcomment923</guid> 
<description>
<![CDATA[ 
	你好：<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;你这里的从服务器和主服务器端分别指的是？<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 目录：<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RPATH=/home/web #主服务器端代码目录<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LPATH=/home #从服务器代码目录<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;你这个代码目录指的是控制端的web 代码还是控制端脚本？<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;例如：如果是web代码是不是/www/TianyaLVS这个目录地址就可以了，不要细分下去？
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/59/#blogcomment933</link>
<title><![CDATA[[评论] 实践rsync+ssh实现代码同步[原创]]]></title> 
<author>englishp744 &lt;yibeiziliageren@hotmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 27 Sep 2011 09:19:46 +0000</pubDate> 
<guid>https://blog.liuts.com/post/59/#blogcomment933</guid> 
<description>
<![CDATA[ 
	Thank bloggers to share and support!
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/59/#blogcomment2442</link>
<title><![CDATA[[评论] 实践rsync+ssh实现代码同步[原创]]]></title> 
<author>handl &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 14 Mar 2014 10:37:31 +0000</pubDate> 
<guid>https://blog.liuts.com/post/59/#blogcomment2442</guid> 
<description>
<![CDATA[ 
	天斯兄，其实未必要配置rsyncd .conf也可以同步的。
]]>
</description>
</item>
</channel>
</rss>