Rsync實操

Rsync實操

一.rsync命令

?#類似于cp[root@user2 ~]# rsync info.sh root@192.168.168.130:/rootroot@192.168.168.130's password: [root@user1 ~]# lsanaconda-ks.cfg  ceph-release-1-1.el7.noarch.rpm  info.sh

二、使用rsync備份push方式

  • 服務器:server 192.168.168.130(需要進行數據備份的主機)

  • 客戶端:client 192.168.168.131 (備份存儲的主機)

?# 在客戶端上編寫rsync配置文件,創建一個存放備份的同步目錄[root@targetpc ~]# vim /etc/rsyncd.conf[root@targetpc ~]# cat /etc/rsyncd.confport=873address = 192.168.168.131 #客戶端地址uid = rootgid = rootuse chroot = yesmax connections = 4pid file = /var/run/rsyncd.pidlock file = /var/run/rsync.locklog file = /var/log/rsyncd.logmotd file = /etc/rsyncd.motd #可弄可不弄hosts allow = 192.168.168.0/24 #允許哪個網段傳輸數據[data] #網絡名path = /data/backup #數據存儲目錄 真實名 需要創建comment = bakcup dataread only = falselist = yes#獨立驗證auth users = rsyncusersecrets file = /etc/rsync.passwd #自己創建?#設置獨立賬戶密碼[root@targetpc ~]# vim /etc/rsync.passwd#添加權限[root@targetpc ~]# chmod 600 /etc/rsync.passwd[root@targetpc ~]# vim /etc/rsync.passwd[root@targetpc ~]# cat /etc/rsync.passwdrsyncuser:123#設置標語[root@targetpc ~]# echo "來送數據了" > /etc/rsyncd.motd[root@targetpc ~]# systemctl restart rsyncd?#測試 服務器測試[root@sourcepc data]# ls1.txt ?2.txt ?3.txt  aaa[root@sourcepc data]# rsync -avz /data/* rsyncuser@192.168.168.131::data來送數據了?Password: sending incremental file list3.txt?sent 155 bytes  received 36 bytes ?20.11 bytes/sectotal size is 0  speedup is 0.00#客戶主機結果[root@targetpc backup]# ls1.txt ?2.txt ?3.txt  aaa
??

三、測試--delete命令push

?#--delete實驗 不能與*同時用[root@targetpc backup]# ls1.txt ?2.txt ?3.txt  aaa  del.txt[root@sourcepc data]# ls1.txt ?2.txt ?3.txt  aaa?[root@sourcepc data]# rsync -avz --delete /data/* rsyncuser@192.168.168.131::data來送數據了?Password: sending incremental file list?sent 119 bytes  received 13 bytes ?13.89 bytes/sectotal size is 0  speedup is 0.00[root@targetpc backup]# ls1.txt ?2.txt ?3.txt  aaa  del.txt#使用--delete時 去掉*[root@sourcepc data]# rsync -avz --delete /data/ rsyncuser@192.168.168.131::data來送數據了?Password: sending incremental file listdeleting del.txt./?sent 149 bytes  received 31 bytes ?18.95 bytes/sectotal size is 0  speedup is 0.00[root@targetpc backup]# ls1.txt ?2.txt ?3.txt  aaa

四、免密同步

?
#免密[root@sourcepc data]# echo "123" > /etc/rsync.passwd[root@sourcepc data]# rsync -avz --delete /data/ rsyncuser@192.168.168.131::data --password-file=/etc/rsync.passwd #注意時--password 全稱來送數據了?ERROR: password file must not be other-accessiblersync error: syntax or usage error (code 1) at authenticate.c(196) [sender=3.1.2]#設置權限[root@sourcepc data]# chmod 600 /etc/rsync.passwd[root@sourcepc data]# rsync -avz --delete /data/ rsyncuser@192.168.168.131::data --password-file=/etc/rsync.passwd來送數據了?sending incremental file list?sent 142 bytes  received 13 bytes ?23.85 bytes/sectotal size is 0  speedup is 0.00

五、pull模式

以上的同步過程都是服務端主動推送數據給目標主機,這里演示下目標主機主動拉取數據進行同步

