日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
CentOS7Rsync服務(wù)搭建-Rsync+Inotify架構(gòu)實(shí)現(xiàn)實(shí)時(shí)同步

關(guān)于centos7版本上面搭建rsync服務(wù)并且實(shí)現(xiàn)實(shí)時(shí)同步
之前一直是在6版本上面搭建rsync服務(wù),在7版本上面折騰了半天。此處總結(jié)下
inotify下載地址:http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz

創(chuàng)新互聯(lián)公司服務(wù)熱線:028-86922220,為您提供成都網(wǎng)站建設(shè)網(wǎng)頁設(shè)計(jì)及定制高端網(wǎng)站建設(shè)服務(wù),創(chuàng)新互聯(lián)公司網(wǎng)頁制作領(lǐng)域十多年,包括成都火鍋店設(shè)計(jì)等多個(gè)行業(yè)擁有多年的網(wǎng)站推廣經(jīng)驗(yàn),選擇創(chuàng)新互聯(lián)公司,為企業(yè)保駕護(hù)航!

環(huán)境說明:

centos7版本上面已經(jīng)默認(rèn)安裝了rsync和xinetd服務(wù)

[ root@rh6 ~ ]# rpm -ql rsync           --在6版本上面執(zhí)行此命令可以看到xinetd服務(wù)配置文件下面有rsync的子配置文件

/etc/xinetd.d/rsync

[ root@rh6 ~ ]# ls /etc/xinetd.d/sync

/etc/xinetd.d/rsync

[ root@centos7_3 ~ ]# rpm -ql rsync          --在7版本上面執(zhí)行此命令卻找不到這樣的配置文件,ls查看提示沒有此文件

[ root@centos7_3 ~ ]# ls /etc/xinetd.d/sync

ls: cannot access /etc/xinetd.d/rsync: No such file or directory

————————————————————————————————————————————————————————

實(shí)驗(yàn)環(huán)境:兩臺centos7版本的宿主機(jī)

  1. 客戶端:172.16.27.25
  2. 服務(wù)端:172.16.27.26

