rsync + inotify 數據實時同步

rsync + inotify 數據實時同步

一、rsync簡介

rsync是linux系統下的數據鏡像備份工具。使用快速增量備份工具Remote Sync可以遠程同步,
支持本地復制,或者與其他SSH、rsync主機同步

二、rsync三種命令

Rsync的命令格式常用的有以下三種:(與ssh類似)
rsync [OPTION]… SRC DEST (本地服務器之間:復制)
rsync [OPTION]… SRC [USER@]HOST:DEST (上傳)
rsync [OPTION]… [USER@]HOST:SRC DEST (下載)

1、 rsync [OPTION]… SRC DEST (本地服務器之間:復制)
服務器(源):
[root@server tmp]# touch a
[root@server tmp]# ls
a
[root@server tmp]# rsync -a a filea
[root@server tmp]# ls
a  filea
2、 rsync [OPTION]… SRC [USER@]HOST:DEST (上傳)
服務器(源):
[root@server tmp]# rsync -avz a root@192.168.100.30:/tmp
The authenticity of host '192.168.100.30 (192.168.100.30)' can't be established.
ECDSA key fingerprint is SHA256:R7/1dpul7cu8SnefsN2wQw5hKDL+xekk0ffasLS6OGI.
ECDSA key fingerprint is MD5:81:88:a1:16:52:83:c0:d5:59:ad:2b:3a:d5:52:02:bc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.30' (ECDSA) to the list of known hosts.
root@192.168.100.30's password: 
sending incremental file list
asent 80 bytes  received 35 bytes  6.57 bytes/sec
total size is 0  speedup is 0.00
客戶端(目標):
[root@stw3 tmp]# ls
a
3、 rsync [OPTION]… [USER@]HOST:SRC DEST (下載)
目標:
[root@stw3 tmp]# touch b
[root@stw3 tmp]# ls
a  b
源:
[root@server tmp]# rsync -avz root@192.168.100.30:/tmp/b .
root@192.168.100.30's password: 
receiving incremental file list
bsent 43 bytes  received 80 bytes  7.45 bytes/sec
total size is 0  speedup is 0.00
[root@server tmp]# ls
a  b  filea

三、rsync+inotify

1、rsync的優點和缺點

優點:rsync與傳統的cp、tar備份方式相比,rsync具有安全性高、備份迅速、支持增量備份等優點,
通過rsync可以解決對實時性要求不高的數據備份需求,例如定期的備份文件服務器數據到遠端服務器,
對本地磁盤定期做數據鏡像等。

缺點:首先,rsync同步數據時,需要掃描所有文件后進行比對,進行差量傳輸。如果文件數量達到了百萬甚至千 萬量級,掃描所有文件將是非常耗時的。而且正在發生變化的往往是其中很少的一部分,這是非常低效的方式。

其次,rsync不能實時的去監測、同步數據,雖然它可以通過linux守護進程的方式進行觸發同步,但是兩次觸發動作一定會有時間差,這樣就導致了服務端和客戶端數據可能出現不一致,無法在應用故障時完全的恢復數據。

2、inotify

inotify是一種強大的、細粒度的、異步的文件系統事件監控機制,linux內核從2.6.13起,加入了inotify支持,通過inotify可以監控文件系統中添加、刪除,修改、移動等各種細微事件,利用這個內核接口,第三方軟件就可以監控文件系統下文件的各種變化情況,而inotify-tools就是這樣的一個第三方軟件。在前面有講到,rsync可以實現觸發式的文件同步,但是通過crontab守護進程方式進行觸發,同步的數據和實際數據會有差異,而inotify可以監控文件系統的各種變化,當文件有任何變動時,就觸發rsync同步,這樣剛好解決了同步數據的實時性問題。

基于以上原因,rsync+inotify(數據實時同步)組合出現了!

四、配置

(把源服務器上/root/etc目錄實時同步到目標服務器的/tmp下)

