linux_6.5_install_inotify-tools-3.13

–=安装的前提是rsync服务已经安装完成,客户端可以拉取和推送数据成功==

一、安装前检查
–==============从内核和目录里面查看是否支持inotify

[root@rsync_client ~]# uname -r
2.6.32-431.el6.x86_64 //要求2.6.13以上的内核

[root@rsync_client ~]# ll /proc/sys/fs/inotify/
total 0
-rw-r–r-- 1 root root 0 Jul 7 14:24 max_queued_events //监控时间队列
-rw-r–r-- 1 root root 0 Jul 7 14:24 max_user_instances //最多监控实例数
-rw-r–r-- 1 root root 0 Jul 7 14:24 max_user_watches //每个实例最多监控的文件数

[root@rsync_client ~]# vim /etc/sysctl.conf //末尾添加三行内容

[root@rsync_client ~]# cat >>/etc/sysctl.conf<< EOF

fs.inotify.max_queued_events = 32768
fs.inotify.user_instances = 1024
fs.inotify.max_user_watches = 900000000
EOF

[root@rsync_client ~]# sysctl -p //使配置生效

–================检查是否有安装inotify 如果没有就安装
rpm -qa inotify-tools

二、安装
–==inotify工具下载,源码包inotify-tools-3.13.tar.gz=
https://sourceforge.net/projects/inotify-tools/files/latest/download
[root@rsync_client software]# tar -zxf inotify-tools-3.13.tar.gz
[root@rsync_client software]# echo $?
0
[root@rsync_client software]# ls
inotify-tools-3.13 inotify-tools-3.13.tar.gz
[root@rsync_client software]# cd inotify-tools-3.13
[root@rsync_client inotify-tools-3.13]# ls
aclocal.m4 ChangeLog config.h.in configure COPYING INSTALL libinotifytools Makefile.am man NEWS src
AUTHORS config.guess config.sub configure.ac depcomp install-sh ltmain.sh Makefile.in missing README
[root@rsync_client inotify-tools-3.13]# ./configure --prefix=/usr/local/inotify-tools
[root@rsync_client inotify-tools-3.13]# echo $?
0
[root@rsync_client inotify-tools-3.13]# make && make install
[root@rsync_client inotify-tools-3.13]# echo $?
0

[root@rsync_client inotify-tools-3.13]# ln -s /usr/local/inotify-tools/ /usr/local/inotify
[root@rsync_client inotify-tools-3.13]# ll /usr/local
total 44
drwxr-xr-x. 2 root root 4096 Sep 3 2018 bin
drwxr-xr-x. 2 root root 4096 Jun 28 2011 etc
drwxr-xr-x. 2 root root 4096 Jun 28 2011 games
drwxr-xr-x. 2 root root 4096 Jun 28 2011 include
lrwxrwxrwx. 1 root root 25 Jul 7 15:24 inotify -> /usr/local/inotify-tools/

三、inotify测试

–==========监控目录并进行同步
[root@rsync_client script]# cat inotify1.sh
#!/bin/bash
host=192.168.16.66
src=/data
dest=lbw
user=rsync_backup
rsync_passfile=/etc/rsync.password
inotify_home=/usr/local/inotify/

#judge
if [ ! -e “KaTeX parse error: Expected 'EOF', got '\ ' at position 8: src" ] \̲ ̲|| [ ! -e "rsync_passfile” ]
|| [ ! -e “${inotify_home}/bin/inotifywait” ]
|| [ ! -e “/usr/bin/rsync” ];
then
echo “check file and folder”
exit 9
fi

${inotify_home}/bin/inotifywait -mrq --timefmt ‘%d/%m/%y %H:%M’ --format ‘%T %w%f’ -e create,close_write,delete,attrib $src
| while read file
do
cd $src && rsync -aruz -R --delete ./ --timeout=100 $user@$host::$dest --password-file=${rsync_passfile}
done
exit 0

[root@rsync_client data]# touch {a…z}
[root@rsync_client data]# ls
a b c d e f g h i j k l m n o p q r s t u v w x y z
[root@rsync_server data]# ls
a b c d e f g h i j k l m n o p q r s t u v w x y z

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值