大佬教程收集整理的这篇文章主要介绍了centos 6.5 安装rsync,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Rsync服务
同步命令参数:
-v详细模式输出,传输时的进度信息
-z传输时进行压缩以提高传输效率
-e使用信道协议
服务端部署:
1关闭防火墙和selinux
2检查rsync安装没有
[root@zabbixceshi /]# rpm -qa |grep rsync
rsync-3.0.6-12.el6.x86_64
Touch /etc/rsyncd.conf
uid = root
gid = root
use chroot = no
@H_188_14@max connections = 0pid file = /var/log/rsync/rsyncd.pid
lock file = /var/log/rsync/rsync.lock
log file = /var/log/rsync/rsyncd.log
Strict modes =yes
[www]
path = /www/
ignore errors
read only = false
list = false
hosts allow = all
hosts deny = 172.25.0.0/24
auth users = BACkup
secrets file = /etc/rsyncd.passwd
Echo “BACk:123” >/etc/rsyncd.passwd
5给予600权限
Chmod 600 /etc/rsyncd.passwd
6启动服务
Rsync �daemon
7查看端口
[root@zabbixceshi /]# netstat -anpt |grep rsync
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 1302/rsync
tcp 0 0 :::873 :::* LISTEN 1302/rsync
8建立共享的目录
@H_188_14@mkdir /www客服端配置
1创建密码文件
Echo “123” >/etc/rsyncd.passwd
2给予600权限
Chmod 600 /etc/rsyncd.passwd
测试:
3从服务端同步到客户端:
[root@rsync-c etc]# rsync -avzbackup@192.168.199.235::www /tmp/注:加�password-file=/etc/rsyncd.passwd 可不用输密码
password:
receiving incremental file list
./
aa
bb
cc.txt
sent 115 bytesreceived 234 bytes139.60 bytes/sec
@R_175_10586@l size is 0speedup is 0.00
或者这样:
rsync -avz rsync://BACkup@192.168.199.235/www /tmp �password-file=/etc/rsyncd.passwd
从客户端同步到服务端
如果只同步目录里面内容/tmp/要加斜线,如果是目录不用加斜线/tmp 即可。
[root@rsync-c tmp]# rsync -avz /tmp/backup@192.168.199.235::www�password-file=/etc/rsyncd.passwd
sending incremental file list
yum.log
zabbix_agentd.log
zabbix_agentd.pid
.ICE-unix/
sent 1285 bytesreceived 69 bytes902.67 bytes/sec
@R_175_10586@l size is 5604speedup is 4.14
或者:
[root@rsync-c tmp]# rsync -avz /tmp/ rsync://BACkup@192.168.199.235/www �password-file=/etc/rsyncd.passwd
使用ssh协议进行推送:
[root@rsync-c tmp]# rsync -avz -e ‘ssh -p 22’ /etc/hostsroot@192.168.199.235:~
The authenticity of host ‘192.168.199.235 (192.168.199.235)’ can’t be established.
RSA key fingerprint is 0b:49:b6:27:2b:98:e4:b1:ed:42:77:7b:07:9a:42:0b.
Are you sure you want to conTinue connecTing (yes/no)? yes
Warning: PeRMANently added ‘192.168.199.235’ (RSA) to the list of kNown hosts.
root@192.168.199.235’s password:
sending incremental file list
hosts
sent 124 bytesreceived 31 bytes20.67 bytes/sec
@R_175_10586@l size is 158speedup is 1.02
关闭rsync服务
[root@rsync-s ~]# ps -ef |grep rsync
root 1373 10 14:05 ? 00:00:00 rsync �daemon
root 1610 13300 15:01 pts/0 00:00:00 grep rsync
[root@rsync-s ~]# pkillrsync
[root@rsync-s ~]# ps -ef |grep rsync
root 1613 13300 15:01 pts/0 00:00:00 grep rsync
启动rsync服务
[root@rsync-s ~]# rsync �daemon
[root@rsync-s ~]# ps -ef |grep rsync
root 1615 10 15:02 ? 00:00:00 rsync �daemon
root 1617 13300 15:02 pts/0 00:00:00 grep rsync
�exclude参数排除文件
rsync -avz �exclude=aa/tmp/backup@192.168.199.235::www �password-file=/etc/rsyncd.passwd
排除多个文件
rsync -avz �exclude={aa,bb} /tmp/BACkup@192.168.199.235::www �password-file=/etc/rsyncd.passwd
或者
rsync -avz �exclude=aa �exclude=bb /tmp/backup@192.168.199.235::www �password-file=/etc/rsyncd.passwd
排除多个不规律的文件
参数:�exclude-from=文件名
[root@rsync-c tmp]# ll
总用量4
-rw-r�r� 1 root root0 7月11 2016 aa
-rw-r�r� 1 root root0 7月11 2016 bb
-rw-r�r� 1 root root0 7月11 2016 cc
-rw-r�r� 1 root root0 7月11 2016 jin
-rw-r�r� 1 root root 13 7月 8 16:11 li.log
-rw-r�r� 1 root root0 7月 8 16:09 xx
[root@rsync-c tmp]# cat li.log注意:文件中每行后面不能有空格
aa
bb
jin
cc
[root@rsync-c tmp]# rsync -avz �exclude-from=li.log /tmp/backup@192.168.199.235::www �password-file=/etc/rsyncd.passwd
sending incremental file list
./
li.log
xx
sent 174 bytesreceived 50 bytes149.33 bytes/sec
@R_175_10586@l size is 13speedup is 0.06
服务端排除 参数:
Exclude=aa bb空格隔开
如果是目录中文件格式如下:
Exclude=aa bb test/test.txt
以上是大佬教程为你收集整理的centos 6.5 安装rsync全部内容,希望文章能够帮你解决centos 6.5 安装rsync所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。