1、源服務器和目標服務器要進行時鐘同步
源:
[root@server ~]# vim /etc/chrony.conf 
[root@server ~]# systemctl restart chronyd
[root@server ~]# systemctl enable chronyd
Created symlink from /etc/systemd/system/multi-user.target.wants/chronyd.service to /usr/lib/systemd/system/chronyd.service.
[root@server ~]# timedatectl Local time: Wed 2025-08-20 11:15:45 CSTUniversal time: Wed 2025-08-20 03:15:45 UTCRTC time: Wed 2025-08-20 03:15:45Time zone: Asia/Shanghai (CST, +0800)NTP enabled: yes
NTP synchronized: yesRTC in local TZ: noDST active: n/a
[root@server ~]# hwclock -w

在這里插入圖片描述

目標:
[root@stw3 ~]# vim /etc/chrony.conf 
[root@stw3 ~]# systemctl restart chronyd
[root@stw3 ~]# systemctl enable chronyd
Created symlink from /etc/systemd/system/multi-user.target.wants/chronyd.service to /usr/lib/systemd/system/chronyd.service.
[root@stw3 ~]# hwclock -w
[root@stw3 ~]# chrony
chronyc  chronyd  
[root@stw3 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? 192.168.100.20                0   7     0     -     +0ns[   +0ns] +/-    0ns

在這里插入圖片描述

2、關閉防火墻和selinux(源和目標主機都要關閉,操作一致)
[root@server ~]# systemctl stop firewalld.service 
[root@server ~]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@server ~]# setenforce 0
[root@server ~]# vim /etc/selinux/config 
[root@server ~]# reboot

在這里插入圖片描述

3、目標服務器:
(1)修改配置文件

log file = /var/log/rsyncd.log # 日志文件位置,啟動rsync后自動產生這個文件,無需提前創建
pidfile = /var/run/rsyncd.pid # pid文件的存放位置
lock file = /var/run/rsync.lock # 支持max connections參數的鎖文件
secrets file = /etc/rsync.pass # 用戶認證配置文件,里面保存用戶名稱和密碼,必須手動創建這個文件

[etc_from_client] # 自定義同步名稱
path = /tmp/ # rsync服務端數據存放路徑,客戶端的數據將同步至此目錄
comment = sync etc from client
uid = root # 設置rsync運行權限為root
gid = root # 設置rsync運行權限為root
port = 873 # 默認端口
ignore errors # 表示出現錯誤忽略錯誤
use chroot = no # 默認為true,修改為no,增加對目錄文件軟連接的備份
read only = no # 設置rsync服務端為讀寫權限
list = no # 不顯示rsync服務端資源列表
max connections = 200 # 最大連接數
timeout = 600 # 設置超時時間
auth users = admin # 執行數據同步的用戶名,可以設置多個,用英文狀態下逗號隔開
hosts allow = 192.168.100.10 # 允許進行數據同步的客戶端IP地址,可以設置多個,用英文狀態下逗號隔開
hosts deny = 192.168.1.1 # 禁止數據同步的客戶端IP地址,可以設置多個,用英文狀態下逗號隔開

[root@stw3 ~]# vim /etc/rsyncd.conf

在這里插入圖片描述

(2)創建用戶認證文件
[root@stw3 ~]# vim /etc/rsync.pass
[root@stw3 ~]# cat /etc/rsync.pass 
admin:123456

在這里插入圖片描述

(3)設置文件權限
[root@stw3 ~]# chmod 600 /etc/rsync*
[root@stw3 ~]# ll /etc/rsync*
-rw------- 1 root root 914 Aug 20 11:30 /etc/rsyncd.conf
-rw------- 1 root root  13 Aug 20 11:32 /etc/rsync.pass
(4)啟動rsync服務并設置開機自啟
[root@stw3 ~]# rsync --daemon
[root@stw3 ~]# vim /etc/rc.d/rc.local 
[root@stw3 ~]# netstat -tulnp | grep 873
tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      9993/rsync          
tcp6       0      0 :::873                  :::*                    LISTEN      9993/rsync      

在這里插入圖片描述

