Rsync客户端和服务端的配置

发布时间:2024年01月23日

Rsync服务端

192.168.8.70

Rsync客户端

192.168.8.71

Rsync客户端和服务端的配置

  1. 安装rsqnc

使用yum安装

?yum -y install rsync

  1. 查看一下安装是否成功

?rpm -qa rsync?

rsync-3.2.3-19.el9.x86_64

(3)rsync的默认配置文件进行备份

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

(4)备份rsync配置
cp -av /etc/rsyncd.conf /opt/

cp:是否覆盖'/opt/rsyncd.conf'y

'/etc/rsyncd.conf' -> '/opt/rsyncd.conf'

  1. 修改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

  1. 创建rsync用户

[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

  1. 创建rsync目录

[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

(9)查看创建的目录

[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

  1. 创建rsync的认证密钥和修改权限

[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

启动rsync服务

[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

配置rsync的客户端

  1. 配置客户端的免密

[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

(2)rsync 客户端测试文件传输。

[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

(3)测试客户端

结果如图所示:
文章来源:https://blog.csdn.net/GMC_J/article/details/135751839
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。