SLV Linux 遷移 - 快速入門

🚚 SLV Linux 遷移

透過 SSH 使用 rsync 將整個 Linux 磁碟遷移到新伺服器。這是全盤遷移——源伺服器上的所有內容都會複製到目標伺服器,包括使用者資料、配置、已安裝的軟體包和 SLV 節點設定。
**注意:**這與 slv v switch(驗證者身份遷移)不同。slv migrate linux 複製整個檔案系統,而 slv v switch 在兩個已執行的節點之間交換驗證者身份。

前提條件

  • 節點上已安裝 SLV CLI
  • 源和目標上都有 sudo / root 訪問許可權
  • 從源到目標的 SSH 訪問(基於密碼或金鑰)
  • 目標伺服器應為全新安裝(如果檢測到現有資料,SLV 會發出警告)

基本用法

伺服器上執行:
bash
sudo slv migrate linux --to root@new-server-ip
text
🚚 SLV Linux Migration

  Source:      ubuntu (this machine)
  Destination: [email protected]

📋 Exclude list:
  • /dev/*
  • /proc/*
  • /sys/*
  • /tmp/*
  • /run/*
  • /mnt/*
  • /media/*
  • /lost+found
  • /swapfile
  • /snap/*
  • /var/log/*

? Start migration? This will overwrite data on the destination. › Yes
  Syncing... (this may take a while depending on disk size)
√ Migration complete
  Rebooting destination...

選項

選項描述
-t, --to <ssh>SSH 目標(例如 root@new-server
-p, --port <port>SSH 埠(預設:22)
--skip-reboot遷移後跳過自動重啟
--exclude <path>額外的 rsync 排除模式(可重複使用)
--include <path>從預設排除列表中移除(可重複使用)
--list-excludes顯示當前排除列表並退出
-y, --yes跳過確認提示

自定義 SSH 埠

如果目標使用非標準 SSH 埠:
bash
sudo slv migrate linux --to root@new-server-ip --port 2222

自定義排除項

檢視將要排除的內容:
bash
slv migrate linux --list-excludes
排除額外路徑(例如跳過賬本資料以加快遷移):
bash
sudo slv migrate linux --to root@new-server-ip --exclude /home/solv/ledger

非互動模式

用於指令碼:
bash
sudo slv migrate linux --to root@new-server-ip --skip-reboot --yes

工作原理

  1. 預檢——驗證 SSH 連線,如果目標有現有資料則發出警告
  2. rsync——透過 SSH 複製整個檔案系統(排除系統偽檔案系統)
  3. 遷移後——自動重啟目標伺服器(除非使用 --skip-reboot
遷移使用 rsync 的 --archive --hard-links --acls --xattrs 選項來保留所有檔案屬性、許可權和特殊檔案。

⚠️ 重要提示

  • 以 root 執行(或使用 sudo)。非 root 遷移會遺漏系統檔案。
  • 目標應為全新伺服器。現有資料將被覆蓋。
  • rsync 退出碼 23/24(部分傳輸)被視為警告而非錯誤。某些檔案(如活躍日誌)可能無法完美傳輸。
  • 遷移後,在停用源伺服器前驗證節點是否正常工作。
  • 對於驗證者身份遷移(兩個執行中的驗證者之間零停機時間切換),請使用 slv v switch。請參閱主網驗證者遷移