rysnc server端
1、vim /etcrsyncd.conf (用户rsync,目录,模块,非系统虚拟用户及密码文件)
2、创建共享目录 /data/www/{www,bbs,blog}
3、创建rsync用户,并授权访问/data/www/
4、创建密码文件,复制配置文件里的路径,然后添加密码内容:‘’虚拟用户名:密码‘’
5、密码文件权限600 chmod 600 /etc/rsync.password
6、rsync --daemon 启动rysnc进程,然后放入/etc/rc.local 开机自启
7、tail /var/log/rsyncd.log 查看rsync运行log
服务器端rsync重启服务
1、 pkill rsync
2、 kill `cat /var/run/rsyncd.pid`
rsync --daemon
查看是否是启动rsync服务
ps -ef|grep rsync
netstat -lnt |grep 873
lsof -i:873
rsync client端
1、密码文件和服务端没有任何关系。命令是--password-file=/etc/rsync.password
2、密码文件内容:‘’密码‘’
3、密码文件权限600 chmod 600 /etc/rsync.password
语法:
pull:
rysnc -avz rsync_backup@10.0.0.11::www /data --password-file=/etc/rsync.password
push
rsync -avz /data/ rsync_backup@10.0.0.11::www --password-file=/etc/rsync.password
排错:
1、防火墙和selinux
2、/var/log/rsyncd.log
3、整个部署流程整体考虑排查
4、操作习惯当做一个大事。如rsyncd.conf的内容都复制一份,部署时直接复制粘贴使用;定位文件时尽可能使用tab补全;使用命令脚本时,先测试脚本本地单独运行没有问题,然后再复制粘贴到脚本中,尽量减少手打。
/etc/rsyncd.conf
##rsyncd.conf start## uid = rsync gid = rsync use chroot = no max connections = 2000 timeout = 600 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log 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 ## Module 1 ## [www] comment = www added by jp at 2019/5/10 9:39 path = /data/www/www/ ## Module 2 ## [bbs] comment = www added by jp at 2019/5/10 9:40 path = /data/www/bbs/ ##################################### [blog] comment = blog added by jp at 2019/5/10 9:41 path = /data/www/blog/
排错
1、rsync: chgrp ".passwd.DKh65W" (in backup) failed: Operation not permitted (1)
[root@nfs01-31 tmp]# rsync -avz /etc/passwd rsync_backup@172.16.1.41::backup
Password:
sending incremental file list
passwd
rsync: chgrp ".passwd.DKh65W" (in backup) failed: Operation not permitted (1)
sent 524 bytes received 125 bytes 432.67 bytes/sec
total size is 1,022 speedup is 1.57
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]
这个可能是配置文件里面没有加fake super = yes
在以前的版本里面不需要,现在版本需要
2、sending incremental file list
rsync: failed to write xattr user.rsync.%stat for "." (in server10): Permission denied (13)
rsync: failed to set times on "." (in server10): Operation not permitted (1)
原因:在rsync服务器端,rsync在模块的目标文件夹中没有权限