?
# 服務端上配置/etc/rsyncd.conf文件port=873address = 192.168.168.130uid = rootgid = rootuse chroot = yesmax connections = 4pid file = /var/run/rsyncd.pidlock file = /var/run/rsync.locklog file = /var/log/rsyncd.log#motd file = /etc/rsyncd.motdhosts allow = 192.168.168.0/24[data]path = /datacomment =  dataread only = falselist = yesauth users = rsyncusersecrets file = /etc/rsync.passwd# 認證文件[root@sourcepc log]# cat  /etc/rsync.passwdrsyncuser:123# 服務端上啟動rsync[root@sourcepc log]# systemctl start rsyncd[root@sourcepc log]# systemctl status rsyncd● rsyncd.service - fast remote file copy program daemonLoaded: loaded (/usr/lib/systemd/system/rsyncd.service; disabled; vendor preset: disabled)Active: active (running) since 四 2025-06-19 20:35:23 CST; 2s agoMain PID: 2097 (rsync)CGroup: /system.slice/rsyncd.service└─2097 /usr/bin/rsync --daemon --no-detach?6月 19 20:35:23 sourcepc systemd[1]: Started fast remote file copy program daemon.# 目標主機上拉取數據[root@client data]# rsync -avz rsyncuser@192.168.168.130::data /dataPassword: receiving incremental file list./1.txt2.txt3.txtaaa12/bbb/ccc/?sent 100 bytes  received 305 bytes ?162.00 bytes/sectotal size is 0  speedup is 0.00[root@client data]# ls1.txt ?2.txt ?3.txt  aaa12  backup  bbb  ccc

六、rsync+sersync 實現數據實時同步push

?#在需要備份主機處 安裝sersync 使用的外部安裝包#使用rz 調入安裝包[root@sourcepc ~]# rz[root@sourcepc ~]# lsanaconda-ks.cfg ? ? ? ? ? ? ? ?  info.shceph-release-1-1.el7.noarch.rpm  sersync2.5.4_64bit_binary_stable_final.tar.gz#解壓[root@sourcepc ~]# tar -xf sersync2.5.4_64bit_binary_stable_final.tar.gz[root@sourcepc ~]# lsanaconda-ks.cfg ? ? ? ? ? ? ? ?  GNU-Linux-x86  sersync2.5.4_64bit_binary_stable_final.tar.gzceph-release-1-1.el7.noarch.rpm  info.sh#進行配置[root@sourcepc ~]# cd GNU-Linux-x86/[root@sourcepc GNU-Linux-x86]# lsconfxml.xml  sersync2[root@sourcepc GNU-Linux-x86]# vim confxml.xml #修改的部分</filter><inotify><delete start="true"/><createFolder start="true"/><createFile start="true"/><closeWrite start="true"/><moveFrom start="true"/><moveTo start="true"/><attrib start="true"/><modify start="true"/></inotify>?<sersync><localpath watch="/data"><remote ip="192.168.168.131" name="data"/><!--<remote ip="192.168.8.39" name="tongbu"/>--><!--<remote ip="192.168.8.40" name="tongbu"/>--></localpath><rsync><commonParams params="-artuz"/><auth start="true" users="rsyncuser" passwordfile="/etc/rsync.passwd"/><userDefinedPort start="false" port="874"/><!-- port=874 --><timeout start="false" time="100"/><!-- timeout=100 --><ssh start="false"/></rsync>?#執行文件[root@sourcepc GNU-Linux-x86]# ./sersync2 -d -r -o ./confxml.xml set the system paramexecute:echo 50000000 > /proc/sys/fs/inotify/max_user_watchesexecute:echo 327679 > /proc/sys/fs/inotify/max_queued_eventsparse the command paramoption: -d ? ?  run as a daemonoption: -r ? ?  rsync all the local files to the remote servers before the sersync workoption: -o ? ?  config xml name:  ./confxml.xmldaemon thread num: 10parse xml config filehost ip : localhost ? ? host port: 8008will ignore the inotify createFile event daemon start,sersync run behind the console use rsync password-file :user is rsyncuserpasswordfile is ? ? ? ? /etc/rsync.passwdconfig xml parse successplease set /etc/rsyncd.conf max connections=0 Manuallysersync working thread 12 ?= 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads) Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)please according your cpu ,use -n param to adjust the cpu rate------------------------------------------rsync the directory recursivly to the remote servers onceworking please wait...execute command: cd /data && rsync -artuz -R --delete ./ rsyncuser@192.168.168.131::data --password-file=/etc/rsync.passwd >/dev/null 2>&1 [root@sourcepc GNU-Linux-x86]# run the sersync: watch path is: /data?#測試[root@sourcepc data]# ls1.txt ?2.txt ?3.txt  aaa[root@sourcepc data]# mkdir bbb?[root@targetpc backup]# ls1.txt ?2.txt ?3.txt  aaa  bbb??[root@sourcepc data]# ls1.txt ?2.txt ?3.txt  aaa  bbb  ccc[root@sourcepc data]# mv aaa aaa12[root@targetpc backup]# ls1.txt ?2.txt ?3.txt  aaa12  bbb  ccc

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/910028.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/910028.shtml
英文地址,請注明出處:http://en.pswp.cn/news/910028.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Java常見八股-(6.算法+實施篇)

