IT��ά������������ҵ��ֵ��
�й�IT��ά����ҳ | ��Ѷ���� | ��ά���� | ��Ϣ��ȫ | CIO�ӽ� | �Ƽ��� | ��Ѱ��� | ��ά��Դ | ר��߻� | ֪ʶ�� | ��̳

Rsync+SSH---Server�Զ���ر�Ԯ����

2005��11��27��
/

һ.ǰ��

�Դ�911�¼�֮��...��ر�Ԯ������ƾͳ���������...�����������ٿ������������... �պ������Ϊ����Ҫ...���ò��о��������...˳�㿴����Ҷ�������ʵ����ر�Ԯ��..�����Ǹ��˵�һ����ĵ�...

�����Ҫ�ֳ���������...���� Trusted SSH Authorized...Rsync...Crontab....���Ҳ��۴����ٶ�Ϊ��...�Լ���ʱ�����ر�Ԯ...����������SolutionsӦ�ÿ�������һ���˵������...

��.׼��

����ϵͳ: Red Hat Linux 7.3 to Red Hat 7.3 ...Local ����Ҫ���� Rsync...�׼�openssh-3.4p1-1

** ����: A (10.0.0.1) Ҫ�� B (192.168.0.1) ����ر�Ԯ
PS:��ɫ��λҪ��ȷ...��Ȼ��Ҫ�۵�������Ҳ��...

�ο���վ :

��.��ʼʵ��

1.��ɵ���Trusted SSH Authorized�s
��Ҫ A (10.0.0.1) Ҫ�� B (192.168.0.1) ����ر�Ԯ ...��������� A ����ʹ��SSH?
B�� B ʱ...����Ҫ��������...User �� Root...SSH Version2�İ汾..����Ҫ����A(10.0.0.1)����public/private dsa key pair..

[root@mondeo home]# cd /root/.ssh/
[root@mondeo .ssh]# ssh-keygen -d
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase): <-- �˴�����passphrase..�´βŲ���ѯ��password
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
11:22:33:44:55:66:77:88:99:00:11:22:33:44:55:66
[root@mondeo .ssh]#

��ʱ����ϵͳ�¿�����������...id_dsa��id_dsa.pub ����Ҫ��id_dsa.pub����192.168.0.1 ���Ҹ���Ϊ authorized_keys2

[root@mondeo .ssh]# scp id_dsa.pub 192.168.0.1:/root/.ssh/authorized_keys2
password:
id_dsa.pub 100% |*************************************************************
**************| 612 00:00
[root@mondeo .ssh]#
����������ִ��ssh 192.168.0.1 �����ܷ���������Ҫ��������...

2.ʹ��rsync ��Remote sync�s

rsync���Լ�� :
rsync��unix-likeϵͳ�µ����ݾ��񱸷ݹ��ߣ��������ϾͿ��Կ�������remote sync��
�����������£�

1�����Ծ��񱣴�����Ŀ¼�����ļ�ϵͳ��
2�����Ժ�������������ԭ���ļ���Ȩ�ޡ�ʱ��ȵȡ�
3����������Ȩ�޼��ɰ�װ��
4���Ż������̣��ļ�����Ч�ʸߡ�
5������ʹ��rcp��ssh�ȷ�ʽ�������ļ�����ȻҲ����ͨ��ֱ�ӵ�socket���ӡ�
6��֧���������䡣

����Ҫ�ȶ�B(192.168.0.1)��Rsync��Server on����...

[root@linux /]#chkconfig --list rsync
rsync off
[root@linux /]#chkconfig rsync on

����������A(10.0.0.1)�Ͻ�һ�� Backup directory...Ȼ���B(192.168.0.1)��mysql��
html��Ŀ¼����ر�Ԯ...żдһ���򵥵�script����:

[root@mondeo /]# mkdir backup
[root@mondeo backup]#vi sync

rsync -avlR --delete -e ssh 192.168.0.1:/var/lib/mysql /backup/
rsync -avlR --delete -e ssh 192.168.0.1:/var/www/html /backup/
[root@mondeo backup]#chmod 700 sync


�����������©s

-a, --archive
It is a quick way of saying you want recursion and want to preserve almost everything.
-v, --verbose
This option increases the amount of information you are given during the transfer.
-l, --links
When symlinks are encountered, recreate the symlink on the destination.
-R, --relative
Use relative paths. �������·��...�Ų�������Ŀ¼�� parent ����ͬһ��...
--delete
��ָ���Server��ɾ����һ�ļ����ǿͻ���Ҳ��Ӧ����һ�ļ�ɾ��������������һ�¡�
-e ssh
��������ܵ����ӡ�

������ʹ�����˶���...������man rsync��ʹ�ø���IJ���...

���Կ���:

[root@mondeo backup]# ./sync

receiving file list ... done...donewrote 16 bytes read 107 bytes 82.00
bytes/sectotal size is 0 speedup is 0.00receiving file list ...
done...donewrote 16 bytes read 921 bytes 624.67 bytes/sectotal size is
308331 speedup is 329.06[root@mondeo backup]#


����ûѯ������....�Լ��аѵ���copy������û���↪....��Ȼ����԰�Զ�̵����������䶯...���Ƿ�����ͬ����....

3.ʹ��crontab �����Զ��ų̣�

�������֮��...��ϣ��ÿ���0��0��...ҹ���˾���ʱ������������sync....��Ȼ����Ҫ����� sync ����������...

[root@mondeo backup]# crontab -e
0 0 * * * /backup/sync

���һ��..���Ǵ󹦸����...ԭ�������Ѿ߱��Զ�������ر�Ԯ��....�Ͻ�����̨���������԰�...


���������뵽��http://bbs.cnitom.com

����Ķ�

ͼ���ȵ�

��Щ��ҵ������Ҫϵͳ�߱�������չ����
��Щ��ҵ������Ҫϵͳ�߱�������չ�����ڴ�֮ǰ�������û�п��ǹ����IT������Ҫһ��������չ(Ҳ��������չ)ϵͳ������...
DB2 10�¹��ܣ���OracleǨ�Ƹ�����
DB2 10�¹��ܣ���OracleǨ�Ƹ������������һЩ�� �ֲ����� �˹�������PL/SQL��SQL PL����BEGINEND���ж���ֲ�����...

�����ȵ