码迷,mamicode.com
首页 > 其他好文 > 详细

rsync备份服务配置流程

时间:2016-09-09 19:08:23      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:配置   rsync   cetnos   

目录

1 rsync服务配置流程... 2

1.1 系统优化... 2

1.2 查看操作系统信息及rsync服务... 2

1.3 编辑rsync服务/etc/rsyncd.conf配置文件... 2

2 rsync服务搭建细节... 3

2.1 创建rsync用户,御用rsynd进程的登录... 3

2.2 创建备份目录并修改权限... 3

2.3 编辑rsync服务的密码文件并修改文件权限... 3

3检查服务配置结果... 3

3.1 开启并检查rsync服务... 3

3.2 写入开机自启动... 4

3.3 客户端rsync配置... 4

4 rsync实战测试... 4

4.1 标准rsync命令使用... 4

4.2 把服务启动写入开机启动... 5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

第1章 rsync服务配置流程

1.1 系统优化

1.2 查看操作系统信息及rsync服务

[root@backup /]# cat /etc/redhat-release

CentOS release 6.7 (Final)

[root@backup /]# uname -r

2.6.32-573.el6.x86_64

[root@backup /]# uname -m

x86_64

[root@backup /]# rpm -qa rsync

rsync-3.0.6-12.el6.x86_64

1.3 编辑rsync服务/etc/rsyncd.conf配置文件

[root@backup /]# vim /etc/rsyncd.conf        (下边的注释不能写在行的后面,会导致配置文件失效,错误)

#rsync_config______start

#created by crazy frog

##rsyncd.cong start##

uid=rsync                        ##virtual users uid

gid=rsync                        ##virtual users gid

use chroot=no                     ##safe system config

max connections=200               ##max  link users

timeout=300                      ##delay time

pid file=/var/run/rsyncd.pid          ##process file for rsync

lock file=/var/run/rsyncd.lock        ##lock file for file the same

log file=/var/log/rsyncd.log          ##rsync  log file

hosts allow=172.16.1.0/24          

[backup]                        ##modules  must##

path=/backup                    ##directory

ignore errors                     ##no check errors

read only=false

list=false

auth users=rsync_backup

secrets file=/etc/rsync.password ##virtual userspassword

##rsyncd.conf end##

"/etc/rsyncd.conf" [New] 21L, 854Cwritten           

第2章 rsync服务搭建细节

2.1 创建rsync用户,御用rsynd进程的登录     

[root@backup /]# useradd -s /sbin/nologin -M rsync 远程命令使用该用户访问备份目录

[root@backup /]# tail -1 /etc/passwd

rsync:x:500:500::/home/rsync:/sbin/nologin

2.2 创建备份目录并修改权限

[root@backup /]# mkdir /backup

[root@backup /]# ls -ld /backup

drwxr-xr-x 2 root root 4096 Sep  8 08:20 /backup

[root@backup /]# chown -R rsync.rsync /backup

[root@backup /]# ls -ld /backup

drwxr-xr-x 2 rsync rsync 4096 Sep  8 08:20 /backup

2.3 编辑rsync服务的密码文件并修改文件权限

[root@backup /]# vim  /etc/rsync.password

rsync_backup=oldboy

"/etc/rsync.password" [New] 1L, 20Cwritten                                          

[root@backup /]# ls -ld /etc/rsync.password

-rw-r--r-- 1 root root 20 Sep  8 08:29 /etc/rsync.password

[root@backup /]# chmod 600 /etc/rsync.password

[root@backup /]# ls -ld /etc/rsync.password

-rw------- 1 root root 20 Sep  8 08:29 /etc/rsync.password

[root@backup /]# cat /etc/rsync.password

rsync_backup=oldboy

第3章 检查服务配置结果

3.1 开启并检查rsync服务  

[root@backup /]# rsync --daemon

[root@backup /]# ps -ef|grep rsync|grep -v grep

root    10262     1  0 07:59 ?       00:00:00 rsync --daemon

[root@backup /]# ps -ef|grep rsync