Java常見八股-&#xff08;1.Java基礎篇&#xff09; Java常見八股-&#xff08;2.Java高級篇&#xff09; Java常見八股-&#xff08;3.MySQL篇&#xff09; Java常見八股-&#xff08;4.前端篇&#xff09; Java常見八股-&#xff08;5.框架篇&#xff09; 目錄 一、算…

阿里云部署的SMTP服務器安全攻防實錄:深度解析攻擊、防護與加固

阿里云部署的SMTP服務器安全攻防實錄&#xff1a;深度解析攻擊、防護與加固 一次針對云上SMTP服務的持續攻擊事件&#xff0c;揭示了郵件中繼服務面臨的多重安全挑戰。本文將深入剖析攻擊手法、防護策略與系統性加固方案。 某企業在阿里云上部署的Postfix SMTP服務器近期遭遇…

HTTP與HTTPS深度解析:從明文傳輸到安全通信的演進之路

引言 在互聯網的早期&#xff0c;HTTP&#xff08;超文本傳輸協議&#xff09;作為Web通信的基石&#xff0c;憑借簡單高效的特性推動了萬維網的爆發式增長。但隨著互聯網從“信息共享”向“價值交互”演進&#xff0c;HTTP的明文傳輸特性逐漸暴露致命缺陷——用戶的每一次點擊…

滲透實戰:繞過沙箱機制的反射型XSS

Lab 24&#xff1a;利用 xss 繞過 csrf 防御 依然是留言板的問題可以執行<h1>標簽 進入修改郵箱的界面&#xff0c;修改抓包 這里構造修改郵箱的代碼 <script> var req new XMLHttpRequest(); req.onload handleResponse; req.open(get,/my-account,true); req…

K8S篇之利用deployment實現滾動平滑升級

一、更新策略 在 Kubernetes (K8s) 中,滾動平滑升級(Rolling Update)是一種無縫更新部署的方式,允許你在不中斷服務的情況下逐步更新應用程序。這是 Kubernetes 默認的 Deployment 更新策略,它會按照指定的步幅逐步替換 Pods,確保在新版本的應用程序沒有完全替換舊版本的…

【Dify 案例】【MCP實戰】【一】【前置配置】

MCP(Model Context Protocol,模型上下文協議) ,2024年11月底,由Anthropic 推出的一種開放標準。旨在為大語言模型(LLM)提供統一的、標準化方式與外部數據源和工具之間進行通信。 MCP 作為一種標準化協議,極大地簡化了大語言模型與外部世界的交互方式,使開發者能夠以統…

2025高考志愿填報張雪峰資料合集

2025高考志愿填報課程&#xff0c;張雪峰專業指導&#xff01;包含61節課&#xff0c;93個專業詳解&#xff0c;總計1500分鐘視頻。 獨家各省資料包&#xff01;新舊高考政策全覆蓋&#xff0c;適合高三家長和考生。內容整理自互聯網&#xff0c;無償分享&#xff0c;如有侵權&…

Nginx+Tomcat負載均衡群集

一.案例:部署Tomcat 1.案例分析 1.1案例概述 京北點指科技有限公司發布V3版移聯建站管理系統&#xff0c;該項目為Java 語言開發的Web 站點。目前&#xff0c;IBM 的 WebSphere 及 0racle 的 WebLogic 占據了市面上 Java 語言 Web 站點的大部分份額。這兩種軟件以其無與倫比…

華為云Flexus+DeepSeek征文|基于華為云一鍵部署dify平臺構建合同審核助手應用實踐

目錄 前言 1 華為云一鍵部署Dify平臺 1.1 華為云Dify平臺介紹 1.2 部署過程介紹 1.3 登錄Dify平臺 2 接入華為云 ModelArts Studio 的 DeepSeek 大模型 2.1 獲取調用模型服務信息 2.2 在 Dify 中配置模型 3 構建合同審核助手應用 3.1 簡要介紹合同審核助手 3.2 開始…

三種經典算法無人機三維路徑規劃對比(SMA、HHO、GWO三種算法),Matlab代碼實現

