软件包安装
# sudo apt-get install rsync 注:在debian、ubuntu 等在线安装方法;
# yum install rsync 注:Fedora、Redhat 等在线安装方法;
# rpm -ivh rsync 注:Fedora、Redhat 等rpm包安装方法;
配置
/etc/rsyncd.conf
uid = root
gid = root
use chroot = yes
max connections = 4
pid file = /var/run/rsyncd.pid
port 873
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
# dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
# [ftp]
# path = /home/ftp
# comment = ftp export area
[AAA]
path = /xx/xx/xxxxxxx/
comment = rsync files ## 注释
ignore errors ##忽略IO
read only = no
list = yes
auth users = rsync
secrets file = /etc/rsync.passwd
[BBB]
path = /xx/xx/xxxx/
comment = rsync files ## 注轇~J
ignore errors ##忽潕¥IO
read only = no
list = yes
auth users = rsync
secrets file = /etc/rsync.passwd
密码
/etc/rsync.passwd
格式 账号:密码
chown root.root rsync.passwd
chmod 600 rsync.passwd
启动rsync服务器相当简单,有以下几种方法
A、--daemon参数方式,是让rsync以服务器模式运行
#/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf #--config用于指定rsyncd.conf的位置,如果在/etc下可以不写
B、xinetd方式
修改services加入如下内容
# nano -w /etc/services
rsync 873/tcp # rsync
rsync 873/udp # rsync
这一步一般可以不做,通常都有这两行(我的RHEL4和GENTOO默认都有)。修改的目的是让系统知道873端口对应的服务名为rsync。如没有的话就自行加入。
设定 /etc/xinetd.d/rsync, 简单例子如下:
# default: off
# description: The rsync server is a good addition to am ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
上述, 主要是要打开rsync這個daemon, 一旦有rsync client要连接時, xinetd会把它转介給 rsyncd(port 873)。然后service xinetd restart, 使上述设定生效.
最后添加防火墙的端口就部署完毕了