手机版
你好,游客 登录 注册
背景:
阅读新闻

Ubuntu Server下rsync同步文件的安装笔记

[日期:2013-04-15] 来源:Linux社区  作者:nighty [字体:大 中 小]

3. 创建 /etc/rsyncd.secrets文件,内容为: rsync:123 表示rsync这个用户的密码是123 然后修改文件的权限 chmod 600 /etc/rsyncd.secrets

4. rsync server做为守护进程
vi /etc/default/rsync
可以看到开头处这样声明:
------------------------------------

# start rsync in daemon mode from init.d script?
# only allowed values are "true", "false", and "inetd"
# Use "inetd" if you want to start the rsyncd from inetd,
# all this does is prevent the init.d script from printing a message
# about not starting rsyncd (you still need to modify inetd's config yourself).
RSYNC_ENABLE=inetd
-------------------------------------------
做为守护进程,可以设置为true或是xinetd方式来启动。于是我们安装inetd sudo apt-get install xinetd
安装好后配置inetd的配置文件 vi /etc/xinetd.d/rsync ,输入如下内容:
---------------------------------------------------

service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
-------------------------------------------------------
然后启动xinetd,/etc/init.d/xinetd restart,A服务器的rsyncd server就完成了!

5. B服务器由于是client,不需要配置,也不需要安装xinetd,直接可以通过命令行执行

rsync --delete -azvv rsync@192.168.1.111::share /var/www/pub/
这个命令就可以直接连接到192.168.111的rsync账户,它会提示你输入密码,就是A中的secrets文件中的密码,然后同步share模块到本机的/var/www/pub目录,你可以事前在A机器上创建一个文件如test.txt,随便写点内容,然后执行些命令,看是不是B上多了这样一个文件?如果是,则表示已经连接成功。你接下来就可以做crontab了!

更多Ubuntu相关信息见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款