具體步驟:

  • 服務(wù)端
  • [root@cc4 ~]# rpm -aq |grep xinetd
    xinetd-2.3.15-13.el7.x86_64
    [root@cc4 ~]# rpm -aq |grep rsync
    rsync-3.0.9-17.el7.x86_64
  • [root@cc4 ~]# vim /etc/xinetd.d/rsync   --說明:修改xinetd服務(wù)下面的配置文件,將rsync交給xinetd管理。此配置文件在7版本默認(rèn)上面是沒有的,我是直接從6版本復(fù)制過來的,也可以手寫下面內(nèi)容
    # default: off
    # description: The rsync server is a good addition to an ftp server, as it \
    #      allows crc checksumming etc.
    service rsync
    {
            disable              = no      --將原來的yes改為no
            flags                  = IPv6
            socket_type      = stream
            wait                  = no
            user                  = root
            server                = /usr/bin/rsync
            server_args      = --daemon
            log_on_failure  += USERID
    }
  • [root@cc4 ~]# vim /etc/rsyncd.conf      --修改配置文件發(fā)布共享目錄
    [test]
            path = /test                --本地共享目錄
            auth user = user1      --指定用戶同步
            secrets file = /etc/rsyncd.secrets      --指定保存用戶密碼文件
  • [root@cc4 ~]# systemctl restart xinetd    --啟動(dòng)服務(wù)
  • [root@cc4 ~]# vim /etc/rsyncd.secrets    --創(chuàng)建安全用戶
    user1:123
  • [root@cc4 ~]# chmod 600 /etc/rsyncd.secrets    --設(shè)置安全用戶文件的權(quán)限,不能被其他人查看
  • [root@cc4 ~]# mkdir /test     --創(chuàng)建共享目錄
    [root@cc4 ~]# touch /test/file{1..10}    --此處為了測試,創(chuàng)建幾個(gè)文件
    [root@cc4 ~]# ls /test/
    file1  file10  file2  file3  file4  file5  file6  file7  file8  file9
  •  
  • 客戶端測試:
  • [root@cc3 ~]# rsync -a 172.16.27.26::
    test   
  • [root@cc3 date]# ls
    [root@cc3 date]# rsync -av user1@172.16.27.26::test /date
    receiving incremental file list
    ./
    file1
    file10
    file2
    file3
    file4
    file5
    file6
    file7
    file8
    file9
    sent 219 bytes  received 524 bytes  1486.00 bytes/sec
    total size is 0  speedup is 0.00
    [root@cc3 date]# ls        --可以看見成功從上面同步過來了。
    file1  file10  file2  file3  file4  file5  file6  file7  file8  file9
  •  
  • 通過inotify+rsync架構(gòu)實(shí)現(xiàn)實(shí)時(shí)同步
  • 環(huán)境說明:要求node1主機(jī)上面的/node1目錄發(fā)生新的創(chuàng)建,刪除,移動(dòng),以及文件屬性信息改變時(shí),自動(dòng)同不到node2主機(jī)的/node2目錄
  • node1主機(jī): IP  172.16.27.25
    node2主機(jī): IP  172.16.27.26
  • 具體步驟:
  • node1端:
  • [root@cc3 tmp]# ls /tmp/inotify-tools-3.14.tar.gz
    /tmp/inotify-tools-3.14.tar.gz
  • [root@cc3 tmp]# tar -xf inotify-tools-3.14.tar.gz
    [root@cc3 tmp]# cd inotify-tools-3.14/
    [root@cc3 inotify-tools-3.14]# 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@cc3 ~]# ./configure && make && make install    --安裝軟件
  • [root@cc3 ~]# vim /tmp/1.sh
    #!/bin/bash
    /usr/local/bin/inotifywait -mrq -e modify,create,move,delete,attrib /node1 |while read events
            do
            rsync -a --delete /node1 172.16.27.26::test
            echo "`date +'%F %T'` 出現(xiàn)事件 $events" >>/tmp/rsync.log 2>&1
            done[root@cc3 ~]#mkdir /node1
    [root@cc3 ~]# touch /node1/testa{1..5}

  • node2端:
  • [root@cc4 ~]# vim /etc/rsyncd.conf
    [test]
            path = /node2/
            read only = false
            uid = root
            gid = root
    [root@cc4 ~]# mkdir /node2
    [root@cc4 ~]# ls /node2/       --此時(shí)查看,該目錄里面什么文件都沒有
    [root@cc4 ~]# systemctl restart xinetd
  • 測試驗(yàn)證:
    在node1端執(zhí)行腳本并且放在后臺執(zhí)行,并且創(chuàng)建文件,再看tmp下面是否有創(chuàng)建文件后腳本執(zhí)行報(bào)的日志信息
    [root@cc3 ~]# nohup sh /tmp/1.sh &
    [1] 14720
    [root@cc3 ~]# nohup: ignoring input and appending output to ‘nohup.out’  --此處直接回車

    [root@cc3 ~]# echo haha >>/node1/file1
    [root@cc3 ~]# ls /tmp/rsync.log
    /tmp/rsync.log
    [root@cc3 ~]# cat /tmp/rsync.log
    2017-10-10 15:55:01 出現(xiàn)事件 /node1/ CREATE file1
    2017-10-10 15:55:01 出現(xiàn)事件 /node1/ MODIFY file1

    在node2端檢查驗(yàn)證
    [root@cc4 ~]# ls /node2/
    file1  testa1  testa2  testa3  testa4  testa5
    [root@cc4 ~]# cat /node2/file1
    haha
    ---------測試發(fā)現(xiàn)在node1端創(chuàng)建的文件實(shí)時(shí)同步過來到node2上面了。

  • 總結(jié):其實(shí)在6系統(tǒng)和7系統(tǒng)上面搭建rsync服務(wù)是一樣的,只是在7上面改版了,系統(tǒng)默認(rèn)沒有/etc/xinetd.d/rsync配置文件,需要自己手動(dòng)創(chuàng)建。其余配置完全一樣

 

 


分享標(biāo)題:CentOS7Rsync服務(wù)搭建-Rsync+Inotify架構(gòu)實(shí)現(xiàn)實(shí)時(shí)同步
分享地址:http://www.5511xx.com/article/dpcogjp.html