一、配置inotify内核参数
vim /etc/sysctl.conf
fs.inotify.max_queued_events = 16384
fs.inotify.max_user_instances = 1024
fs.inotify.max_user_watches = 1048576
#使其生效
sysctl -p
fs.inotify.max_queued_events = 16384
fs.inotify.max_user_instances = 1024
fs.inotify.max_user_watches = 1048576
二、安装inotify
vim /etc/sysctl.conf
[root@serverC ~]# tar xf inotify-tools-3.14.tar.gz
[root@serverC ~]# cd inotify-tools-3.14
[root@serverC inotify-tools-3.14]# ./configure && make && make install
三、将指定目录加入到监控中
inotifywait -mrq -e modify,create,move,delete,attrib /data
----------------------------
#参数解释
-m:表示持续监控
-r:表示递归整个目录
-q:简化输出信息
-e:指定要监控的时间
modify:对文件内容修改
create:创建类操作
move:移动类操作
delete:删除类操作
attrib:对文件权限的修改
四、修改rsync,使其对操作目录进行读写
vim /etc/rsyncd.conf
uid = nobody
gid = nobody
use chroot = yes
address = 192.168.200.113
port = 873
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
hosts allow = 192.168.200.0/24
[ftp]
path = /data
read only = no
dont compress = *.gz *.bz2 *.zip
auth users = backuper
secrets file = /etc/rsyncd_user.db
----------------------------------------------
#使nobody用户具有对目录的读写权限
chown nobody:nobody /data
#重启服务 ,已经写好服务启动脚本
/etc/init.d/rsyncd restart
- 测试是否能够上传
rsync -avzH --delete /etc/resolv.conf backuper@192.168.200.113::ftp
Password:
sending incremental file list
resolv.conf
rsync: chgrp "/.resolv.conf.2QyMvE" (in ftp) failed: Operation not permitted (1)
sent 146 bytes received 120 bytes 17.16 bytes/sec
total size is 57 speedup is 0.21
rsync error: some files/attrs were not transferred (see previous errors)(code 23) at main.c(1178) [sender=3.1.2]