CentOS6.5 Rsync服务
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS6.5 Rsync服务相关的知识,希望对你有一定的参考价值。
rsync介绍
主要有以下三种用法:
1、本地备份
例:[[email protected]~]#rsync /data/ /home/oldboy/
2、远端备份
例:pull
[[email protected] ~]# rsync -avz oldboy.txt -e ‘ssh‘ 192.168.129.128:~
push
[[email protected] ~]# rsync -avz -e ‘ssh‘ 192.168.129.128:~/f1 ./
3、daemon模式备份
以守护进程(socket)的方式传输数据(这个是rsync自身的重要功能)
rsync daemon模式配置
服务端:
[[email protected] ~]#vi /etc/rsyncd.conf
创建rsync默认配置文件路径 /etc/rsyncd.conf 将 默认配置考到此文件内
以下是默认配置
#rsync_config___________start
#created by oldboy 16:01 2016-12-02
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[oldboy]
path = /oldboy/
ignore errors
read only = false
list = false
hosts allow = 192.168.0.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
#rsync_config_________end
rsyncd.conf 里面的共享目录 oldboy 要存在
启动服务之后的操作
[[email protected] ~]# mkdir/oldboy -p
[[email protected] ~]# useradd rsync -s /sbin/nologin
[[email protected] ~]# chown -R rsync.rsync /oldboy
[[email protected] ~]# echo"rsync_backup:oldboy" >/etc/rsync.password
[[email protected] ~]# chmod600 /etc/rsync.password
[[email protected] ~]# rsync --daemon
注:rsync --daemon 可以放入/etc/rc.local 开机启动
[[email protected] ~]# netstat -lntup|grep 873
至此服务端配置完毕
客户端:
[[email protected] ~]# echo"rsync_backup:oldboy" >/etc/rsync.password
[[email protected] ~]# chown 600 /etc/rsync.password
[[email protected] ~]# rsync -avz [email protected]::oldboy /tmp/ --password-file=/etc/rsync.password
[[email protected] tmp]# rsync -avz /tmp/ [email protected]::oldboy --password-file=/etc/rsync.passwordsending incremental file list
./
123.txt
ceshi.log
123/
sent 192 bytes received 54 bytes 492.00 bytes/sec
total size is 0 speedup is 0.00
[[email protected] tmp]#
[[email protected] tmp]# ll
total 4
drwxr-xr-x. 2 root root 4096 Dec 7 13:10 123
-rw-r--r--. 1 root root 0 Dec 7 13:11 123.txt
-rw-r--r--. 1 root root 0 Dec 7 13:10 ceshi.log
[[email protected] oldboy]# ll
total 4
drwxr-xr-x 2 rsync rsync 4096 Dec 7 00:10 123
-rw-r--r-- 1 rsync rsync 0 Dec 7 00:11 123.txt
-rw-r--r-- 1 rsync rsync 0 Dec 7 00:10 ceshi.log
-rw------- 1 rsync rsync 0 Nov 16 02:44 yum.log
以上是关于CentOS6.5 Rsync服务的主要内容,如果未能解决你的问题,请参考以下文章