Ó²ÅÌÊý¾Ý»Ö¸´µ¼º½
RAIDÊý¾Ý»Ö¸´µ¼º½
 | ÍøÕ¾Ê×Ò³ | Êý¾Ý»Ö¸´×ÊÁÏ | Êý¾Ý»Ö¸´Èí¼þ | ×ÉѯÁôÑÔ | Êý¾Ý»Ö¸´²©¿Í | Êý¾Ý»Ö¸´ÂÛ̳ | 
Êý¾Ý»Ö¸´Èí¼þÏÂÔØ
¹«Ë¾¼ò½é Êý¾Ý»Ö¸´³É¹¦°¸Àý Êý¾Ý»Ö¸´±¨¼Û Êý¾Ý»Ö¸´Åàѵ Êý¾Ý»Ö¸´¼¼ÊõÎÄÕ Êý¾Ý»Ö¸´¿Í·þÖÐÐÄ Êý¾Ý»Ö¸´·þÎñÁªÏµ·½Ê½
ÄúÏÖÔÚµÄλÖ㺠±±ÑÇÊý¾Ý»Ö¸´¼¼ÊõÕ¾ >> Êý¾Ý»Ö¸´×ÊÁÏ >> ·þÎñÆ÷Óë´æ´¢¼¼Êõ >> ÎÄÕÂÕýÎÄ
ÓÃrsync¶ÔÍøÕ¾½øÐоµÏñ±¸·Ý            ¡¾×ÖÌ壺С ´ó¡¿
ÓÃrsync¶ÔÍøÕ¾½øÐоµÏñ±¸·Ý
×÷ÕߣºÎ´Öª    ÎÄÕÂÀ´Ô´£ºÍøÂç    µã»÷Êý£º    ¸üÐÂʱ¼ä£º2009-5-13
¶Ôϵͳ¹ÜÀíÔ±À´Ëµ£¬Æ½Ê±µÄ¹¤×÷ÖØÐÄÓ¦¸Ã¼¯ÖÐÔÚά»¤ÏµÍ³Õý³£ÔËת£¬Äܹ»Õý³£Ìṩ·þÎñÉÏ£¬ÕâÀïÍùÍùÇ£Éæµ½Ò»¸öÊý¾Ý±¸·ÝµÄÎÊÌ⣬ÔÚÎÒËùÁ˽âµÄÇé¿öÖУ¬ÓÐ80%
µÄϵͳ¹ÜÀíÔ±²»ÊÇÌ«¹ØÐÄ×Ô¼º·þÎñÆ÷µÄ°²È«ÐÔ£¬µ«ÍùÍù¶Ô±¸·Ö¾µÏñµÄ¼¼ÊõÏ൱¸ÐÐËȤ£¬µ«ÓÉÓÚÉÌÒµ²úÆ·µÄÈíÓ²¼þ¼Û¸ñ¶¼Ï൱¸ß°º£¬Òò´ËÍùÍù»áÑ¡Ôñ×ÔÓÉÈí¼þ¡£ÕâÀï×¼
±¸½éÉܵÄrsync¾ÍÊÇÕâÑùµÄÈí¼þ£¬Ëü¿ÉÒÔÂú×ã¾ø´ó¶àÊýÒªÇó²»ÊÇÌرð¸ßµÄ±¸·ÝÐèÇó¡£
Ò»¡¢ÌØÐÔ¼ò½é
rsyncÊÇÀàunixϵͳϵÄÊý¾Ý¾µÏñ±¸·Ý¹¤¾ß£¬´ÓÈí¼þµÄÃüÃûÉϾͿÉÒÔ¿´³öÀ´ÁË¡ª¡ªremote
sync¡£ËüµÄÌØÐÔÈçÏ£º
1¡¢¿ÉÒÔ¾µÏñ±£´æÕû¸öĿ¼Ê÷ºÍÎļþϵͳ¡£
2¡¢¿ÉÒÔºÜÈÝÒ××öµ½±£³ÖÔ­À´ÎļþµÄȨÏÞ¡¢Ê±¼ä¡¢ÈíÓ²Á´½ÓµÈµÈ¡£
3¡¢ÎÞÐëÌØÊâȨÏÞ¼´¿É°²×°¡£
4¡¢ÓÅ»¯µÄÁ÷³Ì£¬Îļþ´«ÊäЧÂʸߡ£
5¡¢¿ÉÒÔʹÓÃrcp¡¢sshµÈ·½Ê½À´´«ÊäÎļþ£¬µ±È»Ò²¿ÉÒÔͨ¹ýÖ±½ÓµÄsocketÁ¬½Ó¡£
6¡¢Ö§³ÖÄäÃû´«Êä¡£
¶þ¡¢Ê¹Ó÷½·¨
rsyncµÄʹÓ÷½·¨ºÜ¼òµ¥£¬ÎҾ;Ù×Ô¼ºÊ¹ÓõÄÀý×ÓÀ´ËµÃ÷°É¡£
1¡¢ÏµÍ³»·¾³
rsyncÖ§³Ö´ó¶àÊýµÄÀàunixϵͳ£¬ÎÞÂÛÊÇLinux¡¢Solaris»¹ÊÇBSDÉ϶¼¾­¹ýÁËÁ¼ºÃµÄ²âÊÔ¡£ÎÒµÄϵͳ»·¾³Îª£º
server:
FreeBSD 4.3 ip: 192.168.168.52
client: Solaris 8 ip:
192.168.168.137
rsync °æ±¾ 2.4.6(¿ÉÒÔ´Ó
http://rsync.samba.org/rsync/
»ñµÃ×îа汾)
2¡¢ÅäÖÃserver¶ËµÄ/etc/rsyncd.confÎļþ
bash-2.03#
cat /etc/rsyncd.conf
uid = nobody
gid = nobody
use chroot = no # ²»Ê¹ÓÃchroot
max connections = 4 #
×î´óÁ¬½ÓÊýΪ4
pid file = /var/run/rsyncd.pid
lock file =
/var/run/rsync.lock
log file = /var/log/rsyncd.log #
ÈÕÖ¾¼Ç¼Îļþ
[inburst] # ÕâÀïÊÇÈÏÖ¤µÄÄ£¿éÃû£¬ÔÚclient¶ËÐèÒªÖ¸¶¨
path =
/home/inburst/python/ # ÐèÒª×ö¾µÏñµÄĿ¼
comment = BACKUP CLIENT IS SOLARIS 8
E250
ignore errors # ¿ÉÒÔºöÂÔһЩÎ޹صÄIO´íÎó
read only = yes #
Ö»¶Á
list = no # ²»ÔÊÐíÁÐÎļþ
auth users = inburst #
ÈÏÖ¤µÄÓû§Ãû£¬Èç¹ûûÓÐÕâÐУ¬Ôò±íÃ÷ÊÇÄäÃû
secrets file = /etc/inburst.pas #
ÈÏÖ¤ÎļþÃû
[web]
path =
/usr/local/apache/htdocs/
comment = inburst.org web
server
3¡¢ÔÚserver¶ËÉú³ÉÒ»¸öÃÜÂëÎļþ/etc/inburst.pas
bash-2.03#
cat
/etc/inburst.pas
inburst:hack
³öÓÚ°²È«Ä¿µÄ£¬ÎļþµÄÊôÐÔ±ØÐèÊÇÖ»ÓÐÊôÖ÷¿É¶Á¡£
4¡¢ÔÚserver¶Ë½«rsyncÒÔÊØ»¤½ø³ÌÐÎʽÆô¶¯
bash-2.03#
rsync
--daemon
Èç¹ûÒªÔÚÆô¶¯Ê±°Ñ·þÎñÆðÀ´£¬Óм¸ÖÖ²»Í¬µÄ·½·¨£¬±ÈÈ磺
a¡¢¼ÓÈëinetd.conf
±à¼­/etc/services£¬¼ÓÈërsync
873/tcp£¬Ö¸¶¨rsyncµÄ·þÎñ¶Ë¿ÚÊÇ873
±à¼Ó/etc/inetd.conf£¬¼ÓÈërsync stream tcp nowait root
/bin/rsync rsync
--daemon
b¡¢¼ÓÈërc.local
ÔÚ¸÷ÖÖ²Ù×÷ϵͳÖУ¬rcÎļþ´æ·ÅλÖò»¾¡Ïàͬ£¬¿ÉÒÔÐÞ¸ÄʹϵͳÆô¶¯Ê±rsync
--daemon¼ÓÔؽøÈ¥¡£
5¡¢´Óclient¶Ë½øÐвâÊÔ
¡¡
¡¡ÏÂÃæÕâ¸öÃüÁîÐÐÖÐ-vzrtopgÀïµÄvÊÇverbose£¬zÊÇѹËõ£¬rÊÇrecursive£¬topg¶¼ÊDZ£³ÖÎļþÔ­ÓÐÊôÐÔÈçÊôÖ÷¡¢Ê±¼äµÄ²ÎÊý¡£
--progressÊÇÖ¸ÏÔʾ³öÏêϸµÄ½ø¶ÈÇé¿ö£¬--deleteÊÇÖ¸Èç¹û·þÎñÆ÷¶Ëɾ³ýÁËÕâÒ»Îļþ£¬ÄÇô¿Í»§¶ËÒ²ÏàÓ¦°ÑÎļþɾ³ý£¬±£³ÖÕæÕýµÄÒ»Ö¡£ºóÃæµÄ
[email=inburst@ip]inburst@ip[/email]
ÖУ¬inburstÊÇÖ¸¶¨ÃÜÂëÎļþÖеÄÓû§Ãû£¬Ö®ºóµÄ::inburstÕâÒ»inburstÊÇÄ£¿éÃû£¬Ò²¾ÍÊÇÔÚ/etc/rsyncd.confÖÐ×Ô¶¨ÒåµÄÃû³Æ¡£×îºóµÄ/tmpÊDZ¸·Ýµ½±¾µØµÄĿ¼Ãû¡£
¡¡¡¡ÔÚÕâÀïÃ棬»¹¿ÉÒÔÓÃ-e
sshµÄ²ÎÊý½¨Á¢Æð¼ÓÃܵÄÁ¬½Ó¡£¿ÉÒÔÓÃ--password-file=/password/path/fileÀ´Ö¸¶¨ÃÜÂëÎļþ£¬ÕâÑù¾Í¿ÉÒÔÔڽű¾ÖÐʹÓöøÎÞÐè½»»¥Ê½µØÊäÈëÑéÖ¤ÃÜÂëÁË£¬ÕâÀïÐèҪעÒâµÄÊÇÕâ·ÝÃÜÂëÎļþȨÏÞÊôÐÔÒªÉèµÃÖ»ÓÐÊôÖ÷¿É¶Á¡£
bash-2.03#
rsync -vzrtopg --progress --delete inburst@192.168.168.52::inburst
/tmp/
Password:
receiving file list ...
done
./
1
785 (100%)
1.py
4086
(100%)
2.py
10680 (100%)
a
0
(100%)
ip
3956 (100%)
./
wrote 190 bytes read 5499
bytes 758.53 bytes/sec
total size is 19507 speedup is
3.43
6¡¢´´½¨¸üнű¾
Èç¹ûÓбȽϸ´ÔӵŤ×÷£¬ÀûÓÃһЩ³£¼ûµÄ½Å±¾ÓïÑÔ¿ÉÒÔÓаïÖú¡£±ÈÈ磺
bash-2.03#
cat /usr/local/bin/rsync.sh
#!/bin/sh
DATE=`date
+%w`
rsync -vzrtopg --progress --delete
inburst@192.168.168.52::inburst /home/quack/backup/$DATE
--password-file=/etc/rsync.pass >
/var/log/rsync.$DATE
7¡¢ÐÞ¸Ä/etc/crontab×öºÃ¶¨Ê±
±ÈÈç:
bash-2.03#
echo "15 4 * * 6 root
rsync.sh">>/etc/crontab
Èý¡¢FAQ
Q£ºÈçºÎͨ¹ýssh½øÐÐrsync£¬¶øÇÒÎÞÐëÊäÈëÃÜÂ룿
A£º¿ÉÒÔͨ¹ýÒÔϼ¸¸ö²½Öè
1.
ͨ¹ýssh-keygenÔÚserver AÉϽ¨Á¢SSH keys£¬²»ÒªÖ¸¶¨ÃÜÂ룬Äã»áÔÚ~/.sshÏ¿´µ½identityºÍidentity.pubÎļþ
2. ÔÚserver BÉϵÄhomeĿ¼½¨Á¢×ÓĿ¼.ssh
3. ½«AµÄidentity.pub¿½±´µ½server
BÉÏ
4. ½«identity.pub¼Óµ½~[user b]/.ssh/authorized_keys
5. ÓÚÊÇserver
AÉϵÄAÓû§£¬¿Éͨ¹ýÏÂÃæÃüÁîÒÔÓû§B sshµ½server BÉÏÁË
e.g. ssh -l userB
serverB
ÕâÑù¾Íʹserver AÉϵÄÓû§A¾Í¿ÉÒÔsshÒÔÓû§BµÄÉí·ÝÎÞÐèÃÜÂëµÇ½µ½server
BÉÏÁË¡£
Q£ºÈçºÎͨ¹ýÔÚ²»Î£º¦°²È«µÄÇé¿öÏÂͨ¹ý·À»ðǽʹÓÃrsync?
A£º½â´ðÈçÏ£º
Õâͨ³£ÓÐÁ½ÖÖÇé¿ö£¬Ò»ÖÖÊÇ·þÎñÆ÷ÔÚ·À»ðǽÄÚ£¬Ò»ÖÖÊÇ·þÎñÆ÷ÔÚ·À»ðǽÍâ¡£
ÎÞÂÛÄÄÖÖÇé¿ö£¬Í¨³£»¹ÊÇʹÓÃssh£¬Õâʱ×îºÃн¨Ò»¸ö±¸·ÝÓû§£¬²¢ÇÒÅäÖÃsshd½öÔÊÐíÕâ¸öÓû§Í¨¹ýRSAÈÏÖ¤·½Ê½½øÈë¡£
Èç¹û·þÎñÆ÷ÔÚ·À»ðǽÄÚ£¬Ôò×îºÃÏÞ¶¨¿Í»§¶ËµÄIPµØÖ·£¬¾Ü¾øÆäËüËùÓÐÁ¬½Ó¡£
Èç¹û¿Í»§»úÔÚ·À»ðǽÄÚ£¬Ôò¿ÉÒÔ¼òµ¥ÔÊÐí·À»ðǽ´ò¿ªTCP¶Ë¿Ú22µÄsshÍâ·¢Á¬½Ó¾ÍokÁË¡£
Q£ºÎÒÄܽ«¸ü¸Ä¹ý»òÕßɾ³ýµÄÎļþÒ²±¸·ÝÉÏÀ´Âð£¿
A£ºµ±È»¿ÉÒÔ£º
Äã¿ÉÒÔʹÓÃÈ磺rsync
-other -options -backupdir = ./backup-2000-2-13
...ÕâÑùµÄÃüÁîÀ´ÊµÏÖ¡£
ÕâÑùÈç¹ûÔ´Îļþ:/path/to/some/file.c¸Ä±äÁË£¬ÄÇô¾ÉµÄÎļþ¾Í»á±»ÒƵ½./backup-2000-2-13/path/to/some/file.c£¬ÕâÀïÕâ¸öĿ¼ÐèÒª×Ô¼º
ÊÖ¹¤½¨Á¢ÆðÀ´
Q£ºÎÒÐèÒªÔÚ·À»ðǽÉÏ¿ª·ÅÄÄЩ¶Ë¿ÚÒÔÊÊÓ¦rsync£¿
A£ºÊÓÇé¿ö¶ø¶¨
rsync¿ÉÒÔÖ±½Óͨ¹ý873¶Ë¿ÚµÄtcpÁ¬½Ó´«Îļþ£¬Ò²¿ÉÒÔͨ¹ý22¶Ë¿ÚµÄsshÀ´½øÐÐÎļþ´«µÝ£¬µ«ÄãÒ²¿ÉÒÔͨ¹ýÏÂÁÐÃüÁî¸Ä±äËüµÄ¶Ë¿Ú£º
rsync
--port 8730 otherhost::
»òÕß
rsync -e 'ssh -p 2002'
otherhost:
Q£ºÎÒÈçºÎͨ¹ýrsyncÖ»¸´ÖÆĿ¼½á¹¹£¬ºöÂÔµôÎļþÄØ£¿
A£ºrsync -av
--include '*/' --exclude '*' source-dir
dest-dir
Q£ºÎªÊ²Ã´ÎÒ×Ü»á³öÏÖ"Read-only file
system"µÄ´íÎóÄØ£¿
A£º¿´¿´ÊÇ·ñÍüÁËÉè"read only = no"ÁË
Q£ºÎªÊ²Ã´ÎÒ»á³öÏÖ'@ERROR:
invalid
gid'µÄ´íÎóÄØ£¿
A£ºrsyncʹÓÃʱĬÈÏÊÇÓÃuid=nobody;gid=nobodyÀ´ÔËÐеģ¬Èç¹ûÄãµÄϵͳ²»´æÔÚnobody×éµÄ»°£¬¾Í»á³öÏÖÕâÑùµÄ´íÎ󣬿ÉÒÔÊÔÊÔgid
=
nogroup»òÕßÆäËü
Q£º°ó¶¨¶Ë¿Ú873ʧ°ÜÊÇÔõô»ØÊ£¿
A£ºÈç¹ûÄã²»ÊÇÒÔrootȨÏÞÔËÐÐÕâÒ»ÊØ»¤½ø³ÌµÄ»°£¬ÒòΪ1024¶Ë¿ÚÒÔÏÂÊÇÌØȨ¶Ë¿Ú£¬»á³öÏÖÕâÑùµÄ´íÎó¡£Äã¿ÉÒÔÓÃ--port²ÎÊýÀ´¸Ä±ä¡£
Q£ºÎªÊ²Ã´ÎÒÈÏ֤ʧ°Ü£¿
A£º´ÓÄãµÄÃüÁîÐп´À´£º
ÄãÓõÄÊÇ£º
>
bash$ rsync -a 144.16.251.213::test test
> Password:
>
@ERROR: auth failed on module test
>
> I dont understand
this. Can somebody explain as to how to acomplish this.
> All
suggestions are welcome.
Ó¦¸ÃÊÇûÓÐÒÔÄãµÄÓû§ÃûµÇ½µ¼ÖµÄÎÊÌ⣬ÊÔÊÔrsync -a
max@144.16.251.213::test
test
ËÄ¡¢Ò»Ð©¿É½è¼øµÄ½Å±¾
ÕâÀïÕâЩ½Å±¾¶¼ÊÇrsyncÍøÕ¾ÉϵÄÀý×Ó£º
1¡¢Ã¿¸ôÆßÌ콫Êý¾ÝÍùÖÐÐÄ·þÎñÆ÷×öÔöÁ¿±¸·Ý
#!/bin/sh
#
This script does personal backups to a rsync backup server. You will end
up
# with a 7 day rotating incremental backup. The incrementals will
go
# into subdirectories named after the day of the week, and the
current
# full backup goes into a directory called "current"
#
tridge@linuxcare.com
# directory to
backup
BDIR=/home/$USER
# excludes file - this contains a
wildcard pattern per line of files to
exclude
EXCLUDES=$HOME/cron/excludes
# the name of the
backup machine
BSERVER=owl
# your password on the backup
server
export
RSYNC_PASSWORD=XXXXXX
########################################################################
BACKUPDIR=`date
+%A`
OPTS="--force --ignore-errors --delete-excluded
--exclude-from=$EXCLUDES
--delete --backup --backup-dir=/$BACKUPDIR
-a"
export
PATH=$PATH:/bin:/usr/bin:/usr/local/bin
# the following line
clears the last weeks incremental directory
[ -d $HOME/emptydir ] ||
mkdir $HOME/emptydir
rsync --delete -a $HOME/emptydir/
$BSERVER::$USER/$BACKUPDIR/
rmdir $HOME/emptydir
# now the
actual transfer
rsync $OPTS $BDIR
$BSERVER::$USER/current
2¡¢±¸·ÝÖÁÒ»¸ö¿ÕÏеÄÓ²ÅÌ
#!/bin/sh
export
PATH=/usr/local/bin:/usr/bin:/bin
LIST="rootfs usr data
data2"
for d in $LIST; do
mount /backup/$d
rsync
-ax --exclude fstab --delete /$d/ /backup/$d/
umount
/backup/$d
done
DAY=`date "+%A"`
rsync -a
--delete /usr/local/apache /data2/backups/$DAY
rsync -a --delete
/data/solid
/data2/backups/$DAY
3¡¢¶Ôvger.rutgers.eduµÄcvsÊ÷½øÐоµÏñ
#!/bin/bash
cd
/var/www/cvs/vger/
PATH=/usr/local/bin:/usr/freeware/bin:/usr/bin:/bin
RUN=`lps
x | grep rsync | grep -v grep | wc -l`
if [ "$RUN" -gt 0 ];
then
echo already running
exit 1
fi
rsync
-az vger.rutgers.edu::cvs/CVSROOT/ChangeLog
$HOME/ChangeLog
sum1=`sum $HOME/ChangeLog`
sum2=`sum
/var/www/cvs/vger/CVSROOT/ChangeLog`
if [ "$sum1" = "$sum2" ];
then
echo nothing to do
exit 0
fi
rsync -az
--delete --force vger.rutgers.edu::cvs/ /var/www/cvs/vger/
exit
0
4¡¢ÀûÓÃfindµÄÒ»ÖÖÇÉÃʽ
rsync -avR remote:'`find /home
-name "*.[ch]"`'
/tmp/
¿ÉÒÔÓÃÕâÖÖ·½·¨ÁгöÐèÒª±¸·ÝµÄÎļþÁÐ±í¡ª¡ªÕâÖÖ·½·¨Ëƺõ±È½ÏÉÙÈËÓõ½¡£
Îå¡¢²Î¿¼×ÊÁÏ£º
1¡¢
http://rsync.samba.org/
2¡¢rsync examples
3¡¢rsync FAQ
               
ÎÄÕ¼È룺a    ÔðÈα༭£ºa 
  • ÉÏһƪÎÄÕ£º

  • ÏÂһƪÎÄÕ£º
  • ¡¾·¢±íÆÀÂÛ¡¿¡¾¼ÓÈëÊղء¿¡¾¸æËߺÃÓÑ¡¿¡¾´òÓ¡´ËÎÄ¡¿¡¾¹Ø±Õ´°¿Ú¡¿
    ÍøÓÑÆÀÂÛ£º£¨Ö»ÏÔʾ×îÐÂ10Ìõ¡£ÆÀÂÛÄÚÈÝÖ»´ú±íÍøÓѹ۵㣬Óë±¾Õ¾Á¢³¡Î޹أ¡£©
    ¹ØÓÚÎÒÃÇ | RAIDÊý¾Ý»Ö¸´ | ÓÑÇéÁ´½Ó | RSSÉú³É | XMLÉú³É | ÎÄÕÂHTMLµØͼ | ÏÂÔØHTMLµØͼ

    °æȨËùÓÐ ±±ÑÇÊý¾Ý»Ö¸´ÖÐÐÄ
    È«¹úͳһ¿Í·þµç»°:4006-505-808
    ±±¾©Êк£µíÇøÓÀ·á»ùµØ·á»ÛÖз7ºÅвÄÁÏ´´Òµ´óÏÃB×ù205ÊÒ
    ¾©ICP±¸05011939
    rÍwe