实现功能:当用户在本地客户端某目录内建立、修改、删除目录或文件、修改目录或文件的属性,只要执行相同的shell脚本,rsync就会自动找出有改动或删除的数据,将其传送到服务器上,使服务器端某目录内的数据跟本地客户端某目录内的数据保持一致。

  ★方式一:

  一、服务器端(例:10.0.0.1*):
  1、创建用户和组

groupadd www -g 48
useradd -u 48 -g www www
mkdir -p /opt/htdocs
chmod +w /opt/htdocs
chown www:www /opt/htdocs


  2、编辑rsync的配置文件
vi /etc/rsyncd.conf

  输入以下内容:
引用
uid=www
gid=www
max connections=10
use chroot=no
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock

[zhangyan]
path=/opt/htdocs
comment = my htdocs
ignore errors
read only = no
hosts allow=10.0.0.21 10.0.0.22


  3、启动rsync服务器端
/usr/bin/rsync --daemon


  二、客户端(例:10.0.0.21和10.0.0.22):
  1、创建一个shell脚本push.sh
vi push.sh

  输入以下内容(10.0.0.1*为要推送到的目标服务器,zhangyan为服务器端rsyncd.conf配置文件中的模块名):
引用
#!/bin/sh
/usr/bin/rsync -vzrtopg --delete $1 10.0.0.10::zhangyan/
/usr/bin/rsync -vzrtopg --delete $1 10.0.0.11::zhangyan/
/usr/bin/rsync -vzrtopg --delete $1 10.0.0.16::zhangyan/
/usr/bin/rsync -vzrtopg --delete $1 10.0.0.19::zhangyan/
  注:因为是内部局域网之间传输,这里没有设置密码。

  2、赋予push.sh执行权限
chmod +x ./push.sh


  3、同步推送客户端某个目录中(例:/home/zhanguan/abc)的文件到服务器端的/opt/htdocs目录:
./push.sh /home/zhanguan/abc/

  注意:不要忘了abc后面的/。如果更改的文件太大,可以在上面语句的末尾加上空格和&号,推到后台执行。例:
./push.sh /home/zhanguan/abc/ &



  ★方式二:

  一、服务器端(例:10.0.0.1*):
  1、创建用户和组
groupadd www -g 48
useradd -u 48 -g www www
mkdir -p /opt/htdocs
chmod +w /opt/htdocs
chown www:www /opt/htdocs
passwd www
  为www用户设置一个密码。

  二、客户端:
  1、同步推送客户端某个目录中(例:/home/zhanguan/abc)的文件到服务器端的/opt/htdocs目录:
/usr/bin/rsync -vzrtopg --delete /home/zhanguan/abc/ -e ssh www@10.0.0.10:/opt/htdocs/
  输入密码,回车即可,无须服务器端启动rsync服务。




