rsync服务端配置

服务端配置分为以下几步:
1.创建配置文件/etc/rsyncd.conf

[root@Rsync ~]# cat /etc/rsyncd.conf 
#rsync server
uid = rsync
gid = rsync
use chroot = no
max connections = 2000
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
lof 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
###################################################
[backup]
comment = bakcup by linuxea
path = /backup

启动rsync

[root@Rsync ~]# rsync --daemon
[root@Rsync ~]# ps -ef |grep rsync|grep -v grep
root       2094      1  0 03:44 ?        00:00:00 rsync --daemon
[root@Rsync ~]# netstat -lntup|grep rsync
tcp        0      0 0.0.0.0:873                 0.0.0.0:*                   LISTEN      2094/rsync          
tcp        0      0 :::873                      :::*                        LISTEN      2094/rsync          
[root@Rsync ~]# 

2.创建共享目录backup。和rsync用户密码文件
创建用户,不允许登录,不创建家目录

[root@Rsync ~]# useradd rsync -s /sbin/nologin -M

创建目录,给写权限

[root@Rsync ~]# mkdir /backup
[root@Rsync ~]# chown -R rsync /backup
[root@Rsync ~]# ls -ld /backup/
drwxr-xr-x 2 rsync root 4096 Dec 19 03:51 /backup/
[root@Rsync ~]# 

创建账号密码文件,账号rsync_backup密码linuxea,直接登录

[root@Rsync ~]# echo "rsync_backup:linuxea" >/etc/rsync.password
[root@Rsync ~]# cat /etc/rsync.password
rsync_backup:linuxea
[root@Rsync ~]# 

修改权限

[root@Rsync ~]# chmod 600 /etc/rsync.password 
[root@Rsync ~]# ll /etc/rsync.password
-rw------- 1 root root 21 Dec 19 03:54 /etc/rsync.password
[root@Rsync ~]# 

加到开机启动中

[root@Rsync ~]# echo "rsync --daemon" >>/etc/rc.local 
[root@Rsync ~]# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
rsync --daemon
[root@Rsync ~]# 

启动程序

[root@Rsync ~]#  rsync --daemon
[root@Rsync ~]# ps -ef |grep rsync |grep -v grep
root       2227      1  0 04:03 ?        00:00:00 rsync --daemon

二,rsync客户端配置
1,创建密码文件

echo "linuxea" >/etc/rsync.password
chmod 600 /etc/rsync.password
ls -l /etc/rsync.password

如下:

[root@jumo-client ~]# echo "linuxea" >/etc/rsync.password
[root@jumo-client ~]# chmod 600 /etc/rsync.password
[root@jumo-client ~]# ls -l /etc/rsync.password
-rw------- 1 root root 8 Dec 19 04:31 /etc/rsync.password
[root@jumo-client ~]# cat /etc/rsync.password
linuxea

2,rsync客户端推送到rsync服务器端
push推送
-password-file=/etc/rsync.password------->指定密码文件位置

rsync -avz /tmp/ rsync_backup@10.0.0.30::backup --password-file=/etc/rsync.password
如下:

