日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

sersync之不洗澡

發布時間:2025/5/22 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sersync之不洗澡 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

inotiry圖片參考

sersync圖片參考

?

?

?

?

?

inotify文字教程

該軟件對系統有要求,內核2.6以上,并且有如下目錄,后面會講解三個文件用途

? [root@jokerpro ~]# uname -r
? 3.10.0-693.2.2.el7.x86_64

[root@jokerpro ~]# ls -l /proc/sys/fs/inotify/ -rw-r--r-- 1 root root 0 May 31 10:32 max_queued_events -rw-r--r-- 1 root root 0 May 31 10:32 max_user_instances -rw-r--r-- 1 root root 0 May 31 10:32 max_user_watches

安裝該軟件

1,安裝inotify-tools yum install inotify-tools -y 2,命令集工具,即inotifywait和inotifywatch inotifywait:在被監控的文件或目錄上等待特定文件系統事件 (open,close,delete等)發生,執行后處于阻塞狀態,適合在shell腳本中使用 inotifywatch:收集被監控的文件系統使用度統計數據,指文件系統事件發生的次數統計 3,簡單測試 inotifywait -mqr --excludei=a.txt --timefmt '%d/%m/%y%H:%M' --format '%T %w%f' -e create,close_write /backup3

附贈參數說明

inotifywait 參數說明

參數名稱參數說明
-m,–monitor始終保持事件監聽狀態
-r,–recursive遞歸查詢目錄
-q,–quiet只打印監控事件的信息
–excludei排除文件或目錄時,不區分大小寫
-t,–timeout超時時間
–timefmt指定時間輸出格式
–format指定時間輸出格式
-e,–event后面指定刪、增、改等事件
--format : 自定義inotifywait的輸出格式,如--format '%T %w%f',格式解釋如下 %w :顯示被監控目錄的名字 %f : 發生變化的文件名 %T: 使用--timefmt選項中自定義的時間格式

inotifywait events事件說明

事件名稱事件說明
access讀取文件或目錄內容
modify修改文件或目錄內容
attrib文件或目錄的屬性改變
close_write修改真實文件內容
close_nowrite?
close?
open文件或目錄被打開
moved_to文件或目錄移動到
moved_from文件或目錄從移動
move移動文件或目錄移動到監視目錄
create在監視目錄下創建文件或目錄
delete刪除監視目錄下的文件或目錄
delete_self?
unmount卸載文件系統

優化?Inotify

#默認情況下不需要優化

在/proc/sys/fs/inotify目錄下有三個文件,對inotify機制有一定的限制

1 2 3 4 5 [root@web?~]# ll /proc/sys/fs/inotify/ 總用量0 -rw-r--r--1?root?root?09月923:36?max_queued_events -rw-r--r--1?root?root?09月923:36?max_user_instances -rw-r--r--1?root?root?09月923:36?max_user_watches

?

#文件說明 max_user_watches #設置inotifywait或inotifywatch命令可以監視的文件數量(單進程) max_user_instances #設置每個用戶可以運行的inotifywait或inotifywatch命令的進程數 max_queued_events #設置inotify實例事件(event)隊列可容納的事件數量
1 2 [root@web?~]# echo 50000000>/proc/sys/fs/inotify/max_user_watches -- 把他加入/etc/rc.local就可以實現每次重啟都生效 [root@web?~]# echo 50000000>/proc/sys/fs/inotify/max_queued_events

?

附贈一個監控腳本,rsync+inotify都應該裝在邏輯服上,推送到備份服務器上

#!/bin/bash # The author is joker, which is used to listen to directories and synchronize files. # 判軟件安裝 inotify_order=`which inotifywait 1>/dev/null 2>&1` inotify_state=`echo $?` rsync_order=`which rsync 1>/dev/null 2>&1` rsync_state=`echo $?` if [ $inotify_state -eq 1 -a $rsync_state -eq 1 ];thenyum install inotify-tools rsync -ysleep1sh $0 else # 腳本是時刻監控path目錄發生的變化,應該存放于rsync的客戶端,即邏輯服務器 # 被監控目錄 localpath=/joker/ # rsync驗證用戶,密碼 auth_user=rsync_backup cat >/etc/rsync.passwd<<EOF woshimima EOF passwd_file=/etc/rsync.passwd chmod 600 /etc/rsync.passwd # 備份服務器IP ip="60.205.188.107" # 備份服務器備份目錄,匹配rsync模塊 backupdir=gameserver1 # m保持監聽狀態,r遞歸查詢目錄,q打印監控事件信息,w顯示被監控目錄名字,f發生變化的文件名 inotifywait -mrq --format '%w%f' -e close_write,delete $localpath \ |while read file doif [ -f $file ];thenrsync -az $file --delete $auth_user@$ip::$backupdir --password-file=$passwd_fileelsecd $localpathrsync -az ./ --delete $auth_user@$ip::$backupdir --password-file=$passwd_filefi done fi

