Rsync启动失败,使用不成功

[root@cxk ~]# systemctl status rsyncd
○ rsyncd.service - Rsync Daemon
     Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; preset: disa>
     Active: inactive (dead) since Tue 2025-05-27 01:51:26 CST; 39min ago
   Duration: 52ms
    Process: 1080 ExecStart=/usr/bin/rsync --daemon --config=/etc/rsyncd.conf (cod>
   Main PID: 1080 (code=exited, status=0/SUCCESS)
        CPU: 13ms


[root@cxk ~]# journalctl -u rsyncd.service --no-pager

5月 25 20:13:31 cxk.test.cn systemd[1]: Started Rsync Daemon.
5月 25 20:13:31 cxk.test.cn rsyncd[39977]: params.c:Parameter() - Ignoring badly formed line in config file: ignore errors
5月 25 20:13:31 cxk.test.cn rsyncd[39978]: rsyncd version 3.2.5 starting, listening on port 873
5月 25 20:13:31 cxk.test.cn rsyncd[39978]: sent 0 bytes  received 0 bytes  total size 0
5月 25 20:13:31 cxk.test.cn systemd[1]: rsyncd.service: Deactivated successfully.

当日志如上显示rsyncd 服务启动守护进程后秒停止,且查看systemctl status rsyncd时显示(dead)。可能是配置文件错误,2025-05-27 Centos Stream 9 以下配置文件和系统文件可用

[root@cxk ~]# cat /etc/rsyncd.conf  #配置文件
##rsyncd.conf start##
fake super =yes
uid = rsync
gid = rsync
use chroot = no
max connections = 2000
timeout = 600
pid file = /var/run/custom_rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
list = false
hosts allow = 192.168.206.0/24
#hosts deny = 0.0.0.0/32
####################################
[data]
comment = www by lyztest 
path = /data
ignore errors = yes
read only = no
auth users = rsync_backup
secrets file = /etc/rsync.password 

[backup]
comment = gather backups
path = /backup/
ignore errors = yes
read only = no
auth users = rsync_backup
secrets file = /etc/rsync.password

#系统文件
[root@cxk ~]# cat /usr/lib/systemd/system/rsyncd.service 
[Unit]
Description=Rsync Daemon
After=network.target

[Service]
Type=forking
# 启动 rsync 守护进程,加载配置文件 /etc/rsyncd.conf
ExecStart=/usr/bin/rsync --daemon --config=/etc/rsyncd.conf
PIDFile=/var/run/custom_rsyncd.pid
# 重启策略(可选)
Restart=on-failure

[Install]
WantedBy=multi-user.target

注意这里几点

#1.模块文件存在并且 与所属用户需与配置文件一致,用户有访问权限
[root@cxk ~]# ls -ld /data /backup/
drwxr-xr-x. 2 rsync rsync 22  5月 25 21:15 /backup/
drwxr-xr-x. 4 rsync rsync 32  5月 21 22:00 /data

#2.PID文件需要清除或者另外绑定一个新文件路径
[root@cxk ~]# rm -rf /var/run/custom_rsyncd.pid

#3.密码文件/etc/rsync.password要满足格式【 用户名:密码 】(例如 rsync_backup:123456)且权限仅允许root读写
[root@cxk ~]# ls -ld /etc/rsync.password 
-rw-------. 1 root root 19  5月 21 21:59 /etc/rsync.password
[root@cxk ~]# cat /etc/rsync.password 
rsync_backup:wdnmd

# 查看当前防火墙是否放行873端口(TCP)
[root@cxk ~]# firewall-cmd --list-ports | grep 873

# 如果未放行,添加永久规则(放行873端口的TCP连接)
[root@cxk ~]# firewall-cmd --permanent --add-port=873/tcp

# 重新加载防火墙规则使生效
[root@cxk ~]# firewall-cmd --reload

# 查看与rsync相关的SELinux布尔值 (我是给他全开了)
[root@cxk ~]# getsebool -a | grep rsync
postgresql_can_rsync --> on
rsync_anon_write --> on
rsync_client --> on
rsync_export_all_ro --> on
rsync_full_access --> on
rsync_sys_admin --> on

[root@cxk ~]# setsebool -P rsync_client on  # -P参数表示永久生效

验证测试并重启

#前台运行测试,如果成功了则不输出 且进程持续运行;如果仍有错误,终端会显示具体问题
[root@cxk ~]# rsync --daemon --no-detach --config=/etc/rsyncd.conf

#重启服务
[root@cxk ~]# systemctl daemon-reload
[root@cxk ~]# systemctl restart rsyncd
[root@cxk ~]# systemctl status rsyncd
● rsyncd.service - Rsync Daemon
     Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; preset: disa>
     Active: active (running) since Tue 2025-05-27 01:51:25 CST; 1h 1min ago
    Process: 1090 ExecStart=/usr/bin/rsync --daemon --config=/etc/rsyncd.conf (cod>
   Main PID: 1097 (rsync)
      Tasks: 1 (limit: 22768)
     Memory: 1.4M
        CPU: 100ms
     CGroup: /system.slice/rsyncd.service
             └─1097 /usr/bin/rsync --daemon --config=/etc/rsyncd.conf
#叔叔又夫妇

#测试正常使用
[root@cxk ~]# rsync -av /etc/hostname rsync_backup@192.168.206.130::backup
Password: 
sending incremental file list

sent 64 bytes  received 23 bytes  19.33 bytes/sec
total size is 9  speedup is 0.10

普通学生第一次尝试投稿,还请指正!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值