rsyncd基本配置
蒜香大龙虾
2024-08-08 01:32:40
Categories:
Tags:
rsync服务端
安装
1
| yum install rsync rsync-daemon -y
|
修改配置文件
修改默认配置文件路径为/etc/rsyncd.conf
1 2 3
| cat > /etc/sysconfig/rsyncd << EOF OPTIONS="/etc/rsyncd.conf" EOF
|
修改/etc/rsyncd.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| # 进程 pid 文件所在位置 pid file = /var/run/rsyncd.pid # 监听端口,默认是873,可省 # port = 873 # 监听的IP地址可省 # address = 172.20.20.11
# 守护进程所属的uid,默认nobody uid = root # 守护进程的gid,默认同上 gid = root
# 改根 use chroot = no
# 只读 read only = yes # 只写 write only = no
# 允许访问的IP,空格隔开 hosts allow = 172.20.20.0/255.255.255.0 172.20.20.1 192.168.0.1
# 客户端最多连接数 max connections = 5
# 登录显示的欢迎信息,可省 # motd file = /etc/rsyncd/rsyncd.motd
# 日志路径 log file = /var/log/rsync.log # 记录传输文件的日志 transfer logging = yes # 日志格式 log format = %t %a %m %f %b # 日志级别 syslog facility = local3
# 超时单位为秒钟,默认值0为无限 timeout = 300
# dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 # 这里是man文档原话翻译: # NOTE:此参数目前没有任何效果,除了它被设置为“*“,那么它将最小化或禁用所有文件的压缩
[repo] path=/opt/repo
|
启动和放行防火墙
如果开启selinux需要修改上下文,否则同步失败
1 2
| semanage fcontext -a -t rsync_var_run_t "/opt/repo(/.*)?" restorecon -Rv /opt/repo
|
启动
1 2 3
| systemctl enable --now rsyncd firewall-cmd --add-port=873/tcp firewall-cmd --add-port=873/tcp --per
|