inotify+rsync实时同步服务部署
環境:服務端 192.168.6.30(安裝 rsync) /data/share
:客戶端 192.168.6.38(安裝 inotufy+rsync)/nfsbackup
主流程:https://www.cnblogs.com/clsn/p/7707822.html#auto_id_28
?
客戶端安裝 inotify
下面開始安裝inotify-tools
[root@static-img ~]# yum install make gcc gcc-c++ ? ? ? ? ? ? ? ? ? ? ? ? ?#安裝編譯工具
[root@static-img ~]# cd /usr/local/src
[root@static-img src]# wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
[root@static-img src]# tar zxvf inotify-tools-3.14.tar.gz
[root@static-img src]# cd inotify-tools-3.14
[root@static-img inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify
[root@static-img inotify-tools-3.14]# make && make install
發現已經成功安裝inotify-tools了
[root@static-img inotify-tools-3.14]# ll -d /usr/local/inotify/
drwxr-xr-x 6 root root 4096 Oct 26 12:01 /usr/local/inotify/
設置系統環境變量
[root@static-img ~]# vim /etc/profile
......
export PATH=$PATH:/usr/local/inotify/bin
[root@static-img ~]# source /etc/profile
添加庫文件
[root@static-img ~]# vim /etc/ld.so.conf
/usr/local/inotify/lib
[root@static-img ~]# ldconfig
修改inotify默認參數(inotify默認內核參數值太小)
查看系統默認參數值
[root@static-img ~]# sysctl -a | grep max_queued_events
fs.inotify.max_queued_events = 16384
[root@static-img ~]# sysctl -a | grep max_user_watches
fs.inotify.max_user_watches = 8192
[root@static-img ~]# sysctl -a | grep max_user_instances
fs.inotify.max_user_instances = 128
修改參數:
[root@static-img ~]# sysctl -w fs.inotify.max_queued_events="99999999"
[root@static-img ~]# sysctl -w fs.inotify.max_user_watches="99999999"
[root@static-img ~]# sysctl -w fs.inotify.max_user_instances="65535"
腳本
#!/bin/bash Path=/data/share backup_Server=192.168.6.30 /usr/local/inotify/bin/inotifywait -mrq --format '%w%f' -e create,close_write,delete /data/share | while read line doif [ -f $line ];thenrsync -az $line --delete rsync_backup@$backup_Server::nfsbackup --password-file=/etc/rsync.passwordelsecd $Path &&\rsync -az ./ --delete rsync_backup@$backup_Server::nfsbackup --password-file=/etc/rsync.passwordfi done?
轉載于:https://www.cnblogs.com/shiina-ringo/p/9963231.html
總結
以上是生活随笔為你收集整理的inotify+rsync实时同步服务部署的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Unity导出APk出错解决方法二
- 下一篇: 近来随笔