Proxmox VE(PVE)全部替换为国内源,更换pve源为非订阅源,更换ceph源,小版本升级

roed2025-05-27  342

更换软件源(三个节点都需要配置)

由于自带的软件源速度较慢,此处选择清华大学镜像源:https://mirrors.tuna.tsinghua.edu.cn
涉及的软件源有三个,分别为debain、pve、ceph,需要分别修改下列文件。

  • 操作流程:

    一、准备工作

    1. 备份重要数据
       
      cp /etc/apt/sources.list /etc/apt/sources.list.bak
      mkdir -p /root/sources_backup && cp /etc/apt/sources.list.d/* /root/sources_backup/
      
      # 检查 PVE 版本
      pveversion

    二、更换软件源(国内镜像)

    1. Debian 系统源(选择其一)

    清华大学镜像站

     
    cat > /etc/apt/sources.list << EOF
    # 基础源
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free
    
    # 更新源
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free
    
    # 安全更新源
    deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free
    # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free
    EOF
    

    中国科学技术大学镜像站

     
    cat > /etc/apt/sources.list << EOF
    # 基础源
    deb https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free
    # deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free
    
    # 更新源
    deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free
    # deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free
    
    # 安全更新源
    deb https://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free
    # deb-src https://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free
    EOF
    
     

    2. PVE 非订阅源(选择其一)

     
    # 备份原企业源
    mv /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak 2>/dev/null
    
    # 清华大学镜像站
    echo "deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
    
    # 或中国科学技术大学镜像站
    echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
    
     

    3. Ceph 源(选择其一,此步骤仅当您使用 Ceph 集群时才需要执行)

     
    # 备份原Ceph源
    mv /etc/apt/sources.list.d/ceph.list /etc/apt/sources.list.d/ceph.list.bak 2>/dev/null
    
    # 清华大学镜像站(Ceph Quincy 版本)
    echo "deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription" > /etc/apt/sources.list.d/ceph-no-subscription.list
    
    # 或中国科学技术大学镜像站
    echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription" > /etc/apt/sources.list.d/ceph-no-subscription.list
    
     

    三、导入 GPG 密钥

     
    # 导入 Proxmox VE 官方密钥
    wget -qO - https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg | gpg --dearmor | tee /usr/share/keyrings/proxmox-ve.gpg >/dev/null
    
    # 导入 Ceph 官方密钥(可选,此步骤仅当您使用 Ceph 集群时才需要执行)
    wget -q -O- 'https://download.ceph.com/keys/release.asc' | gpg --dearmor | tee /usr/share/keyrings/ceph-archive-keyring.gpg >/dev/null
    
     

    四、忽略订阅警告(非生产环境)

     
    sed -i "s/data.status !== 'Active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
    systemctl restart pveproxy.service
    
     

    五、同步系统时间

     
    # 安装 chrony(如果未安装)
    apt install chrony -y
    
    # 重启服务触发时间同步
    systemctl restart chrony
    
    # 验证时间同步状态
    chronyc sources
    
     

    六、执行更新

     
    # 更新软件包列表
    apt update
    
    # 执行系统升级(小版本升级)
    apt dist-upgrade -y
    
    # 执行系统更新
    apt update && apt full-upgrade
    
    # 清理缓存
    apt autoremove && apt clean
    
     

    七、验证更新结果

     
    # 检查 PVE 版本
    pveversion
    
    # 检查 Ceph 状态(仅集群环境需要)
    ceph -s
    
    • 常见问题解决

      1. GPG 签名验证失败 (Public key is not available)

      当您运行 apt update 时遇到类似 GPG error: The following signatures couldn't be verified because the public key is not available 的错误时,通常是密钥没有正确导入。

      解决方法: 重新执行 第三部分 中对应的 GPG 密钥导入命令。

      # 重新导入 Proxmox VE 官方密钥
      echo " 正在重新导入 Proxmox VE GPG 密钥..."
      wget -qO - https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg | gpg --dearmor | tee /usr/share/keyrings/proxmox-ve.gpg >/dev/null
      echo " Proxmox VE GPG 密钥重新导入完成。"
      
      # 如果您使用 Ceph,也重新导入 Ceph 官方密钥
      echo " 正在重新导入 Ceph GPG 密钥 (如果使用 Ceph)..."
      wget -q -O- 'https://download.ceph.com/keys/release.asc' | gpg --dearmor | tee /usr/share/keyrings/ceph-archive-keyring.gpg >/dev/null
      echo " Ceph GPG 密钥重新导入完成。"
      
      # 重新运行更新
      apt update
      
      

      2. 更新后 Web 界面报错或无法访问

      有时更新后 Web 界面可能出现异常,尝试重启相关的 PVE 服务:

      systemctl restart pvedaemon.service pveproxy.service
      echo "✅ PVE 相关服务已重启,请刷新 Web 界面。"

      3. Ceph 命令找不到

      如果您在集群环境中执行 ceph -s 时提示命令不存在,说明 Ceph 客户端工具未安装。

      apt install ceph-common -y
      echo "✅ Ceph 客户端工具 (ceph-common) 已安装。"

      注意事项

      • 生产环境建议:
        • 在任何更新前,务必备份虚拟机配置和所有重要数据
        • 在维护窗口期执行更新,避免对业务造成中断。
        • 对于多节点集群,建议逐个节点进行更新。每个节点更新后观察 5-10 分钟,确认无异常后再更新下一个节点。
      • 版本兼容性:
        • 确保所有 PVE 节点都使用相同的 Debian 版本(例如,如果第一个节点是 bookworm,其他节点也必须是 bookworm)。
        • Ceph 版本需与 PVE 版本兼容。Proxmox VE 8.x 推荐使用 Ceph Quincy 或更新版本。
      • 防火墙设置:
        • 确保节点间网络互通,特别是对于 Ceph 集群,所有 Ceph OSD 和 MON 节点之间必须能够相互通信。
        • 开放必要的端口:
          • SSH (22)
          • PVE Web 界面 (8006)
          • Ceph 内部通信端口 (默认情况下,Ceph OSD 和 MON 节点会使用一系列端口,如 6789、6800-7300 等,集群内部通信通常无需额外配置防火墙,但外部访问时需要注意)。
申明 1、网站名称:容易得 网址:WWW.ROED.CN
2、网站的内容来源于网络,如有侵权,请联系邮箱:185254287#qq.com 本站会在7个工作日内进行删除处理。
3、转载发布此文目的在于传递分享更多信息,仅代表原作者个人观点,并不代表本站赞同其观点和对其真实性负责。文章内容仅供参考,请读者自行甄别,以防风险。
4、禁止发布和链接任何有关政治、色情、宗教、迷信、低俗、变态、血腥、暴力以及危害国家安全,诋毁政府形象等违法言论和信息。
转载请注明原文地址:https://www.roed.cn/read-479158.html