技术大类 » 其他Unix技术 | 评论(40) | 引用(0) | 阅读(51840)
Aimeko
2007-7-21 09:45
请问 windows2003 下能使用此软件2台机器互相同步数据么?
如何操作呢?
张宴 回复于 2007-7-21 23:49
rsync有winodws版本,可以实现在Windows2003下的同步备份。
jchen
2011-6-13 10:30
请问rsync如何限速,如果大文件同步会导致同步期间带宽被占用完,按网上说的用参数--bwlimit来限速,但是测试了下貌似没什么效果。
louis vuitton uk Email Homepage
2011-11-23 08:46
This louis vuitton uk for sale belongs to the sounding just what are termed as Louis Vuitton vintage best sellers, many other products and services for the reason that range appearing companies.You will easily notice the unfold zippers of this coach outlet store online. That is the decoration. There are some inside pockets for you as well. They are easy to match your clothes and to carry.Let us inspire your inner beauty with fine christian louboutin sale. Purse the elegance in bridal wedding. Enjoy the fashion.
Anney幸福
2012-4-6 10:15
请问rsync可以用在windows server 2008 上吗
Anney幸福
2012-4-6 10:16
请问 rsync可以用在windows server 2008上吗
tai5rsengh2 Email Homepage
2012-4-7 05:33
情人网,表现支撑楼猪一下,女子学院一夜情。。。
瑜珈九玩偶 Email Homepage
2012-4-7 19:28
coach factory outlet Email Homepage
2012-5-17 10:49
Today, following half a century, mentor leather-bases coach factory outlet continues to be the delicate craft of leather-based master is accountable for,Would you like to meet more friends, or go with the times? If yes, coach factory online is opening welcome doors to you.in the market you definitely can find various colorways that are designed in as well as the high quality that applied in. For most of you would like to come. So just come to our coach factory outlet online store to choose one.
louis vuitton sale Email Homepage
2012-5-17 10:50
Louis Vuitton belt at louis vuitton sale is one kind of fashion accessory with high cost performance among the Louis Vuitton accessories.Offering quality LV products with favorable prices, louis vuitton outlet store is at your service. Hurry up, or you can not seize the chance.in fact, louis vuitton is one of the most famous fashion design master.he opened the fist suitcase shop called after his name.
coach outlet online Email Homepage
2012-5-17 10:50
I heard of coach outlet online through the advertisement when I was shopping. And now I often brow the webpage and buy Coach bags online.It is a symbol regarding position not to mention nature.Here I would like to launch a excellent bags pertaining to business men.Which may be coach outlet store.coach outlet has always been simple,durable style features to win consumers.The products are more flexible,with easy bleaching,wear characteristics,and simply use a damp cloth.
coach outlet, Email Homepage
2012-5-17 10:50
Remember the coach outlet provide coach bags which won't be deteriorated into its overall styles by any means. It will maintain its looks, colors, and uniqueness for long time.coach outlet store online has been voted by Hour Detroit magazine readers as the Best of Detroit in their 12th annual readers'poll.Lots of women like which usually amount normally include a coach outlet online ,it provides coziness to many girls that don't even think it is a great bushel of great interest directly to them.
xujie777 Email
2012-5-18 16:00
We aim to make all our customers satisfy with our products. You will find a variety of Men's fashion louis vuitton uk, fashion Women's cheap Louis Vuitton bags in our store at affordable price.Thinking of interesting ways to cost a milestone birthday? louis vuitton online shop had one of the most distinctive distinctive celebrations.bakery along with living room operated by means of about three moment louis vuitton online Most effective Pastry Chef’s of the year Rammy Nominee Chef’s.
xujie777 Email
2012-5-18 16:00
The choices are likely to be basically countless seeing that louis vuitton outlet occurs with the help of completely new and also incredible concepts once in a while.Louis vuitton Wholesale Monogram Canvas HandbagsLouis Vuitton Collection Beach Handbags louis vuitton bags outlet Damier Canvas HandbagsLouis vuitton Mahina HandbagsLouis Vuitton Monogram Mini Lin HandbagsLouis Vuitton Monogram Multicolore HandbagsLouis vuitton Monogram Vernis HandbagsLouis Vuitton Wholesale Epi Leather HandbagsLouis Vuitton For Men HandbagsLouis Vuitton Damier Canvas WalletsLouis Vuitton Epi Leather WalletsLouis Vuitton Monogram Canvas WalletsLouis Vuitton Monogram Vernis WalleLouis Vuitton ShoesLouis Vuitton Men wallets.As the Authentic Louis Vuitton are so high-priced, so came the louis vuitton handbags outlet.
xujie777 Email
2012-5-18 16:01
coach outlet has become a popular shopping experience for consumers around the world, and a desirable distribution channel for manufacturer's and retailers.Getting your hands on coach outlet store online can be a hefty investment of hundreds of dollars.But do not despair,the Coach Outlet store could be the answer to your prayers.coach outlet online is your smart choice when you want to get the discount Coach accessory. You can find the exact Coach Bags and other accessory you want at a low price that's right for you. My dear friends, let the coach outlet online pave your way into the world of high fashion with their ultimate fashion factory.
xujie123
2012-5-21 11:02
Our online store offers you discounted Designer louis vuitton replica wallet at present. You could find them in desirable quality and price. If you don't mind high class louis vuitton uk, have a good time here.louis vuitton Store Online Handbags can also bring great accuracy as well as practical applicability and fashionable.Have you ever dreamed of being as charming as Madonna? Have you ever thought of becoming an envy of all your friends? If so, come to louis vuitton outlet.<br/>
xujie555
2012-5-21 13:24
coach factory outlet uses graceful accessories to match the classical logo of coach, which is the best combination of coach. The handmade coach products?can make you more charming and graceful.coach factory online provides people many coach goods. If you wish to snatch the coach handbag, then this best method is made for that you like for coach discount.coach factory outlet online is a fashion brand to ensure its quality. With designer coach shoulder bags, you will always attract people's attention. The bags will emphasize your personal style and taste.<br/>
xujie333
2012-5-21 14:46
coach outlet online Store guarantee that all the coach handbags offered are own high quality. In addition , all of them are sold at an unexpected low price.If you want to purchase, just visit their website.coach factory outlet is really sizzling kinds of shopping way for you. With the usage of the replica designer coach bags, you can surely be able to change your individual looks in a stunning manner.Coach bags on sale from the coach outlet are cheap or discount prices that you certainly will stand out from the crowd on your next camping trip!<br/>
cheaperoakleysunglasses Email Homepage
2012-6-30 09:30
If you are not a movement, but would like a pair of sunglasses that will capture others attention, discount oakley sunglasses is still option is ideal for you. You like sports style was low-key and vintage look, if I decide to buy oakley sunglasses will give you every option in the Sun. Once you know that Oakley Active Sunglasses protect you from the Sun's glare, you can style and fashion--you decide, it is at the top of Oakley Asian Fit Sunglasses in this market.
分页: 1/2 第一页 1 2 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]