Rsync+inotify reports an error during real-time synchronization
Article Directory
1. The error is as follows:
[root@slave abc]#touch test.html
[root@slave abc]#rsync: failed to set times on "/." (in wwwroot): Operation not permitted (1)
rsync: chgrp "/.test.html.pkEkSr" (in wwwroot) failed: Operation not permitted (1)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
rsync: failed to set permissions on "/." (in wwwroot): Operation not permitted (1)
rsync: chgrp "/test.html" (in wwwroot) failed: Operation not permitted (1)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]
Second, analysis cause:
The reason why rsync: failed to set times on “xxxx”: Operation not permitted appears is roughly that there is no operation authority for the folder (or file) xxxx. If the user performing the synchronization is root, there will be no such problem, but rsync can also synchronize without using the root user. If the root user is not used, even if you use -o, -g, it will synchronize to the destination folder. The file users and groups have become synchronous users, but the file permissions can be retained after using -p. When the destination folder (or file) xxxx is modified so that the owner is not the user used by rsync, even if the permissions of the shared directory are 777, the above error will occur.
Before changing the owner and group in the configuration file, check the detailed information of /var/www/html, its owner and group are root,
so even if the directory 777 permissions are given to /var/www/html, rsync service The owner and group of the slave are nobody, and the file created in the directory of the shared file on the slave side still does not have the write permission, so an error
will be reported when the file is created on the slave.
Three, the solution:
The problem is that in the /etc/rsyncd.conf file, you specify the uid and gid. In this way, the directory where you want to write the synchronization file, its owner and group must be in the /etc/rsync.conf file The specified uid and gid are root.
In this way, there will be no errors such as rsync: failed to set times on...!
Master (192.168.2.4)
vim /etc/rsyncd.conf
uid = root
gid = root
#修改配置文件后重启服务
kill `cat /var/run/rsyncd.pid`
netstat -natp | grep rsync
rsync --daemon
netstat -natp | grep rsync
Verify again
Slave(192.168.2.5)
cd /opt/abc
touch test.html
ls
rm -rf test.html
ls
Master(192.168.2.4)
cd /var/www/html
ls