服务器
- 192.168.0.1:备份服务器
- 192.168.0.2:远程服务器
目的
将远程服务器数据同步到备份服务器
前提
两台服务器安装rsync(服务端、备份端)
yum install -y rsync
#启动rsync服务
systemctl start rsyncd.service
systemctl enable rsyncd.service
systemctl restart rsyncd.service
#检查是否已经成功启动
netstat -lnp|grep 873
#远程服务器(配置文件)(/etc/rsyncd.conf)
# /etc/rsyncd: configuration file for rsync daemon mode
# See rsyncd.conf man page for more options.
# configuration example:
# uid = nobody
# gid = nobody
# use chroot = yes
# max connections = 4
# pid file = /var/run/rsyncd.pid
# 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
uid = root
# //设置运行rsync 进程的用户
gid = root
use chroot = no
max connections = 4
# pid file = /var/run/rsyncd.pid
#//CentOS7中yum安装不需指定pid file 否则报错
lock file=/var/run/rsyncd.lock
log file = /var/log/rsyncd.log
# //此文件定义完成后系统会自动创建
exclude = lost+found/
transfer logging = yes
timeout = 900
ignore nonreadable = yes
# //同步时跳过没有权限的目录
dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
# //传输时不压缩的文件

本文详细介绍了如何配置rsync服务,包括在两台服务器上安装、启动服务,设置配置文件,以及创建密码文件。接着,展示了rsync命令的用法,包括同步规则、排除文件、定时任务等。在执行同步时遇到了权限问题,原因是SELinux未关闭,通过临时和永久关闭SELinux解决了问题。
最低0.47元/天 解锁文章
1528

被折叠的 条评论
为什么被折叠?



