持之以恒

          記錄本
          posts - 4, comments - 32, trackbacks - 0, articles - 74
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          linux rsync同步設置詳細指南

          Posted on 2012-05-29 17:21 小白19870626 閱讀(16449) 評論(1)  編輯  收藏 所屬分類: linux
           
          配置rsync 同步數據 rpm包安裝rsync及配置


          [root@Hammer home]# rpm -qa |grep rsync #檢查系統是否安裝了rsync軟件包
          rsync-2.6.8-3.1
          [root@Hammer CentOS]# rpm -ivh rsync-2.6.8-3.1.i386.rpm # 如果沒有安裝則手動安裝

          [root@test rsync-3.0.4]# vim /etc/xinetd.d/rsync


          1 配置rsync servervi /etc/xinetd.d/rsync
          將disable=yes改為no

          service rsync
          {
          disable = no
          socket_type = stream
          wait = no
          user = root
          server = /usr/bin/rsync
          server_args = --daemon
          log_on_failure += USERID
          }

          2 配置rsync自動啟動
          [root@test etc]# chkconfig rsync on
          [root@test etc]# chkconfig rsync --list
          rsync on

          3 配置rsyncd.conf
          [root@test etc]# vim rsyncd.conf

          uid = root
          gid = root
          use chroot = no
          max connections = 4
          strict modes = yes
          port = 873
          pid file = /var/run/rsyncd.pid
          lock file = /var/run/rsync.lock
          log file = /var/log/rsyncd.log

          [backup]
          path = /srv
          comment = This is test
          auth users = scihoo
          uid = root
          gid = root
          secrets file = /home/rsync.ps
          read only = no
          list = no


          4 確保etc/services中rsync端口號正確
          [root@test etc]# vim /etc/services
          rsync 873/tcp # rsync
          rsync 873/udp # rsync

          5 配置rsync密碼(在上邊的配置文件中已經寫好路徑)/home/rsync.ps(名字隨便寫,只要和上邊配置文件里的一致即可),格式(一行一個用戶)
          [root@test etc]# vi /home/rsync.ps
          scihoo:scihoo

          6 配置rsync密碼文件權限
          [root@test home]# chown root.root rsync.ps
          [root@test home]# chmod 400 rsync.ps

          7 啟動配置
          [root@test home]# /etc/init.d/xinetd restart
          Stopping xinetd: [ OK ]
          Starting xinetd: [ OK ]

          8 如果xinetd沒有的話,需要安裝一下
          [root@test home]# yum -y install xinetd


          啟動rsync server
          RSYNC服務端啟動的兩種方法
          9、啟動rsync服務端(獨立啟動)
          [root@test home]# /usr/bin/rsync --daemon

          10、啟動rsync服務端 (有xinetd超級進程啟動)
          [root@test home]# /etc/init.d/xinetd reload

          11 加入rc.local
          在各種操作系統中,rc文件存放位置不盡相同,可以修改使系統啟動時把rsync --daemon加載進去。
          [root@test home]# vi /etc/rc.local
          /usr/local/rsync –daemon #加入一行

          12 檢查rsync是否啟動
          [root@test home]# lsof -i :873
          COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
          xinetd 4396 root 5u IPv4 633387 TCP *:rsync (LISTEN)




          客戶端配置
          1 配置三個過程就可以了
          1.1 設定密碼文件
          1.2 測試rsync執行指令
          1.3 將rsync指令放入工作排程(crontab)
          [root@aj1 home]# vi /etc/xinetd.d/rsync

          # default: off
          # description: The rsync server is a good addition to an ftp server, as it \
          # allows crc checksumming etc.
          service rsync
          {
          disable = yes
          socket_type = stream
          wait = no
          user = root
          server = /usr/bin/rsync
          server_args = --daemon
          log_on_failure += USERID
          }

          1.1 配置密碼文件 (注:為了安全,設定密碼檔案的屬性為:600。rsync.ps的密碼一定要和Rsync Server密碼設定案里的密碼一樣)
          [root@aj1 home]# vi rsync.ps
          sciooo

          [root@aj1 home]# chown root.root .rsync.ps # 注意必須給權限
          [root@aj1 home]# chmod 600 .rsync.ps # 必須修改權限

          1.2 從服務器上下載文件
          [root@aj1 rsync-3.0.4]# rsync -avz --password-file=/home/rsync.ps scihoo@192.168.0.206::backup /home/

          從本地上傳到服務器上去
          [root@aj1 rsync-3.0.4]# rsync -avz --password-file=/home/rsync.ps /home scihoo@192.168.0.206::backup


          小白

          評論

          # re: linux rsync同步設置詳細指南   回復  更多評論   

          2013-12-24 14:28 by littledog
          很好用,謝謝提供
          主站蜘蛛池模板: 磐安县| 霍邱县| 涿鹿县| 博湖县| 保亭| 开平市| 静乐县| 安岳县| 手游| 日照市| 灵寿县| 普宁市| 永州市| 新兴县| 彭山县| 龙游县| 南汇区| 长春市| 东港市| 淳安县| 泰安市| 兰西县| 北宁市| 思南县| 辰溪县| 东光县| 雷波县| 新野县| 奉贤区| 灌阳县| 繁峙县| 红安县| 新绛县| 宁明县| 原平市| 钦州市| 达州市| 论坛| 偏关县| 抚顺市| 滨海县|