[root@jumo-client tmp]# rsync -avz /tmp/ rsync_backup@10.0.0.30::backup --password-file=/etc/rsync.password
sending incremental file list
./
ks-script-LRvD5O
ks-script-LRvD5O.log
yum.log
.ICE-unix/
.esd-0/
.esd-0/socket
VMwareDnD/
linuxea/
linuxea/1.txt
linuxea/rh/
pulse-75mVmxEZuktI/
pulse-75mVmxEZuktI/native
pulse-75mVmxEZuktI/pid
pulse-phsa2Tvp17nZ/
virtual-root.LmpRtk/
vmware-config0/
vmware-config0/99-vmware-scsi-udev.rules
vmware-root-593009104/
vmware-root-593009104/vmware-apploader-27948.log
vmware-root-593009104/vmware-apploader-27956.log
vmware-root-593009104/vmware-apploader-28259.log
vmware-root-593009104/vmware-apploader-28267.log
vmware-root-593009104/vmware-apploader-28358.log
vmware-root-593009104/vmware-apploader-28366.log
vmware-root-593009104/vmware-apploader-28411.log
vmware-root-593009104/vmware-apploader-28419.log
vmware-root-593009104/vmware-apploader-28463.log
vmware-root-593009104/vmware-apploader-28471.log
vmware-root-593009104/vmware-apploader-28515.log
vmware-root-593009104/vmware-apploader-28523.log
vmware-root-593009104/vmware-apploader-28567.log
vmware-root-593009104/vmware-apploader-28575.log
vmware-root-593009104/vmware-apploader-28619.log
vmware-root-593009104/vmware-apploader-28627.log
vmware-root-593009104/vmware-apploader-28671.log
vmware-root-593009104/vmware-apploader-28679.log
vmware-root-593009104/vmware-apploader-28723.log
vmware-root-593009104/vmware-apploader-28731.log
vmware-root-593009104/vmware-apploader-28775.log
vmware-root-593009104/vmware-apploader-28783.log
vmware-root-593009104/vmware-apploader-28827.log
vmware-root-593009104/vmware-apploader-28835.log
vmware-root-593009104/vmware-apploader-28879.log
vmware-root-593009104/vmware-apploader-28887.log
vmware-root-593009104/vmware-apploader-28931.log
vmware-root-593009104/vmware-apploader-28939.log
vmware-root-593009104/vmware-apploader-28984.log
vmware-root-593009104/vmware-apploader-28992.log
vmware-root-593009104/vmware-apploader-29045.log
vmware-root-593009104/vmware-apploader-29053.log
vmware-root/
vmware-root/vmware-1827.log
vmware-root/vmware-1924.log
vmware-root/vmware-1952.log
vmware-root/vmware-1980.log
vmware-root/vmware-2008.log
vmware-root/vmware-2037.log
vmware-root/vmware-2065.log
vmware-root/vmware-2095.log
vmware-root/vmware-2123.log
vmware-root/vmware-26874.log
vmware-root/vmware-26939.log
vmware-root/vmware-29555.log
vmware-root/vmware-29616.log
vmware-root/vmware-3335.log
vmware-root/vmware-3400.log
vmware-root/vmware-apploader-12060.log
vmware-root/vmware-apploader-12068.log
vmware-root/vmware-apploader-12072.log
vmware-root/vmware-apploader-12130.log
vmware-root/vmware-apploader-12138.log
vmware-root/vmware-apploader-1226.log
vmware-root/vmware-apploader-12452.log
vmware-root/vmware-apploader-1247.log
vmware-root/vmware-apploader-12473.log
vmware-root/vmware-apploader-12478.log
vmware-root/vmware-apploader-1249.log
vmware-root/vmware-apploader-1252.log
vmware-root/vmware-apploader-1270.log
vmware-root/vmware-apploader-1275.log
vmware-root/vmware-apploader-1723.log
vmware-root/vmware-apploader-1731.log
vmware-root/vmware-apploader-1735.log
vmware-root/vmware-apploader-1744.log
vmware-root/vmware-apploader-1746.log
vmware-root/vmware-apploader-1752.log
vmware-root/vmware-apploader-1754.log
vmware-root/vmware-apploader-1756.log
vmware-root/vmware-apploader-1758.log
vmware-root/vmware-apploader-1772.log
vmware-root/vmware-apploader-1780.log
vmware-root/vmware-apploader-1784.log
vmware-root/vmware-apploader-1792.log
vmware-root/vmware-apploader-1797.log
vmware-root/vmware-apploader-1806.log
vmware-root/vmware-apploader-2577.log
vmware-root/vmware-apploader-2585.log
vmware-root/vmware-apploader-26874.log
vmware-root/vmware-apploader-26939.log
vmware-root/vmware-apploader-3335.log
vmware-root/vmware-apploader-3400.log

sent 62884 bytes  received 1733 bytes  129234.00 bytes/sec
total size is 294329  speedup is 4.55
[root@jumo-client tmp]#


在rsync服务端验证
[root@Rsync backup]# ls
[root@Rsync backup]# ls
ks-script-LRvD5O      linuxea             pulse-phsa2Tvp17nZ   vmware-config0  vmware-root            yum.log
ks-script-LRvD5O.log  pulse-75mVmxEZuktI  virtual-root.LmpRtk  VMwareDnD       vmware-root-593009104
[root@Rsync backup]# 

从rsync端拉取到本地
先删掉,将推送的拉取回来