代碼功能 該MATLAB代碼用于對比三種元啟發式優化算法&#xff08;SMA、HHO、GWO三種算法&#xff0c; SMA黏菌算法、HHO哈里斯鷹優化算法、GWO灰狼優化算法&#xff09; 在特定優化問題上的性能&#xff0c;運行環境MATLABR2020b或更高 &#xff1a; 初始化問題模型&#xff…

設計模式精講 Day 8:組合模式(Composite Pattern)

【設計模式精講 Day 8】組合模式&#xff08;Composite Pattern&#xff09; 開篇 在“設計模式精講”系列的第8天&#xff0c;我們將深入講解組合模式&#xff08;Composite Pattern&#xff09;。組合模式是一種結構型設計模式&#xff0c;它允許將對象組合成樹形結構以表示…

【Dify學習筆記】:RagFlow接入Dify基礎教程

RagFlow接入Dify基礎教程 如果RagFlow還沒部署&#xff0c;可參考我另一篇本地部署文章&#xff1a;【Dify學習筆記】&#xff1a;本地部署RagFlow適配Dify 一、RagFlow 1. 配置模型 點擊&#xff1a;頭像 > Model providers 添加模型供應商、設置默認模型Set default …

Apache ECharts-02.入門案例

一.入門案例 官網下載&#xff1a;下載 - Apache ECharts&#xff0c;下載echarts.js文件&#xff0c;下載好后在其同一個文件夾下創建html文件即可。 <!DOCTYPE html> <html><head><meta charset"utf-8" /><title>ECharts</title…

社群經濟視閾下開源AI智能名片鏈動2+1模式與S2B2C商城小程序在私域電商中的融合應用研究

摘要&#xff1a;在數字經濟與社交網絡深度融合的背景下&#xff0c;付費社群憑借精準用戶篩選、高價值成員聚合及強信任關系鏈等優勢&#xff0c;成為私域電商發展的核心載體。本文基于社群經濟理論&#xff0c;結合“開源AI智能名片鏈動21模式S2B2C商城小程序”的技術與商業邏…

【Tools】Mac brew工具

Homebrew&#xff08;簡稱 brew&#xff09;是 macOS&#xff08;也支持 Linux&#xff09;上的一款 包管理工具&#xff0c;它的作用類似于&#xff1a; Ubuntu 下的 aptCentOS 下的 yumArch Linux 下的 pacman 一句話概括&#xff1a; brew 是用來在 macOS 上安裝、管理軟件…

IEEE RAL 雙臂機器人三連抓估計物體狀態 無需特制夾爪或視覺相機 - 大阪大學萬偉偉老師團隊

IEEE RA-L | 萬偉偉老師團隊提出雙臂機器人規劃控制方法有效降低被抓物姿態不確定性 日本大阪大學萬偉偉老師團隊針對雙臂機器人開發了一種重復抓取規劃和阻抗控制的方法&#xff0c;該方法通過兩個機械臂依次尋找抓取位置和物體姿態&#xff0c;并通過三個正交抓取動作&#x…

AtomicInteger 和 volatile Integer對比

AtomicInteger 和 volatile Integer 雖然都與線程安全有關&#xff0c;但本質完全不同。它們的主要區別體現在原子性保證和功能上&#xff1a; &#x1f50d; 核心區別對比表 特性volatile IntegerAtomicInteger原子性? 不保證復合操作原子性? 保證所有操作的原子性自增操作…

一生一芯 PA2 RTFSC

從src/isa/riscv32/inst.c出發。 向上搜索&#xff0c;理解宏定義的含義。 R(i) #define R(i) gpr(i) R(i)&#xff1a;訪問第i號通用寄存器 會被替換為&#xff1a; #define gpr(idx) (cpu.gpr[check_reg_idx(idx)]) 分為兩個部分&#xff1a; cpu.gprcheck_reg_idx c…

深度學習——手寫數字識別

深度學習——手寫數字識別 學習深度學習的朋友應該對MNIST數據集不陌生吧&#xff0c;相信很多人在剛開始學習深度學習的時候都會用到MNIST數據集進行書寫數字識別。本篇文章參考魚書創建一個深度網絡來進行書寫數字識別的任務。 如上圖所示&#xff0c;這里使用的卷積層全都是…

HashMap算法高級應用實戰:頻率類子數組問題的5種破解模式

本文將深入剖析5種基于HashMap的高級模式&#xff0c;通過原理詳解、多語言實現、性能對比和工業級應用&#xff0c;助您徹底掌握頻率類子數組問題。 1. 深入解析&#xff1a;頻率類子數組問題 1.1 問題定義與分類 頻率類子數組問題是指需要統計或查找滿足特定元素頻率條件的…