说明:
在CentOS7下部署rsync服务和在CentOS6上部署基本上是一样的,只是CentOS7自带了rsyncd启动脚本,由systemd管理而已。
rsync服务端配置 [[email protected] ~]# rpm -qa|grep rsync rsync-3.0.9-17.el7.x86_64 [[email protected] ~]# uname -r 3.10.0-514.el7.x86_64 [[email protected] ~]# systemctl stop firewalld [[email protected] ~]# grep -i "selinux=" /etc/selinux/config # SELINUX= can take one of these three values: SELINUX=disabled [[email protected] ~]# rsync --version rsync version 3.0.9 protocol version 30 [[email protected] ~]# useradd -M -s /sbin/nologin rsync [[email protected] ~]# mkdir /data/test -p [[email protected] ~]# chown -R rsync.rsync /data/test [[email protected] ~]# vim /etc/rsyncd.conf #rsync_configuration ##rsyncd.conf start## uid = rsync gid = rsync use chroot = no max connections = 200 timeout = 300 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log [test] path = /data/test ignore errors read only = false list = false hosts allow = * hosts deny = 0.0.0.0/32 auth users = rsync_backup secrets file = /etc/rsync.password #rsync_config_______________end [[email protected] ~]# echo ‘rsync_backup:123456‘ >/etc/rsync.password [[email protected] ~]# chmod 600 /etc/rsync.password [[email protected] ~]# systemctl restart rsyncd [[email protected] ~]# ss -lntup|grep rsync tcp LISTEN 0 5 *:873 *:* users:(("rsync",pid=7631,fd=4)) tcp LISTEN 0 5 :::873 :::* users:(("rsync",pid=7631,fd=5))
客户端配置
[[email protected] ~]# uname -r 3.10.0-862.el7.x86_64 [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) [[email protected] ~]# systemctl stop firewalld [[email protected] ~]# grep -i "selinux=" /etc/selinux/config # SELINUX= can take one of these three values: SELINUX=disabled [[email protected] ~]# rsync --version rsync version 3.1.2 protocol version 31 [[email protected] ~]# echo ‘123456‘ >/etc/rsync.password [[email protected] ~]# chmod 600 /etc/rsync.password
验证同步成功
[[email protected] ~]# ll /tmp/ 总用量 8 drwx------ 2 oldboy oldboy 24 1月 25 19:31 ssh-i8u7DI17TF drwx------ 2 oldboy oldboy 24 1月 24 17:33 ssh-Q7DZur3rIP drwx------ 2 root root 6 1月 25 20:04 vmware-root -rw------- 1 root root 8054 1月 24 17:35 yum_save_tx.2019-01-24.17-35.v9YeIo.yumtx [[email protected] ~]# rsync -avz /tmp/ [email protected]::test --password-file=/etc/rsync.password [[email protected] ~]# ll /data/test/ 总用量 20 drwx------ 2 rsync rsync 4096 1月 25 19:31 ssh-i8u7DI17TF drwx------ 2 rsync rsync 4096 1月 24 17:33 ssh-Q7DZur3rIP drwx------ 2 rsync rsync 4096 1月 25 20:04 vmware-root -rw------- 1 rsync rsync 8054 1月 24 17:35 yum_save_tx.2019-01-24.17-35.v9YeIo.yumtx
CentOS7中由systemd管理的rsyncd脚本内容
[[email protected] ~]# cat /usr/lib/systemd/system/rsyncd.service [Unit] Description=fast remote file copy program daemon ConditionPathExists=/etc/rsyncd.conf [Service] EnvironmentFile=/etc/sysconfig/rsyncd ExecStart=/usr/bin/rsync --daemon --no-detach "$OPTIONS" #<===此选项意思是rsync不将自己从终端上剥离 [Install] WantedBy=multi-user.target
原文地址:https://www.cnblogs.com/blog-tim/p/10362817.html
时间: 2024-10-12 15:52:08