无码视频在线观看,99人妻,国产午夜视频,久久久久国产一级毛片高清版新婚

  • 始創(chuàng)于2000年 股票代碼:831685
    咨詢(xún)熱線(xiàn):0371-60135900 注冊(cè)有禮 登錄
    • 掛牌上市企業(yè)
    • 60秒人工響應(yīng)
    • 99.99%連通率
    • 7*24h人工
    • 故障100倍補(bǔ)償
    全部產(chǎn)品
    您的位置: 網(wǎng)站首頁(yè) > 幫助中心>文章內(nèi)容

    配置rsync + inotify 實(shí)現(xiàn)數(shù)據(jù)實(shí)時(shí)同步

    發(fā)布時(shí)間:  2012/9/15 18:10:47

    要求:兩臺(tái)Web服務(wù)器實(shí)現(xiàn)數(shù)據(jù)同步(我這里使用的是Centos 6.2-x64)

    服務(wù)器一:172.16.11.126

    服務(wù)器二:172.16.11.127

    一、配置ssh備份源172.16.11.126(這里推薦使用專(zhuān)用的普通用戶(hù),注意相應(yīng)的權(quán)限問(wèn)題,如遇特殊情況使用root用戶(hù)也可以,即不用考慮權(quán)限問(wèn)題了。

    1、新建備份用戶(hù)rget rput 分別用來(lái)上傳下載

       [root@localhost ~]#  useradd rget

       [root@localhost ~]#  useradd rput

       [root@localhost ~]#  passwd rget

       [root@localhost ~]#  passwd rput

    2、確認(rèn)sshd服務(wù)正常啟動(dòng),且允許用戶(hù)rget rput訪問(wèn)

       [root@localhost ~]#   vim /etc/ssh/sshd_config

        

    1.  .......... 

    2.      

    3.  UserDNS no 

    4.      

    5.  AllowUsers rget rput 

    6.   

       [root@localhost ~]# service sshd restart

       [root@localhost ~]# chown -R rput:rput/var/www/html

       [root@localhost ~]# setfacl -R -m user:daemon:rwx /var/www/html /upload

       [root@localhost ~]# getgacl /var/www/html/upload

       [root@localhost ~]# setfacl -m default:user:daemon:rwx /var/www/html/upload/

       [root@localhost ~]# getfacl /var/www/html/upload | grep default

    二、配置rsync源服務(wù)器。

       [root@localhost ~]# yum install rsync

       [root@localhost ~]# /etc/init.d/httpd restart

       [root@localhost ~]# cd /var/www/html/

       [root@localhost html]# /etc/init.d/sshd restart

       [root@localhost html]# vim /etc/rsyncd.conf

    1.    uid = nobody 

    2.    gid = nobody 

    3.    use chroot = yes                 //禁錮在源目錄 

    4.    address = 172.16.11.126          //監(jiān)聽(tīng)地址 

    5.    port 873                         //監(jiān)聽(tīng)端口 

    6.    log file = /var/log/rsyncd.log   //日志文件位置 

    7.    pid file = /var/run/rsyncd.pid   //存放進(jìn)程ID的文件位置 

    8.    hosts allow = 172.16.11.0/24     //允許訪問(wèn)的客戶(hù)機(jī)地址 

    9.    [wwwroot]                        //共享模塊名稱(chēng) 

    10.         path = /var/www/html     //源目錄的世紀(jì)路徑 

    11.         comment = Document Root of www1.dong.com 

    12.         read only = yes          //只讀 

    13.         dont compress = *.gz *.bz2 *.tgz *.zip *.rar *.z  //同步時(shí)不再壓縮的文件類(lèi)型 

    14.         auth users = backuper    //授權(quán)賬戶(hù) 

    15.         secrets file = /etc/rsyncd_users.db               //存放賬戶(hù)信息的數(shù)據(jù)文件 

     

    [root@localhost html]# vim /etc/rsyncd_users.db

    1.    backuper:pwd123 

    [root@localhost html]# chmod 600 /etc/rsyncd_users.db

    [root@localhost html]# rsync –daemon          //啟動(dòng)rsync服務(wù)

    [root@localhost html]# netstat -anpt | grep rsync

    tcp        0      0 192.168.1.1:873             0.0.0.0:*                   LISTEN      5458/rsync

    # 如需關(guān)閉rsync服務(wù)時(shí)  kill $(cat /var/run/rsyncd.pid) 

    [root@localhost html]# vim /etc/xinetd.d/rsync

    1.    # default: off 

    2.    # description: The rsync server is a good addition to an ftp server, a 

    3.    s it \ 

    4.    #       allows crc checksumming etc. 

    5.    service rsync 

    6.   

    7.            disable = no                      //將原有的yes改為no    

    8.            socket_type     = stream 

    9.            wait            = no 

    10.         user            = root 

    11.         server          = /usr/bin/rsync 

    12.         server_args     = --daemon       //確認(rèn)有—daemon服務(wù)選項(xiàng) 

    13.         log_on_failure  += USERID 

    14.

    [root@localhost html]# yum -y install xinetd

    [root@localhost html]# /etc/init.d/xinetd start

    三、使用rsync備份工具 

    SSH備份源

    [root@localhost ~]# rsync -avz rget@172.16.11.126:/var/www/html/ /opt/

    rsync備份源

    [root@localhost ~]# rsync -avz backuper@172.16.11.126::wwwroot /root

       或者

    [root@localhost ~]# rsync -azv rsync://backuper@172.16.11.126/wwwroot /root

    四、配置rsync + inotify實(shí)時(shí)同步

    1、調(diào)整inotify內(nèi)核參數(shù) 

    [root@localhost ~]# cat /proc/sys/fs/inotify/max_queued_events

    16384

    [root@localhost ~]# cat /proc/sys/fs/inotify/max_user_instances

    1024

    [root@localhost ~]# cat /proc/sys/fs/inotify/max_user_watches

    1048576

    [root@localhost ~]# vim /etc/sysctl.conf

    1.    kernel.shmall = 268435456 

    2.    fs.inotify.max_queued_events = 16384 

    3.    fs.inotify.max_user_instances =1024 

    4.    fs.inotify.max_user_watches = 1048576 

    [root@localhost ~]# sysctl -p

    2、安裝inofity-tools工具 (這里我已經(jīng)下載好了inotify-tools-3.14.tar.gz

    [root@localhost ~]# tar -zxvf inotify-tools-3.14.tar.gz

    [root@localhost ~]# cd inotify-tools-3.14

    [root@localhost inotify-tools-3.14]#  ./configure

    [root@localhost inotify-tools-3.14]#  make

    [root@localhost inotify-tools-3.14]# make install

    [root@localhost inotify-tools-3.14]# inotifywait -mrq -e modify,create,attrib,move,delete /var/www/html/ & 

    3、編寫(xiě)觸發(fā)式同步腳本

    [root@localhost inotify-tools-3.14]# vim /opt/inotifity_rsync.sh

    1.    #!/bin/bash 

    2.    INOTIFY_CMD="/usr/local/bin/inotifywait -mrq -e modify,create,attrib,move,delete /var/www/html/" 

    3.    RSYNC_CMD="/usr/bin/rsync -azH --delete /var/www/html/ /nfs/" 

    4.    $INOTIFY_CMD | while read DIRECTORY EVENT FILE 

    5.    do 

    6.            if [ $(pgrep rsync | wc -l) -le 0 ]; then 

    7.                    $RSYNC_CMD 

    8.            fi 

    9.    done  

     

    [root@localhost inotify-tools-3.14]# chmod +x /opt/inotifity_rsync.sh

    [root@localhost inotify-tools-3.14]# echo '/opt/inotifity_rsync.sh' >> /etc/rc.local 

    注意這是在備份源上面的操作

    [root@localhost ~]# vim /etc/exports   172.16.11.126

    1.    /var/www/html   *(rw,no_root_squash)  

    [root@localhost ~]# service  nfs  restart

     把共享的目錄掛在到本地

    [root@localhost ~]# mount 172.16.11.126:/var/www/html/ /nfs/

    備份源與發(fā)起端生成密鑰對(duì) (連接時(shí)不需要進(jìn)入交互式)

    [root@localhost ~]# ssh-keygen -t rsa

    [root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub 172.16.11.127


    本文出自:億恩科技【mszdt.com】

    服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]

  • 您可能在找
  • 億恩北京公司:
  • 經(jīng)營(yíng)性ICP/ISP證:京B2-20150015
  • 億恩鄭州公司:
  • 經(jīng)營(yíng)性ICP/ISP/IDC證:豫B1.B2-20060070
  • 億恩南昌公司:
  • 經(jīng)營(yíng)性ICP/ISP證:贛B2-20080012
  • 服務(wù)器/云主機(jī) 24小時(shí)售后服務(wù)電話(huà):0371-60135900
  • 虛擬主機(jī)/智能建站 24小時(shí)售后服務(wù)電話(huà):0371-60135900
  • 專(zhuān)注服務(wù)器托管17年
    掃掃關(guān)注-微信公眾號(hào)
    0371-60135900
    Copyright© 1999-2019 ENKJ All Rights Reserved 億恩科技 版權(quán)所有  地址:鄭州市高新區(qū)翠竹街1號(hào)總部企業(yè)基地億恩大廈  法律顧問(wèn):河南亞太人律師事務(wù)所郝建鋒、杜慧月律師   京公網(wǎng)安備41019702002023號(hào)
      1
     
     
     
     

    0371-60135900
    7*24小時(shí)客服服務(wù)熱線(xiàn)