[root@jumo-client tmp]# rm -rf *
[root@jumo-client tmp]# ls
[root@jumo-client tmp]# rsync -avz rsync_backup@10.0.0.30::backup /tmp/ --pasword-file=/etc/rsync.password
rsync: --pasword-file=/etc/rsync.password: unknown option
rsync error: syntax or usage error (code 1) at main.c(1422) [client=3.0.6]
[root@jumo-client tmp]# 
[root@jumo-client tmp]# rsync -avz rsync_backup@10.0.0.30::backup /tmp/ --password-file=/etc/rsync.password
receiving incremental file list
./
ks-script-LRvD5O
ks-script-LRvD5O.log
yum.log
.ICE-unix/
.esd-0/
VMwareDnD/
linuxea/
linuxea/1.txt
linuxea/rh/
pulse-75mVmxEZuktI/
pulse-75mVmxEZuktI/native
pulse-75mVmxEZuktI/pid
pulse-phsa2Tvp17nZ/
virtual-root.LmpRtk/
vmware-config0/
vmware-config0/99-vmware-scsi-udev.rules
vmware-root-593009104/
vmware-root-593009104/vmware-apploader-27948.log
vmware-root-593009104/vmware-apploader-27956.log
vmware-root-593009104/vmware-apploader-28259.log
vmware-root-593009104/vmware-apploader-28267.log
vmware-root-593009104/vmware-apploader-28358.log
vmware-root-593009104/vmware-apploader-28366.log
vmware-root-593009104/vmware-apploader-28411.log
vmware-root-593009104/vmware-apploader-28419.log
vmware-root-593009104/vmware-apploader-28463.log
vmware-root-593009104/vmware-apploader-28471.log
vmware-root-593009104/vmware-apploader-28515.log
vmware-root-593009104/vmware-apploader-28523.log
vmware-root-593009104/vmware-apploader-28567.log
vmware-root-593009104/vmware-apploader-28575.log
vmware-root-593009104/vmware-apploader-28619.log
vmware-root-593009104/vmware-apploader-28627.log
vmware-root-593009104/vmware-apploader-28671.log
vmware-root-593009104/vmware-apploader-28679.log
vmware-root-593009104/vmware-apploader-28723.log
vmware-root-593009104/vmware-apploader-28731.log
vmware-root-593009104/vmware-apploader-28775.log
vmware-root-593009104/vmware-apploader-28783.log
vmware-root-593009104/vmware-apploader-28827.log
vmware-root-593009104/vmware-apploader-28835.log
vmware-root-593009104/vmware-apploader-28879.log
vmware-root-593009104/vmware-apploader-28887.log
vmware-root-593009104/vmware-apploader-28931.log
vmware-root-593009104/vmware-apploader-28939.log
vmware-root-593009104/vmware-apploader-28984.log
vmware-root-593009104/vmware-apploader-28992.log
vmware-root-593009104/vmware-apploader-29045.log
vmware-root-593009104/vmware-apploader-29053.log
vmware-root/
vmware-root/vmware-1827.log
vmware-root/vmware-1924.log
vmware-root/vmware-1952.log
vmware-root/vmware-1980.log
vmware-root/vmware-2008.log
vmware-root/vmware-2037.log
vmware-root/vmware-2065.log
vmware-root/vmware-2095.log
vmware-root/vmware-2123.log
vmware-root/vmware-26874.log
vmware-root/vmware-26939.log
vmware-root/vmware-29555.log
vmware-root/vmware-29616.log
vmware-root/vmware-3335.log
vmware-root/vmware-3400.log
vmware-root/vmware-apploader-12060.log
vmware-root/vmware-apploader-12068.log
vmware-root/vmware-apploader-12072.log
vmware-root/vmware-apploader-12130.log
vmware-root/vmware-apploader-12138.log
vmware-root/vmware-apploader-1226.log
vmware-root/vmware-apploader-12452.log
vmware-root/vmware-apploader-1247.log
vmware-root/vmware-apploader-12473.log
vmware-root/vmware-apploader-12478.log
vmware-root/vmware-apploader-1249.log
vmware-root/vmware-apploader-1252.log
vmware-root/vmware-apploader-1270.log
vmware-root/vmware-apploader-1275.log
vmware-root/vmware-apploader-1723.log
vmware-root/vmware-apploader-1731.log
vmware-root/vmware-apploader-1735.log
vmware-root/vmware-apploader-1744.log
vmware-root/vmware-apploader-1746.log
vmware-root/vmware-apploader-1752.log
vmware-root/vmware-apploader-1754.log
vmware-root/vmware-apploader-1756.log
vmware-root/vmware-apploader-1758.log
vmware-root/vmware-apploader-1772.log
vmware-root/vmware-apploader-1780.log
vmware-root/vmware-apploader-1784.log
vmware-root/vmware-apploader-1792.log
vmware-root/vmware-apploader-1797.log
vmware-root/vmware-apploader-1806.log
vmware-root/vmware-apploader-2577.log
vmware-root/vmware-apploader-2585.log
vmware-root/vmware-apploader-26874.log
vmware-root/vmware-apploader-26939.log
vmware-root/vmware-apploader-3335.log
vmware-root/vmware-apploader-3400.log

sent 1789 bytes  received 62936 bytes  18492.86 bytes/sec
total size is 294329  speedup is 4.55
[root@jumo-client tmp]# ls
ks-script-LRvD5O      linuxea             pulse-phsa2Tvp17nZ   vmware-config0  vmware-root            yum.log
ks-script-LRvD5O.log  pulse-75mVmxEZuktI  virtual-root.LmpRtk  VMwareDnD       vmware-root-593009104
[root@jumo-client tmp]# 

重启命令:
关闭服务

pkill rsync 
kill 'cat /var/run/rsync.pid'
rsync --daemon

推送还是拉取都是客户端进行操作!

2 分享

您可以选择一种方式赞助本站

支付宝扫码赞助

支付宝扫码赞助

日期: 2015-12-19分类: rsync

标签: rsync

发表评论