rsync配置文件和命令参数详解

本文介绍如何从零开始配置rsync服务,包括创建必要的文件和目录、修改xinetd配置文件启用rsync服务、配置rsync服务的各项参数如认证、日志记录等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这几个文件默认不存在 需要自行创建 mkdir -p /etc/rsyncd 
touch rsyncd.conf 
touch rsyncd.secrets 
touch rsyncd.motd

# vi /etc/xinetd.d/rsync 
将如下代码 

service rsync 

disable = yes 
socket_type = stream 
wait = no 
user = root 
server = /usr/bin/rsync 
server_args = –daemon 
log_on_failure += USERID 

中的 disable = yes 改成 disable = no 

然后启动 xinetd 
# /etc/init.d/xinetd start 或 service xinetd restart 
注意:如果服务器上装有防火墙记得要打开端口,默认端口是873 

# telnet 127.0.0.1 873 
Trying 127.0.0.1... 
telnet: connect to address 127.0.0.1: Connection refused 
# iptables -A INPUT -s 192.168.0.0/255.255.255.0 -p tcp -m tcp --dport 873 -j ACCEPT 
# iptables -A INPUT -p tcp -m tcp --dport 873 -j DROP 
# vi /etc/rsyncd.conf (这个文件如果不存在自己创建) 

#Global Settings 
uid = root #以什么身份运行rsync 
gid = root 
use chroot = no #不使用chroot 
max connections = 20 #最大连接数 
secrets file = /etc/rsyncd.secrets #密码文件位置,认证文件设置,设置用户名和密码 
log file = /var/log/rsyncd.log #指定rsync的日志文件,而不将日志发送给syslog 
pid file = /var/run/rsyncd.pid #指定rsync的pid文件 
lock file = /var/run/rsync.lock #指定支持max connections参数的锁文件,默认值是/var/run/rsyncd.lock 
comment = hello world 
#motd file = /etc/rsyncd.motd #欢迎信息文件名称和存放位置(此文件没有,可以自行添加) 

[backup] # 这里是认证的模块名,在client端需要指定 
path = /titan24/www/repos # 需要做镜像的目录 
auth users = rsync # 授权帐号。认证的用户名,如果没有这行,则表明是匿名,多个用户用,分隔 
read only = no # yes只读 值为NO意思为可读可写模式,数据恢复用NO 
hosts allow = 192.168.3.128 #允许访问的服务器IP 
hosts deny = * #黑名单 
list = true # 允许列文件 
#ignore errors # 可以忽略一些无关的IO错误 
#exclude = cache/111/ cache/222/ #忽略的目录

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值