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
