Rsync守护进程模式-day35

2019-05-20


基本流程

环境准备

----backup

服务端

1.修改配置文件

[root 19:37 @ backup ~]# vim  /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

2.根据配置文件创建

创建虚拟用户
[root 19:53 @ backup ~]# useradd -s /sbin/nologin -M rsync

创建共享目录
[root 19:53 @ backup ~]# mkdir -p /data

把共享目录授权给虚拟用户
[root 19:53 @ backup ~]# chown rsync.rsync /data/

把密码文件权限改为600
[root 19:53 @ backup ~]# chmod 600 /etc/rsync.password

写密码到指定密码文件里
[root 19:53 @ backup ~]# echo 'rsync_backup:123456'  >/etc/rsync.password
[root 19:53 @ backup ~]# cat /etc/rsync.password
rsync_backup:123456

3.查看

是否是虚拟用户
[root 19:54 @ backup ~]# grep rsync /etc/passwd
rsync:x:1001:1001::/home/rsync:/sbin/nologin

是否授权给虚拟用户
[root 19:54 @ backup ~]# ll -d /data
drwxr-xr-x 2 rsync rsync 6 May 20 16:04 /data

文件权限是否改为600
[root 19:54 @ backup ~]# ll /etc/rsync.password
-rw------- 1 root root 20 May 20 16:05 /etc/rsync.password

密码文件内容是否正确
[root 19:54 @ backup ~]# cat  /etc/rsync.password
rsync_backup:123456
[root 19:54 @ backup ~]# 

4.启动rsync服务

[root 19:55 @ backup ~]# systemctl restart rsyncd

5.查看rsync服务是否启动

查看进程
[root 19:56 @ backup ~]# ps -ef |grep rsync
root       7596      1  0 20:27 ?        00:00:00 /usr/bin/rsync --daemon --no-detach
root       7598   7522  0 20:28 pts/0    00:00:00 grep --color=auto rsync

查看端口
[root 19:56 @ backup ~]# ss -lntup|grep 873
tcp    LISTEN     0      5         *:873                   *:*                   users:(("rsync",pid=7596,fd=3))
tcp    LISTEN     0      5        :::873                  :::*                   users:(("rsync",pid=7596,fd=5))
[root 19:56 @ backup ~]# ss -lntup|grep rsync
tcp    LISTEN     0      5         *:873                   *:*                   users:(("rsync",pid=7596,fd=3))
tcp    LISTEN     0      5        :::873                  :::*                   users:(("rsync",pid=7596,fd=5))
[root 19:56 @ backup ~]# 

6.本地检查

[root 19:56 @ backup ~]# rsync -avz /etc/hosts  [email protected]::data
Password: 
sending incremental file list

sent 48 bytes  received 20 bytes  7.16 bytes/sec
total size is 349  speedup is 5.13
[root 19:56 @ backup ~]# 

报错一定要看日志文件和配置文件

----nfs01

客户端

1.创建密码文件

[root 20:57 @ nfs01 ~]# echo 123456 >/etc/gyj.password
[root 20:57 @ nfs01 ~]# cat /etc/gyj.password
123456
[root 21:00 @ nfs01 ~]# 

2.密码文件设置权限600

[root 20:57 @ nfs01 ~]# chmod 600 /etc/gyj.password

验证

将客户端nfs01目录的/etc/hostname备份到服务端backup共享目录/data/

[root 20:57 @ nfs01 ~]# rsync -avz /etc/hostname [email protected]::data  --password-file /etc/gyj.password
sending incremental file list
hostname

sent 100 bytes  received 43 bytes  286.00 bytes/sec
total size is 6  speedup is 0.04

查看

[root 20:52 @ backup ~]# ll /data
total 8
-rw-r--r-- 1 rsync rsync   6 May 17 08:36 hostname
-rw-r--r-- 1 rsync rsync 349 May 17 11:12 hosts
[root 20:58 @ backup ~]# 

你可能感兴趣的:(Rsync守护进程模式-day35)