root    10262     1  0 07:59 ?        00:00:00 rsync –daemon    进程是在root

root    [root@backup/]# lsof -i :873

COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

rsync  10262 root    3u IPv4 125661      0t0  TCP *:rsync (LISTEN)

rsync  10262 root    5u  IPv6 125662      0t0 TCP *:rsync (LISTEN)

[root@backup /]# netstat -lntup|grep 873

tcp       0      0 0.0.0.0:873                 0.0.0.0:*                   LISTEN      10262/rsync        

tcp       0      0 :::873                      :::*                        LISTEN      10262/rsync 10302  9542  008:01 pts/0    00:00:00 grep rsync  

3.2 写入开机自启动

[root@backup /]# echo “/usr/bin /nc --daemon">>/etc/rc.local

[root@backup /]# tail -1 /etc/rc.local

rsync --daemon

3.3 客户端rsync配置

[root@web01 /]# mkdir /backup

[root@web01 /]# vim /etc/rsync.password

oldboy

"/etc/rsync.password" [New] 2L, 8Cwritten                                           

[root@web01 /]# cat /etc/rsync.password

oldboy

[root@web01 /]# chmod /etc//rsync.password

chmod: missing operand after`/etc//rsync.password‘

Try `chmod --help‘ for more information.

[root@web01 /]# chmod 600  /etc/rsync.password

[root@web01 /]# ls -ld  /etc/rsync.password

-rw-------. 1 root root 8 Sep  8 08:58 /etc/rsync.password

 

第4章 rsync实战测试

4.1 标准rsync命令使用

[root@web01 /]# rsync -avz /backup/  rsync_backup@172.16.1.132::backup--password-file=/etc/rsync.password

sending incremental file list

./

oldboy.txt

sent 80 bytes received 30 bytes  73.33 bytes/sec

total size is 0 speedup is 0.00

[root@backup backup]# ls -ld /backup

drwxr-xr-x 4 rsync rsync 4096 Sep  9 00:50 /backup

[root@backup backup]# ls -ld /backup/oldboy

drwxr-xr-x 2 root root 4096 Sep  9 00:50 /backup/oldboy

[root@backup backup]# chown -R rsync.rsync/backup/oldboy

[root@backup backup]# ls -ld /backup/oldboy

drwxr-xr-x 2 rsync rsync 4096 Sep  9 00:50 /backup/oldboy

[root@NFS backup]# rsync -avz /backup/rsync_backup@172.16.1.132::backup/oldboy --password-file=/etc/rsync.password   推送(这种方法比较简洁)

sending incremental file list

./

a

g

test1

{c..g]

.ICE-unix/

sent 131000 bytes received 186 bytes  37481.71bytes/sec

total size is 134217728  speedup is 1023.11

[root@NFS backup]# rsync -avz rsync_backup@172.16.1.132::backup/oldboy /backup/    --password-file=/etc/rsync.password   客户端拉取

4.2 把服务启动写入开机启动

[root@backup oldboy]# echo "/usr/bin/rsync--daemon" >>/etc/rc.local

[root@backup oldboy]# tail /etc/rc.local

#!/bin/sh

#

# This script will be executed *after* all theother init scripts.

# You can put your own initialization stuff inhere if you don‘t

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

>/etc/udev/rules.d/70-persistent-net.rules

/usr/bin/rsync –daemon

查看日志:

[root@backup oldboy]# tail /var/log/rsyncd.log

2016/09/09 00:49:34 [2143] receiving file list

2016/09/09 00:49:34 [2143] ./

2016/09/09 00:49:34 [2143] sent 213 bytes  received 457 bytes  total size 134217728

2016/09/09 00:51:58 [2169] params.c:Parameter() -Ignoring badly formed line in configuration file: ignore errors


本文出自 “11566241” 博客,请务必保留此出处http://crazyfrog.blog.51cto.com/11566241/1851019

rsync备份服务配置流程

标签:配置   rsync   cetnos   

原文地址:http://crazyfrog.blog.51cto.com/11566241/1851019

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!