Rsync配置

1.关闭防火墙
centos6:

chkconfig iptables off
service iptables stop

centos7

systemctl disable iptables
systemctl disable firewalld
systemctl stop iptables
systemctl stop firewalld

2.关闭selinux

#setenforce 0
vim /etc/sysconfig/selinux
将selinux=enforce改为 selinux=disabled(文件内容有示例)

3.安装rsync

	centos6:
		rsync是由xinetd来管理的,所以需要先安装xinetd
		#安装软件
		yum install rsync , xinetd -y
		#修改xinetd配置,启动rsync
		vim /etc/xinetd.d/rsync
		将其中的disabled=yes , 改为disabled=no
		#设置xinetd自启动
		chkconfig  xinetd on
		#启动xinetd
		service xinetd start
	centos7,rsync直接由systemctl来管理,直接作为一个服务启动,不再需要xinetd了
		yum install rsyncd -y
		systemctl enable rsyncd
		systemctl start rsyncd
	以上只是rsyncd在不同的环境汇总的安装的的差别.

4.配置rsyncd.conf

uid = nobody #进程用户,目录权限和此用户相关 , 备份目录要和这个用户保持一致
gid = nobody #进程组,目录权限和此有用户组有关.
use chroot = no
max connections = 20
strict modes = yes
port = 873
pid file = /var/run/rsyncd.pid
lock file =/var/run/rsync.lock

[backup] #这里是认证的模块名,在client端需要指定
path = /home/backup/ #需要做镜像的目录,不可缺少!
comment = This is a test #这个模块的注释信息 
ignore errors #可以忽略一些无关的IO错误
read only = no #设置可以允许上传文件
list = no #不允许列文件
auth users = hening #认证的用户名,如果没有这行则表明是匿名,此用户与系统无关
#密码和用户名表,中间用冒号隔开, 格式如下
#username:password
#这个文件的权限必须是600
secrets file = /etc/rsync.pas				  
#hosts allow = 10.96.9.105,10.96.9.113#允许主机内容ip
#hosts deny = 0.0.0.0/0 #禁止主机
#transfer logging = yes
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock 

====================================================================

5.客户端设置

5.1 window:

rsync -uvzrtopg --delete --progress /cygdrive/e/test svn@192.168.2.212::svn13e < E:\rsync-server\password.txt

问题:
	
	1.密码参数--password-file=不生效, 解决办法
	
	rsync -uvzrtopg --delete --progress /cygdrive/e/test svn@192.168.2.212::svn13e < E:\rsync-server\password.txt

5.2 linux:

rsync -vzrtopg --progress --delete /opt/ backup158@10.246.1.112::APP158 --password-file=/etc/rsync.pas

问题:
	1./etc/rsync.pas权限要设置为600

5.3 跳过指定目录

#必须是相对于同步目录来说,*** 必须使用相对目录 ***, 不能使用绝对目录, 通配符: * , 表示所有文件
#跳过指定的文件夹
rsync -vzrtopg --progress --exclude 'source' --delete /opt/ backup158@10.246.1.112::APP158 --password-file=/etc/rsync.pas
#跳过多个文件夹
rsync -vzrtopg --progress --exclude-from '/home/backup/exclude-dirs' --delete /opt/ backup158@10.246.1.112::APP158 --password-file=/etc/rsync.pas
/home/backup/exclude-dirs内容如下:
#此目录表示  /opt/test目录
test
#此目录表示  /opt/test2目录	
test2/
#此目录表示  /opt/test3目录
test3/
  1. 问题排查
当系统出现问题的时候, 记得去看 /var/log/message文件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值