rsync 設定Linux下目錄同步[final]
1. 在目標機上生成public key .
franklinstby$ cd /home/oracle
franklinstby$ mkdir .ssh
franklinstby$ chmod 700 .ssh
franklinstby$ cd /home/oracle
franklinstby$ ssh-keygen -t rsa
然後可以看到 .ssh 目錄下生成有 id_rsa.pub 檔案。
2. 在源機器上家目錄.ssh下生成authorized_keys檔案,然後將目標機的
public key傳輸源機器已經存在 authorized_keys 檔案中.
備註: 10.17.113.18 是目標機的IP地址 。
franklindb$touch authorized_keys
franklindb$ ssh 10.17.113.18 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
3. 測試連通性 (備註: 10.17.113.15 是源庫的IP地址 )
franklinstby$ssh 10.17.113.15 date
4. 現在可以登入目標機器,開始測試rsync .
franklinstby$rsync -e ssh -av /data/frankdb/arch/
receiving file list ... done
./
1_626_721631640.arc
1_627_721631640.arc
1_628_721631640.arc
1_629_721631640.arc
1_630_721631640.arc
1_631_721631640.arc
sent 349808 bytes received 831141263 bytes 11013126.77 bytes/sec
total size is 1153840128 speedup is 1.39
franklinstby$
5. 設定crontab 及指令碼自動進行不同目錄的同步。
同步目錄中檔案的指令碼如下:
#!/bin/bash
pid=`/sbin/pidof rsync`
if [ "$pid" ]
then
echo
echo "Starting rsync `date`"
echo "Rsync is already running...."
else
echo
echo "Starting rsync `date`"
rsync -e ssh -av /data/frankdb/arch/
echo "Completed rsync `date`"
fi
exit 0
6. 設定linux中的crontab (注意事先建立相應的目錄)
*/10 * * * * bash /u01/run/rsync_arc 1>>/u01/run/log/rsync_arc.log 2>>/u01/run/log/rsync_arc.bad
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-672849/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- rsync 同步目錄
- Linux系統目錄實時同步Linux
- Linux 檔案同步工具之 rsyncLinux
- 在word中怎麼設定目錄 word設定目錄的方法
- linux下的臨時目錄Linux
- linux 利用rsync實現檔案增量同步Linux
- Linux設定中文幫助文件、常見目錄、幫助命令Linux
- linux將掛載在home目錄下的磁碟轉移到根目錄下Linux
- Linux之rsync同步分發指令碼編寫.Linux指令碼
- 獲取和設定pdf目錄
- Linux下rsync安裝與配置Linux
- Linux誤刪除/(根)目錄下usr目錄系統救援方法Linux
- Zblog Nginx 下二級目錄設定偽靜態程式碼Nginx
- 在Linux中,rsync同步時,如何刪除目標資料多出來的資料,即源上不存在,但目標卻存在的檔案或者目錄?Linux
- rsync實時同步
- 資料同步rsync
- Rsync資料同步
- rsync遠端同步
- Linux下高效切換目錄的方法Linux
- 設定儲存檔案的目錄
- Vue設定許可權列表目錄Vue
- 資料同步——rsync遠端同步
- Linux安裝SVN實現自動同步到Web目錄LinuxWeb
- Linux 只複製目錄,不復制目錄下的資料檔案Linux
- 【Linux基礎】Linux目錄Linux
- Linux教程:Linux下如何高效切換目錄?(附影片教程)Linux
- vscode如何設定目錄分級顯示VSCode
- 雲伺服器Linux系統設定時間同步設定伺服器Linux
- PbootCMS修改模板儲存目錄設定二級子目錄boot
- Linux命令---rsyncLinux
- 在linux下顯示中文目錄和檔名Linux
- linux部落格目錄Linux
- Linux批量建立目錄Linux
- Linux 目錄詳解Linux
- linux 目錄及其作用Linux
- linux目錄詳解Linux
- linux 壓縮目錄並排除某個目錄Linux
- rsync+inotify實時同步
- windows bat系列10:批量設定&取消共享目錄WindowsBAT