概述
这算是个老问题了,每次在windows主机上通过rsync向服务端同步数据的时候都会遇到,这次总结记录下吧。错误代码为:
password file must be owned by root when running as root
在linux上设置rsync的时候,需要将passwordfile设置为600权限。所以在windows上我们也可以用其自带的chmod.exe 执行,其cwgwin客户端默认安装的位置是C:cygwin64bin,报错如下:
![49166f144ffdbf024c198f619f675c95.png](https://img-blog.csdnimg.cn/img_convert/49166f144ffdbf024c198f619f675c95.png)
涉及脚本如下:
![0f42710531823da9c5ec82fec4f59c27.png](https://img-blog.csdnimg.cn/img_convert/0f42710531823da9c5ec82fec4f59c27.png)
看提示应该是权限问题,需设置为600
默认客户端上没有chown.exe这个命令,直接从cwrsync-server的安装路径里拷贝一个过来就可以用了。操作如下:
chmod.exe -c 600 /cygdrive/d/rsync/rsyncd.txtchown.exe administrator /cygdrive/d/rsync/rsyncd.txt
![2bfe4797d8760565f549778f2f49484e.png](https://img-blog.csdnimg.cn/img_convert/2bfe4797d8760565f549778f2f49484e.png)
但是看密码文件修改后的权限如下:多了NULL SID
![74ce43abd84dd420ae12a6060fc14402.png](https://img-blog.csdnimg.cn/img_convert/74ce43abd84dd420ae12a6060fc14402.png)
windows的默认用户一般都是administrator,如果你不是以administrator登录的,请将上面命令中的administrator改成你当前使用的用户名。
![23a31799f75bc3b5bdcc7c6c9912e642.png](https://img-blog.csdnimg.cn/img_convert/23a31799f75bc3b5bdcc7c6c9912e642.png)
改成这样就可以了
这里实际上就是要注意改为当前使用的用户名,其他问题倒不是很大,后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下~
![f4cff41aac941f028a919933f25786b2.gif](https://img-blog.csdnimg.cn/img_convert/f4cff41aac941f028a919933f25786b2.gif)