主要内容
环境:
rsync服务端
rsync客户端
rsync多模块
一、环境:
rsync服务端 backup 10.0.0.41 172.16.1.41
rsync客户端 nfs01 10.0.0.31 172.16.1.31
二、rsync服务端:
1.修改配置文件之前准备:
(1)添加虚拟用户rsync
(2)创建模块目录/data ;修改所有者户所属用户组为rsync
(3)创建密码文件,并修改权限为600
2.修改配置文件:/etc/rsyncd.conf
[root@backup ~]# cat /etc/rsyncd.conf
#Rsync server
#created by oldboy 15:01 2009-6-5
##rsyncd.conf start##
fake super = yes
uid = rsync
gid = rsync
use chroot = no
max connections = 2000
timeout = 600
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 = 10.0.0.0/24
#hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
#####################################
[data]
comment = www by old0boy 14:18 2012-1-13
path = /data
注意:用户,密码文件,模块以及目录都必须和创建的保持一致
3.启动rsync服务
(1)启动服务:systemctl restart rsyncd
(2)检查端口号和进程
进程:ps -ef |grep rsync
[root@backup ~]# ps -ef |grep rsync
root 7719 1 0 04:08 ? 00:00:00 /usr/bin/rsync --daemon --no-detach
root 9243 8929 0 16:28 pts/1 00:00:00 grep --color=auto rsync
端口号:ss -lntup |grep rsync
[root@backup ~]# ss -lntup |grep rsync
tcp LISTEN 0 5 *:873 *:* users:(("rsync",pid=7719,fd=3))
tcp LISTEN 0 5 :::873 :::* users:(("rsync",pid=7719,fd=5))
4.检查rsync服务端是否能用(自我检查)
[root@backup ~]# rsync -avz /etc/hosts rsync_backup@172.16.1.41::data
Password:
sending incremental file list
hosts
sent 220 bytes received 43 bytes 75.14 bytes/sec
total size is 349 speedup is 1.33
[root@backup ~]# cat /data/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.5 lb01
172.16.1.6 lb02
172.16.1.7 web01
172.16.1.8 web02
172.16.1.31 nfs01
172.16.1.41 backup
172.16.1.51 db01 db01.etiantian.org
172.16.1.61 m01
5.检查rsync服务是否开机自动运行
[root@backup ~]# systemctl is-enabled rsyncd
enabled
6.排查故障的思路
(1)看日志
[root@backup ~]# tail -f /var/log/rsyncd.log
(2)配置文件
[root@backup ~]# vim /etc/rsyncd.conf
三、rsync客户端
1.在客户端检测能否将数据推送到服务端
[root@nfs01 ~]# rsync -avz /etc/hostname rsync_backup@172.16.1.41::data
Password:
sending incremental file list
hostname
sent 100 bytes received 49 bytes 42.57 bytes/sec
total size is 6 speedup is 0.04
############回到backup下查看
[root@backup ~]# cat /data/hostname
nfs01
2.创建密码文件,并改权限为600
[root@nfs01 ~]# echo '123456' >/etc/rsync.password
[root@nfs01 ~]# cat /etc/rsync.password
123456
[root@nfs01 ~]# chmod 600 /etc/rsync.password
[root@nfs01 ~]# ll /etc/rsync.password
-rw------- 1 root root 7 May 21 19:19 /etc/rsync.password
3.测试密码文件是否设置正确
[root@nfs01 ~]# rsync -avz /etc/hosts rsync_backup@172.16.1.41::data --password-file=/etc/rsync.password
sending incremental file list
hosts
sent 88 bytes received 49 bytes 274.00 bytes/sec
total size is 349 speedup is 2.55
######回到backup下面查看
[root@backup ~]# cat /data/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.5 lb01
172.16.1.6 lb02
172.16.1.7 web01
172.16.1.8 web02
172.16.1.31 nfs01
172.16.1.41 backup
172.16.1.51 db01 db01.etiantian.org
172.16.1.61 m01
四、rsync多模块
1.修改配置文件
[root@backup ~]# cat /etc/rsyncd.conf
#Rsync server
#created by oldboy 15:01 2009-6-5
##rsyncd.conf start##
fake super = yes
uid = rsync
gid = rsync
use chroot = no
max connections = 2000
timeout = 600
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 = 10.0.0.0/24
#hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
#####################################
[data]
comment = www by old0boy 14:18 2012-1-13
path = /data
#####################################
[backup]
comment = www by old0boy 14:18 2012-1-13
path = /backup