?

sersync文字教程

包在自己的云服務器目錄上/joker,讀者如果沒有該目錄,請從網上查找

1,想同步什么文件 6-11 6 <filter start="false"> 7 <exclude expression="(.*)\.svn"></exclude> 8 <exclude expression="(.*)\.gz"></exclude> 9 <exclude expression="^info/*"></exclude> 10 <exclude expression="^static/*"></exclude> 11 </filter> 2,inotify監控屬性 12-21 12 <inotify> 13 <delete start="true"/> 14 <createFolder start="true"/> 15 <createFile start="false"/> 16 <closeWrite start="true"/> 17 <moveFrom start="true"/> 18 <moveTo start="true"/> 19 <attrib start="false"/> 20 <modify start="false"/> 21 </inotify> 3,sersync配置 23-44 其中 24-28 目錄 24 <localpath watch="/opt/tongbu"> # 本地推送目錄 25 <remote ip="127.0.0.1" name="tongbu1"/> #rsync服務器ip和模塊 26 <!--<remote ip="192.168.8.39" name="tongbu"/>--> 27 <!--<remote ip="192.168.8.40" name="tongbu"/>--> 28 </localpath> 29-35 rsync命令 29 <rsync> 30 <commonParams params="-artuz"/> # 默認avz 31 <auth start="true" users="root" passwordfile="/etc/rsync.pas"/> # 開啟驗證,用戶,密碼 32 <userDefinedPort start="false" port="874"/<!port=874 --> # 端口 33 <timeout start="true" time="100"/><!-- timeout=100 --> # 客戶端超時 34 <ssh start="false"/> 35 </rsync> 4,日志 36 36 <failLogpath="/tmp/rsync_fail_log.sh"timeToExecute="60"/><!--default every 60mins execute once-->

啟動執行

/mnt/sersync/bin/sersync -d -r -o /mnt/sersync/conf/confxml.xml

附贈啟動參數

[root@jokerpro bin]# /service/script/sersync/bin/sersync -h set the system param execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events parse the command param _______________________________________________________ 參數-d:啟用守護進程模式 參數-r:在監控前,將監控目錄與遠程主機用rsync命令推送一遍 參數-n: 指定開啟守護線程的數量,默認為10個 參數-o:指定配置文件,默認使用confxml.xml文件 參數-m:單獨啟用其他模塊,使用 -m refreshCDN 開啟刷新CDN模塊 參數-m:單獨啟用其他模塊,使用 -m socket 開啟socket模塊 參數-m:單獨啟用其他模塊,使用 -m http 開啟http模塊 不加-m參數,則默認執行同步程序

注意與事項

邏輯服務器安裝inotify+sersync+rsync命令備份服務器安裝rsync的daemon模式邏輯服務器數據產生目錄發生數據變化,就會推送到備份服務器上一般錯誤還是發生在rsync上,請看上一篇文章,搞懂rsync,虛擬賬號,rsync賬號,目錄權限

附贈sersync腳本,執行于邏輯服上

#!/bin/bash # The author is joker, applied to file synchronization. # rsync 驗證用戶,密碼 author=rsync_backup password=woshimima # 判軟件安裝 inotify_order=`which inotifywait 1>/dev/null 2>&1` inotify_state=`echo $?` rsync_order=`which rsync 1>/dev/null 2>&1` rsync_state=`echo $?` if [ $inotify_state -eq 1 -a $rsync_state -eq 1 ];thenecho -e "\033[31m 紅色字,正在安裝inotify,rsync \033[0m" yum install inotify-tools rsync -ysleep1sh $0 else# 只需要密碼 cat>/etc/rsync.passwd<<EOF $password EOFchmod 600 /etc/rsync.passwd# 查找xml文件位置sersync_path=`pwd`confxml_path=`cd ..&&pwd`# -d 守護進程模式,-r如果是第一次監控,將全量推送一次,后續增量,-o,指定配置文件$sersync_path/sersync -d -r -o $confxml_path/conf/confxml.xmlsersync_process=`ps -ef|grep sersync|grep -v grep|wc -l`if [ $sersync_process -ge 1 ];thenecho -e "\033[32m 綠色字,sersync 啟動成功 \033[0m"elseecho -e "\033[31m 紅色字,啟動失敗,檢查inotify,rsync是否安裝與正常啟動 \033[0m" fi fi

?

轉載于:https://www.cnblogs.com/jokerbj/p/9115164.html

總結

以上是生活随笔為你收集整理的sersync之不洗澡的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。