所需环境
两台机器,一台服务端,一台客户端
服务器安装配置
安装rsync
检查是否安装,若无则安装rpm -qa rsyncyum -y install rsync
vim /etc/rsyncd.conf
修改以下内容:
uid = rsync
gid = rsync
use chroot = no
max connections = 4
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors //忽略错误
read only = false
list = false
hosts allow = 192.168.1.11/24 //允许的地址
hosts deny = 0.0.0.0/32 //拒绝的地址
auth users = rsync_backup // 推拉文件时的虚拟用户
secrets file = /etc/rsync.password //密码文件
[backup] //模块名,可以写多个
comment = “backup dir by oldboy”
path = /backup //存放文件的目录(共享目录)
权限配置
mkdir -p backup
useradd -s /sbin/nologin -M rsync
chown -R rsync.rsync backup
echo “rsync_backup:123123” >/etc/rsync.password
chmod 600 /etc/rsync.password
cat /etc/rsync.password
“rsync_backup:123123”
启动并查看端口
rsync --daemon
netstat -anput | grep rsync
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2581/rsync
tcp6 0 0 :::873 :::* LISTEN 2581/rsync
客户端安装配置
安装rsync
检查是否安装,若无则安装rpm -qa rsyncyum -y install rsync
echo '123132' > /etc/rsyncd.password
cat /etc/rsyncd.password
123132
启动并查看端口
rsync --daemon
netstat -anput | grep rsync
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2878/rsync
tcp6 0 0 :::873 :::* LISTEN 2878/rsync
验证
touch /123.txt
rsync -av /123.txt 192.168.1.11:/root/
root@192.168.1.11's password:
sending incremental file list
123.txt
传输完成在服务器查看:
出现123.txt文件怎证明成功。
mkdir -p backup
useradd -s /sbin/nologin -M rsync
chown -R rsync.rsync backup
echo “rsync_backup:123123” >/etc/rsync.password
chmod 600 /etc/rsync.password
cat /etc/rsync.password
“rsync_backup:123123”
rsync --daemon
netstat -anput | grep rsync
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2581/rsync
tcp6 0 0 :::873 :::* LISTEN 2581/rsync
检查是否安装,若无则安装rpm -qa rsyncyum -y install rsync
验证
touch /123.txt
rsync -av /123.txt 192.168.1.11:/root/
root@192.168.1.11's password:
sending incremental file list
123.txt
传输完成在服务器查看:
出现123.txt文件怎证明成功。
来源:CSDN
作者:suiyu_eran_
链接:https://blog.csdn.net/suiyu_eran_/article/details/103846255