Rsync客户端和服务端的配置

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)测试客户端

结果如图所示:
  • 27
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值