Rsync服务端 | 192.168.8.70 | |
Rsync客户端 | 192.168.8.71 |
使用yum安装
?yum -y install rsync
?rpm -qa rsync?
rsync-3.2.3-19.el9.x86_64
cat /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
cp:是否覆盖'/opt/rsyncd.conf'? y
'/etc/rsyncd.conf' -> '/opt/rsyncd.conf'
Cat /etc/rsync.conf
uid = rsync
gid = rsync
use chroot = no
max connections = 100
timeout = 100
pid file = /var/lock/rsync.pid
lock file = /var/lock/rsync.lock
log file = /var/log/rsync.log
[nfs-master]
path = /data/rsync/nfs-master-server
read only = false
hosts allow = 192.168.8.0/24
auth users = rsyncuser1
secrets file = /etc/rsync/rsync.passwd
list = false
[nfs-slave]
path = /data/rsync/nfs-slave-server
read only = false
hosts allow = 192.168.8.0/24
auth users = rsyncuser2
secrets file = /etc/rsync/rsync.passwd
list = false
[root@localhost ~]# useradd rsync -s /sbin/nologin -M -c 'rsync 服务运行用户'
[root@localhost ~]# grep rsync /etc/passwd
rsync:x:1000:1000:rsync 服务运行用户:/home/rsync:/sbin/nologin
[root@localhost ~]# mkdir -pv /data/rsync/{nfs-master-server,nfs-slave-server}
mkdir: 已创建目录 '/data'
mkdir: 已创建目录 '/data/rsync'
mkdir: 已创建目录 '/data/rsync/nfs-master-server'
mkdir: 已创建目录 '/data/rsync/nfs-slave-server'
(8)授权目录
[root@localhost ~]# chown -R rsync. /data/rsync
[root@localhost ~]# ls -lhrt -d /data/rsync/{nfs-master-server,nfs-slave-server}
drwxr-xr-x 2 rsync rsync 6 ?1月 17 19:27 /data/rsync/nfs-slave-server
drwxr-xr-x 2 rsync rsync 6 ?1月 17 19:27 /data/rsync/nfs-master-server
[root@localhost ~]# cat /etc/rsync/rsync.passwd
rsyncuser1:123
rsyncuser2:123
[root@localhost rsync]# chmod 600 /etc/rsync/rsync.passwd
[root@localhost rsync]# ll
总用量 4
-rw------- 1 root root 30 ?1月 17 19:34 rsync.passwd
[root@zabbixguo130 ~]# ?rsync --daemon
[root@zabbixguo130 ~]# ps aux |grep sync
root ???????2651 ?0.0 ?0.0 ??9148 ?1988 ? ???????Ss ??20:02 ??0:00 rsync --daemon
root ???????5690 ?0.0 ?0.0 ??6636 ?2176 pts/0 ???S+ ??20:30 ??0:00 grep --color=auto sync
[root@localhost rsync]#?cat /etc/rsync.passwd
123
[root@localhost rsync]#?chmod 600 /etc/rsync.passwd
[root@localhost rsync]# ll
总用量 4
-rw------- 1 root root 30 ?1月 17 19:34 rsync.passwd
[root@zabbixguo130 ~]# ?rsync -avz /root/ rsyncuser1@192.168.8.70::nfs-master
--password-file=/etc/rsync/rsync.passwd
Password:
sending incremental file list
./
.bash_history
.bash_logout
.bash_profile
.bashrc
.cshrc
.lesshst
.mysql_history
.tcshrc
.viminfo
nginx-1.20.2/src/stream/ngx_stream_upstream_round_robin.h
nginx-1.20.2/src/stream/ngx_stream_upstream_zone_module.c
nginx-1.20.2/src/stream/ngx_stream_variables.c
nginx-1.20.2/src/stream/ngx_stream_variables.h
nginx-1.20.2/src/stream/ngx_stream_write_filter_module.c
sent 6,018,063 bytes ?received 10,697 bytes ?388,952.26 bytes/sec
total size is 20,467,907 ?speedup is 3.40