4、源服務器:
(1)配置網絡源和epel-release
[root@server ~]# cd /etc/yum.repos.d/
[root@server yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@server yum.repos.d]# rm -rf *
[root@server yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2025-08-20 11:43:00--  https://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 117.92.155.17, 150.139.241.204, 111.77.199.29
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|117.92.155.17|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’100%[===================================================================>] 2,523       --.-K/s   in 0s      2025-08-20 11:43:00 (10.5 MB/s) -/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523][root@server yum.repos.d]# yum -y install epel-release
(2)安裝rsync服務端軟件,只需要安裝,不要啟動,不需要配置(可忽略,rsync默認已經安裝)
[root@server ~]# yum -y install rsync
(3)創建認證密碼文件
[root@server ~]# vim /etc/rsync.pass
[root@server ~]# cat /etc/rsync.pass 
123456

在這里插入圖片描述

(4)設置文件權限,只設置文件所有者具有讀取、寫入權限即可
[root@server ~]# chmod 600 /etc/rsync.pass 
(5)在源服務器上創建測試目錄,然后在源服務器運行以下命令
[root@server ~]# mkdir /root/etc
[root@server ~]# cd /root/etc
[root@server etc]# ls
[root@server etc]# mkdir test
[root@server etc]# cd test
[root@server test]# pwd
/root/etc/test
[root@server test]# rsync -avH --port 873 --progress --delete /root/etc/ admin@192.168.100.30::etc_from_client --password-file=/etc/rsync.pass
sending incremental file list
deleting vmware-root_8623-1990534217/
deleting systemd-private-587fbc66687344f9bed799a3b4ad760a-rtkit-daemon.service-V88iF7/tmp/
deleting systemd-private-587fbc66687344f9bed799a3b4ad760a-rtkit-daemon.service-V88iF7/
deleting systemd-private-587fbc66687344f9bed799a3b4ad760a-cups.service-I0Q073/tmp/
deleting systemd-private-587fbc66687344f9bed799a3b4ad760a-cups.service-I0Q073/
deleting systemd-private-587fbc66687344f9bed799a3b4ad760a-colord.service-9TD9Zd/tmp/
deleting systemd-private-587fbc66687344f9bed799a3b4ad760a-colord.service-9TD9Zd/
deleting systemd-private-587fbc66687344f9bed799a3b4ad760a-chronyd.service-fc3OEy/tmp/
deleting systemd-private-587fbc66687344f9bed799a3b4ad760a-chronyd.service-fc3OEy/
deleting systemd-private-587fbc66687344f9bed799a3b4ad760a-bolt.service-ZCd3B8/tmp/
deleting systemd-private-587fbc66687344f9bed799a3b4ad760a-bolt.service-ZCd3B8/
deleting .font-unix/
deleting .esd-0/
deleting .XIM-unix/
deleting .X11-unix/X0
deleting .X11-unix/
deleting .Test-unix/
deleting .ICE-unix/9983
deleting .ICE-unix/9630
deleting .ICE-unix/9469
deleting .ICE-unix/9446
deleting .ICE-unix/
deleting .X0-lock
./
test/sent 77 bytes  received 1,018 bytes  104.29 bytes/sec
total size is 0  speedup is 0.00
(6)在目標服務器上查看,在/tmp目錄下有test目錄,說明數據同步成功
[root@stw3 ~]# cd /tmp
[root@stw3 tmp]# ls
systemd-private-587fbc66687344f9bed799a3b4ad760a-bolt.service-ZCd3B8
systemd-private-587fbc66687344f9bed799a3b4ad760a-chronyd.service-fc3OEy
systemd-private-587fbc66687344f9bed799a3b4ad760a-colord.service-9TD9Zd
systemd-private-587fbc66687344f9bed799a3b4ad760a-cups.service-I0Q073
systemd-private-587fbc66687344f9bed799a3b4ad760a-rtkit-daemon.service-V88iF7
vmware-root_8623-1990534217
[root@stw3 tmp]# ls
test
測試:源服務器中創建文件,可以傳輸到目標服務器中
源:
[root@server test]# ls
[root@server test]# 
[root@server test]# touch file1 file2
[root@server test]# ls
file1  file2
[root@server test]# rsync -avH --port 873 --progress --delete /root/etc/ admin@192.168.100.30::etc_from_client --password-file=/etc/rsync.pass
sending incremental file list
test/
test/file10 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=1/4)
test/file20 100%    0.00kB/s    0:00:00 (xfr#2, to-chk=0/4)sent 195 bytes  received 66 bytes  24.86 bytes/sec
total size is 0  speedup is 0.00
目標:
[root@stw3 tmp]# cd test
[root@stw3 test]# ls
file1  file2

實現實時同步(rsync+inotify)

源:
(1)安裝inotify-tools工具(make、gcc、gcc-c++、inotify-tools)
[root@server ~]# yum -y install make gcc gcc-c++ inotify-tools
(2)寫同步腳本,讓腳本自動去檢測我們制定的目錄下 文件發生的變化,然后再執行rsync的命令把它同步到我們的目標服務器端去
[root@server ~]# mkdir /tbjiaoben
[root@server ~]# cd /tbjiaoben
[root@server tbjiaoben]# ls
[root@server tbjiaoben]# vim inotify.sh

host=192.168.100.20 # 目標服務器的ip(備份服務器)
src=/root/etc # 在源服務器上所要監控的備份目錄(此處可以自定義,但是要保證存在)
des=etc_from_client # 自定義的模塊名,需要與目標服務器上定義的同步名稱一致
password=/etc/rsync.pass # 執行數據同步的密碼文件
user=admin # 執行數據同步的用戶名
inotifywait=/usr/bin/inotifywait

$inotifywait -mrq --timefmt ‘%Y%m%d %H:%M’ --format ‘%T %w%f%e’ -e modify,delete,create,attrib src∣whilereadfiles;dorsync?avzP??delete??timeout=100??password?file=src | while read files;dorsync -avzP --delete --timeout=100 --password-file=srcwhilereadfiles;dorsync?avzP??delete??timeout=100??password?file={password} $src user@user@user@host::desecho"desecho "desecho"{files} was rsynced" >>/tmp/rsync.log 2>&1
done

在這里插入圖片描述

(3)啟動腳本
[root@server ~]# nohup bash /tbjiaoben/inotify.sh &
[2] 11411
[root@server ~]# nohup: ignoring input and appending output to ‘nohup.out’
[root@server ~]# ps -ef | grep inotify
root      11401      1  0 15:48 pts/0    00:00:00 /usr/bin/inotifywait -mrq --timefmt %Y%m%d %H:%M --format %T %w%f%e -e modify,delete,create,attrib /root/etc
root      11402      1  0 15:48 pts/0    00:00:00 bash /tbjiaoben/inotify.sh
root      11411   9783  0 15:48 pts/0    00:00:00 bash /tbjiaoben/inotify.sh
root      11412  11411  0 15:48 pts/0    00:00:00 /usr/bin/inotifywait -mrq --timefmt %Y%m%d %H:%M --format %T %w%f%e -e modify,delete,create,attrib /root/etc
root      11413  11411  0 15:48 pts/0    00:00:00 bash /tbjiaoben/inotify.sh
root      11436   9783  0 15:50 pts/0    00:00:00 grep --color=auto inotify
(wd now: ~)
(4)在源服務器上生成一個新文件,查看inotify生成的日志

從日志上可以看到,我們生成了一個test文件,并且添加了內容到其里面

[root@server ~]# cd /root/etc
[root@server etc]# ls
test
[root@server etc]# touch file111
[root@server etc]# ls
file111  test
[root@server etc]# cd
[root@server ~]# tail /tmp/rsync.log 
20250820 15:52 /root/etc/file111CREATE was rsynced
20250820 15:52 /root/etc/file111CREATE was rsynced
20250820 15:52 /root/etc/file111ATTRIB was rsynced
20250820 15:52 /root/etc/file111ATTRIB was rsynced
(5)目標服務器驗證
[root@stw3 ~]# cd /tmp
[root@stw3 tmp]# ls
etc  test
[root@stw3 tmp]# cd etc
[root@stw3 etc]# ls
file111  test
5、設置腳本開機自啟
(1)把nohup /bin/bash /tbjiaoben/inotify.sh &寫到配置文件(/etc/rc.d/rc.local)中
[root@server ~]# vim /etc/rc.d/rc.local 

在這里插入圖片描述

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

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

相關文章

Linux基礎介紹-3——第一階段

文章目錄一、進程管理1.1 進程的基本概念1.2 常見管理命令1.3 進程優先級調整:nice 與 renice二、軟件包管理三、防火墻管理四、shell腳本五、xshell鏈接kali一、進程管理 1.1 進程的基本概念 進程是程序的動態執行實例,每個進程都有唯一的 PID&#x…

python 可迭代對象相關知識點

1. 什么是可迭代對象 (Iterable) 在 Python 里,可迭代對象指的是: 👉 能夠一次返回一個元素的對象,可以被 for 循環遍歷。 常見的可迭代對象有: 序列類型:list、tuple、str集合類型:set、dict&a…

ijkplayer Android 編譯

一、下載編譯庫文件1.1 編譯庫文件環境:ubuntu 20.04 版本liangtao:ffmpeg$lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.6 LTS Release: 20.04 Codename: focal1.2 項目源碼下載使用 git 下載 ijkplayer&#…

snn前向推理時間計算(處理器實現)

公式 Tinf(1?sparsity)number of synapsesnumber of sub-processorsSIMD ways T_{\text{inf}} \frac{(1-\text{sparsity})\times \text{number of synapses}} {\text{number of sub-processors}\times \text{SIMD ways}} Tinf?number of sub-processorsSIMD ways(1?sparsity…

Linux------《操作系統全景速覽:Windows·macOS·Linux·Unix 對比及 Linux 發行版實戰指南》

(一)常見操作系統(system)電腦:Windows,Macos,Linux,UnixWindows:微軟公司開發的一款桌面操作系統(閉源系統)。版本有dos,win98,win NT,win XP , …

Three.js 初級教程大全

本文檔旨在為初學者提供一個全面的 Three.js 入門指南。我們將從 Three.js 的基本概念開始,逐步介紹如何創建場景、添加物體、設置材質、使用光照和相機,以及如何實現簡單的動畫和交互。通過本教程,你將能夠掌握 Three.js 的核心知識&#xf…

遙感領域解決方案丨高光譜、無人機多光譜、空天地數據識別與計算

一:AI智慧高光譜遙感實戰:手撕99個案例項目、全覆蓋技術鏈與應用場景一站式提升方案在遙感技術飛速發展的今天,高光譜數據以其獨特的光譜分辨率成為環境監測、精準農業、地質勘探等領域的核心數據源。然而,海量的波段數據、復雜的…

(LeetCode 面試經典 150 題) 114. 二叉樹展開為鏈表 (深度優先搜索dfs+鏈表)

題目:114. 二叉樹展開為鏈表 思路:深度優先搜索dfs鏈表,時間復雜度0(n)。 C版本: /*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode() : …

《線程狀態轉換深度解析:從阻塞到就緒的底層原理》

目錄 一、線程的五種基本狀態 二、線程從 RUNNABLE 進入阻塞 / 等待狀態的三種典型場景 1. 調用sleep(long millis):進入 TIMED_WAITING 狀態 2. 調用wait():進入 WAITING/TIMED_WAITING 狀態 3. 等待 I/O 資源或獲取鎖失敗:進入 BLOCKE…

面經整理-猿輔導-內容服務后端-java實習

部門管理系統設計 題目要求 設計部門 MySQL 數據表實現接口:根據中間部門 ID 獲取其下屬葉子部門 ID設計包含子節點列表的 Java 數據對象,并實現批量獲取功能 一、MySQL 部門表設計 表結構 CREATE TABLE department (id BIGINT PRIMARY KEY AUTO_INCREME…

Openharmony之window_manager子系統源碼、需求定制詳解

1. 模塊概述 Window Manager 模塊是 OpenHarmony 操作系統的核心窗口管理系統,負責窗口的創建、銷毀、布局、焦點管理、動畫效果以及與硬件顯示的交互。該模塊采用客戶端-服務端架構,提供完整的窗口生命周期管理和用戶界面交互支持。 1.1架構總覽 Window Manager Client 應…

《CDN加速的安全隱患與解決辦法:如何構建更安全的網絡加速體系》

CDN(內容分發網絡)作為提升網站訪問速度的關鍵技術,被廣泛應用于各類互聯網服務中。然而,在享受加速優勢的同時,CDN也面臨諸多安全隱患。本文將解析常見的CDN安全問題,并提供實用的解決辦法,幫助…

【Linux指南】GCC/G++編譯器:庖丁解牛——從源碼到可執行文件的奇幻之旅

不只是簡單的 gcc hello.c 每一位Linux C/C++開發者敲下的第一行編譯命令,幾乎都是 gcc hello.c -o hello 或 g++ hello.cpp -o hello。這像一句神奇的咒語,將人類可讀的源代碼變成了機器可執行的二進制文件。但在這條簡單的命令背后,隱藏著一個如同精密鐘表般復雜的多步流…

地區電影市場分析:用Python爬蟲抓取貓眼_燈塔專業版各地區票房

在當今高度數據驅動的影視行業,精準把握地區票房表現是制片方、宣發團隊和影院經理做出關鍵決策的基礎。一部電影在北上廣深的表現與二三線城市有何差異?哪種類型的電影在特定區域更受歡迎?回答這些問題,不能再依賴“拍腦袋”和經…

Spark03-RDD02-常用的Action算子

一、常用的Action算子 1-1、countByKey算子 作用:統計key出現的次數,一般適用于K-V型的RDD。 【注意】: 1、collect()是RDD的算子,此時的Action算子,沒有生成新的RDD,所以,沒有collect()&…

[Android] 顯示的內容被導航欄這擋住

上圖中彈出的對話框的按鈕“Cancel/Save”被導航欄遮擋了部分顯示&#xff0c;影響了使用。Root cause: Android 應用的主題是 Theme.AppCompat.Light1. 修改 AndroidManifest.xml 將 application 標簽的 android:theme 屬性指向新的自定義主題&#xff1a;<applicationandr…

分貝單位全指南:從 dB 到 dBm、dBc

引言在射頻、音頻和通信工程中&#xff0c;我們經常會在示波器、頻譜儀或測試報告里看到各種各樣的dB單位&#xff0c;比如 dBm、dBc、dBV、dBFS 等。它們看起來都帶個 dB&#xff0c;實則各有不同的定義和參考基準&#xff1a;有的表示相對功率&#xff0c;有的表示電壓電平&a…

怎么確定mysql 鏈接成功了呢?

asyncio.run(test_connection()) ? Connection failed: cryptography package is required for sha256_password or caching_sha2_password auth methods 根據你提供的錯誤信息,問題出現在 MySQL 的認證插件和加密連接配置上。以下是幾種解決方法: 1. 安裝 cryptography 包…

(5)軟件包管理器 yum | Vim 編輯器 | Vim 文本批量化操作 | 配置 Vim

Ⅰ . Linux 軟件包管理器 yum01 安裝軟件在 Linux 下安裝軟件并不像 Windows 下那么方便&#xff0c;最通常的方式是去下載程序的源代碼并進行編譯&#xff0c;從而得到可執行程序。正是因為太麻煩&#xff0c;所以有些人就把一些常用的軟件提前編譯好并做成軟件包&#xff0c;…

VGG改進(3):基于Cross Attention的VGG16增強方案

第一部分&#xff1a;交叉注意力機制解析1.1 注意力機制基礎注意力機制的核心思想是模擬人類的選擇性注意力——在處理信息時&#xff0c;對重要部分分配更多"注意力"。在神經網絡中&#xff0c;這意味著模型可以學習動態地加權輸入的不同部分。傳統的自注意力(Self-…