创建rsyncd服务的配置文件
touch
/etc/rsyncd
.conf
//
主配置文件
touch
/etc/rsyncd
.secrets
//
用户名密码文件
chmod
600
/etc/rsyncd
.secrets
//rsyncd
服务的密码文件权限必须是600
|
编辑主配置文件 rsyncd.conf
uid = root
gid = root
use chroot =
yes
//chroot
为
yes
时必须使用root权限,且不能备份path路径外的链接文件
read
only = no
//
只读
write only = no
//
只写
max connections = 5
//
客户端最大连接数
log
file
=
/var/log/rsyncd
.log
//
指定
rsync
发送消息日志文件
log
format
= %t %a %m %f %b
//
日志文件格式
timeout = 300
//
连接超时时间
[
test
] //自定义模块名称
path=
/soft
//
需要同步的目录
list=
yes
//
是否允许列出模块里的内容
ignore errors
auth
users
= userID
//
模块验证用户名称
secrets
file
=
/etc/rsyncd/rsyncd
.secrets
//
模块验证密码文件 可放在全局配置里
|
设定rsyncd为独立的守护进程并配置rsyncd.secrets
vim
/etc/rsyncd
.secrets
//
配置密码文件
echo
test
:IP >>
/etc/rsyncd
.secrets
/usr/bin/rsync
--daemon
echo
"rsync –daemon"
>>
/etc/rc
.
local
//
添加到自启动文件
|
为了保证开机时自动启动,需要手动加上面的命令(/usr/bin/rsync --daemon --config=/etc/rsyncd.conf)加入 /etc/rc.local 文件中
如果服务器开启了防火墙,必须保证端口能穿过防火墙
vim
/etc/sysconfig/iptables
开放873端口
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 873 -j ACCEPT
|
客户端执行rsync命令测试配置是否成功
IP限制方式:
rsyncd.conf配置
uid = root
gid = root
use chroot = no
read
only = no
write only = no
max connections = 5
log
file
=
/var/log/rsync
.log
log
format
= %t %a %m %f %b
syslog facility = local3
timeout = 300
[
test
]
hosts allow = 允许连接的IP
hosts deny = *
path =
/soft
list=
yes
ignore errors
|
以daemon方式启动
/usr/bin/rsync
--daemon --config=
/etc/rsyncd
.conf
|
客户端执行rsync命令测试配置是否成功