首页
Search
1
Armbian ARM64 搭建 MATE + TigerVNC + noVNC + XRDP + 中文输入法 + Cloudflare Tunnel 完整教程
14 阅读
2
RHEL/CentOS 7.9 Chrony 时间同步服务
7 阅读
3
Linux 常用命令速查手册
5 阅读
4
使用私有 CA 为内网 IP 签发 TLS 服务器证书
3 阅读
5
CentOS 7.9 + 宝塔 + FRP 自建内网穿透:公网访问 Armbian noVNC 与 1Panel
3 阅读
默认分类
服务器
VMware
vSphere
Linux
Windows
数据库
登录
Search
agblr
累计撰写
7
篇文章
累计收到
0
条评论
首页
栏目
默认分类
服务器
VMware
vSphere
Linux
Windows
数据库
页面
搜索到
4
篇与
的结果
2026-09-19
CentOS 7.9 + 宝塔 + FRP 自建内网穿透:公网访问 Armbian noVNC 与 1Panel
一、需求背景目前有两台服务器:公网服务器系统环境:CentOS 7.9.2009 x86_64 宝塔面板 Nginx 公网 IP用途:部署 FRP 服务端 frps作为公网入口使用宝塔 Nginx 配置域名使用 HTTPS 访问内网服务内网设备系统环境:Armbian 23.02.2 Jammy Ubuntu 22.04目前运行:noVNC: 127.0.0.1:6081 1Panel: 127.0.0.1:2333目标:https://vnc.agblr.xyz ↓ 访问 Armbian noVNC https://a.agblr.xyz ↓ 访问 Armbian 1Panel并且内网的 6081、2333 不直接暴露到公网。二、最终架构整体架构如下: Internet │ ▼ Cloudflare / DNS │ ▼ CentOS 公网服务器 宝塔 + Nginx :80 / :443 │ ┌─────────────┴─────────────┐ │ │ ▼ ▼ 127.0.0.1:16081 127.0.0.1:2333 noVNC代理 1Panel代理 │ │ └────────── FRPS ───────────┘ │ :7000 │ Internet │ FRPC │ ┌────────┴────────┐ │ │ ▼ ▼ 127.0.0.1:6081 127.0.0.1:2333 noVNC 1Panel │ └──── Armbian ────公网只需要开放:80/TCP 443/TCP 7000/TCPFRP 映射出来的:16081 2333只监听:127.0.0.1因此无法直接从公网通过:公网IP:16081 公网IP:2333访问。三、为什么不用宝塔 FRP 插件最开始尝试使用宝塔的 FRP 管理器,但报错:AttributeError: module 'public' has no attribute 'get_server_ip'完整关键位置:self.config['serveraddr'] = public.get_server_ip()原因是:宝塔版本:7.9.2 CentOS:7.9.2009 Python:3.7.9FRP 插件调用了旧版宝塔 API:public.get_server_ip()而当前宝塔代码中已经不存在该接口。因此最终放弃宝塔 FRP 插件,改为:FRP 手动安装 + systemd 管理 + 宝塔只负责 Nginx / 域名 / HTTPS这种方式也更加稳定。四、CentOS 安装 FRP 服务端创建目录:mkdir -p /www/server/frp cd /www/server/frp下载 FRP:wget gh-proxy.com/https://github.com/fatedier/frp/releases/download/v0.70.1/frp_0.70.1_linux_amd64.tar.gz解压:tar -zxf frp_0.70.1_linux_amd64.tar.gz复制 frps:cp frp_0.70.1_linux_amd64/frps /www/server/frp/frps chmod 755 /www/server/frp/frps验证:/www/server/frp/frps --version输出:0.70.1说明安装成功。五、一个实际踩过的坑:下载文件损坏第一次下载时,由于目录里已经有同名文件,wget 实际把新的完整文件保存为了:frp_0.70.1_linux_amd64.tar.gz.1但后续却执行:tar -zxf frp_0.70.1_linux_amd64.tar.gz导致解压的是旧的残缺文件。报错:gzip: stdin: unexpected end of file tar: Unexpected EOF in archive tar: Error is not recoverable随后复制出来的 frps 也不完整:/www/server/frp/frps --version直接出现:Segmentation fault解决方法是删除旧文件重新下载:rm -rf /www/server/frp/*重新下载、解压后:/www/server/frp/frps --version正常返回:0.70.1以后遇到类似问题可以先检查:ls -lh以及:gzip -t frp_0.70.1_linux_amd64.tar.gz如果 gzip -t 没有输出,一般说明 gzip 文件完整。六、配置 FRP 服务端生成一个随机 Token:openssl rand -hex 32例如:52ba40b2e66447009793152b1fe5aa03ba175bed401bfde15922e8969925d831实际使用时请使用自己生成的 Token。创建:vi /www/server/frp/frps.toml配置:bindAddr = "0.0.0.0" bindPort = 7000 proxyBindAddr = "127.0.0.1" auth.method = "token" auth.token = "替换成自己的TOKEN" allowPorts = [ { single = 16081 }, { single = 2333 } ]这里有两个比较重要的地方。proxyBindAddrproxyBindAddr = "127.0.0.1"意味着 FRP 客户端映射出来的端口只监听:127.0.0.1不会变成:0.0.0.0这样可以避免 16081 和 2333 直接暴露公网。allowPortsallowPorts = [ { single = 16081 }, { single = 2333 } ]限制客户端只允许申请:16081 2333避免 FRP 客户端随意创建其他公网映射。七、验证 FRP 服务端配置执行:/www/server/frp/frps verify -c /www/server/frp/frps.toml如果没有配置错误即可继续。八、配置 systemd创建:vi /etc/systemd/system/frps.service内容:[Unit] Description=FRP Server After=network-online.target Wants=network-online.target [Service] Type=simple ExecStart=/www/server/frp/frps -c /www/server/frp/frps.toml Restart=always RestartSec=5 [Install] WantedBy=multi-user.target加载:systemctl daemon-reload设置开机启动:systemctl enable --now frps检查:systemctl status frps --no-pager -l检查监听:ss -lntp | grep 7000正常应该看到:0.0.0.0:7000九、开放 FRP 服务端端口CentOS firewalld:firewall-cmd --permanent --add-port=7000/tcp firewall-cmd --reload宝塔安全页面也允许:TCP 7000如果使用腾讯云、阿里云等,还需要在云服务器安全组开放:TCP 7000注意:16081 2333不需要开放。十、Armbian 安装 FRP 客户端先查看 CPU 架构:uname -m如果:aarch64则使用 ARM64 版本。创建目录:mkdir -p /opt/frp cd /opt/frp下载:wget gh-proxy.com/https://github.com/fatedier/frp/releases/download/v0.70.1/frp_0.70.1_linux_arm64.tar.gz解压:tar -zxf frp_0.70.1_linux_arm64.tar.gz复制:cp frp_0.70.1_linux_arm64/frpc /opt/frp/frpc chmod 755 /opt/frp/frpc验证:/opt/frp/frpc --version应该显示:0.70.1十一、确认内网服务noVNC:ss -lntp | grep 6081确认:127.0.0.1:6081测试:curl -I http://127.0.0.1:60811Panel:ss -lntp | grep 2333确认:127.0.0.1:2333十二、配置 FRP 客户端创建:nano /opt/frp/frpc.toml内容:serverAddr = "CentOS公网IP" serverPort = 7000 auth.method = "token" auth.token = "和CentOS完全相同的TOKEN" [[proxies]] name = "novnc" type = "tcp" localIP = "127.0.0.1" localPort = 6081 remotePort = 16081 [[proxies]] name = "1panel" type = "tcp" localIP = "127.0.0.1" localPort = 2333 remotePort = 2333最终映射关系:Armbian 127.0.0.1:6081 → CentOS 127.0.0.1:16081以及:Armbian 127.0.0.1:2333 → CentOS 127.0.0.1:2333十三、启动 FRP 客户端测试先检查:/opt/frp/frpc verify -c /opt/frp/frpc.toml前台运行:/opt/frp/frpc -c /opt/frp/frpc.toml成功后,在 CentOS 上执行:ss -lntp | grep -E '16081|2333'应该看到:127.0.0.1:16081 127.0.0.1:2333测试 noVNC:curl -I http://127.0.0.1:16081测试 1Panel:curl -I http://127.0.0.1:2333只要有正常 HTTP 响应,FRP 就已经打通。十四、Armbian 设置 frpc 开机启动创建:vi /etc/systemd/system/frpc.service内容:[Unit] Description=FRP Client After=network-online.target Wants=network-online.target [Service] Type=simple ExecStart=/opt/frp/frpc -c /opt/frp/frpc.toml Restart=always RestartSec=5 [Install] WantedBy=multi-user.target执行:systemctl daemon-reload systemctl enable --now frpc检查:systemctl status frpc --no-pager -l查看实时日志:journalctl -u frpc -f服务端日志:journalctl -u frps -f十五、宝塔配置 noVNC 域名例如使用:vnc.agblr.xyz vnc.23332048.xyz将域名解析到:CentOS公网IP然后创建宝塔站点。noVNC 的 Nginx 配置可以使用:server { listen 80; server_name vnc.agblr.xyz vnc.23332048.xyz; root /www/wwwroot/vnc.agblr.xyz; location ^~ /.well-known/acme-challenge/ { root /www/wwwroot/vnc.agblr.xyz; allow all; } location / { proxy_pass http://127.0.0.1:16081; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_connect_timeout 30s; proxy_read_timeout 3600s; proxy_send_timeout 3600s; proxy_buffering off; proxy_cache off; } access_log /www/wwwlogs/vnc.agblr.xyz.log; error_log /www/wwwlogs/vnc.agblr.xyz.error.log; }其中最重要的是:proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";因为 noVNC 使用 WebSocket。如果没有这几行,很可能出现:网页可以打开 但是 VNC 无法连接 WebSocket connection failed十六、宝塔配置 1Panel 域名例如:a.agblr.xyz a.23332048.xyz对应:127.0.0.1:2333配置:server { listen 80; server_name a.agblr.xyz a.23332048.xyz; index index.php index.html index.htm default.php default.htm default.html; root /www/wwwroot/a.agblr.xyz; #SSL-START #error_page 404/404.html; #SSL-END #ERROR-PAGE-START #error_page 404 /404.html; #error_page 502 /502.html; #ERROR-PAGE-END location ^~ /.well-known/acme-challenge/ { root /www/wwwroot/a.agblr.xyz; allow all; } location / { proxy_pass http://127.0.0.1:2333; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $host; proxy_connect_timeout 30s; proxy_send_timeout 3600s; proxy_read_timeout 3600s; proxy_buffering off; proxy_cache off; proxy_request_buffering off; client_max_body_size 1024m; } location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) { return 404; } access_log /www/wwwlogs/a.agblr.xyz.log; error_log /www/wwwlogs/a.agblr.xyz.error.log; }之所以同样保留 WebSocket,是因为 1Panel 的:SSH终端 容器终端 实时日志等功能都可能依赖 WebSocket。十七、检查 Nginx 配置每次修改完都先执行:/www/server/nginx/sbin/nginx -t如果显示:syntax is ok test is successful再重新加载:/www/server/nginx/sbin/nginx -s reload不要直接重启 Nginx。这样即使配置写错,也不会直接把现有网站全部打断。十八、曾遇到的 Nginx 报错遇到过:nginx: [emerg] "location" directive is not allowed here原因是把:location / { }写到了:server { }外面。Nginx 正确结构必须是:server { listen 80; server_name example.com; location / { ... } }不能:location / { } server { }十九、Cloudflare 域名如何访问 noVNC如果另有一个域名:xxx.com托管在 Cloudflare,可以让它访问相同的 noVNC。Cloudflare DNS:类型:A 名称:@ 内容:CentOS公网IP 代理状态:已代理(橙色云)访问:https://xxx.com时,浏览器实际上还是访问:Cloudflare :443 → CentOS Nginx :443然后由 Nginx 再反代到:127.0.0.1:16081这是正常行为。DNS 本身只负责:域名 → IPDNS 不负责:域名 → IP:端口所以不能配置:xxx.com → CentOSIP:16081二十、CNAME 能不能用可以。例如:xxx.com CNAME vnc.agblr.xyz但是要注意:CNAME 只是 DNS 别名。访问:https://xxx.com时 HTTP Host 仍然是:xxx.com不会自动变成:vnc.agblr.xyz因此 Nginx 仍然需要:server_name vnc.agblr.xyz xxx.com;否则 Nginx 可能匹配到其他站点。同时 CNAME 不能写:vnc.agblr.xyz:16081也不能写:https://vnc.agblr.xyz/vnc.html因为 DNS 不理解端口和 URL 路径。二十一、URL 跳转与反向代理的区别如果只要求:访问 xxx.com然后浏览器地址变成:vnc.agblr.xyz可以使用 Cloudflare Redirect Rules。这种属于:301/302 跳转最终地址栏会发生变化。例如:https://xxx.com ↓ 302 ↓ https://vnc.agblr.xyz但是如果要求:访问 https://xxx.com 地址栏始终保持: https://xxx.com 实际访问: noVNC则应该使用:Nginx reverse_proxy而不是 URL 跳转。二十二、Cloudflare + noVNC 最终链路最终推荐:浏览器 │ │ HTTPS / WSS ▼ Cloudflare │ │ HTTPS ▼ CentOS 宝塔 Nginx │ │ HTTP + WebSocket ▼ 127.0.0.1:16081 │ ▼ FRPS │ ▼ FRPC │ ▼ Armbian 127.0.0.1:6081 │ ▼ noVNC如果使用 Cloudflare 橙色云,建议:SSL/TLS: Full (strict)同时源站也申请正常 HTTPS 证书。二十三、常用排错命令查看 FRPSsystemctl status frps日志:journalctl -u frps -f监听:ss -lntp | grep 7000查看 FRPCsystemctl status frpc日志:journalctl -u frpc -f查看映射端口CentOS:ss -lntp | grep -E '16081|2333'正常:127.0.0.1:16081 127.0.0.1:2333noVNC 测试CentOS:curl -I http://127.0.0.1:160811Panel 测试curl -I http://127.0.0.1:2333Nginx 检查/www/server/nginx/sbin/nginx -t重新加载:/www/server/nginx/sbin/nginx -s reload二十四、安全建议当前架构中最重要的安全设计是:proxyBindAddr = "127.0.0.1"因此:16081 2333没有直接暴露公网。公网真正开放的是:80 443 7000推荐继续保持这种模式:公网 ↓ Nginx ↓ 本机 FRP 映射端口而不要直接:公网IP:16081 公网IP:2333尤其是 1Panel 这种管理后台,更不建议直接暴露原始端口。另外建议:FRP 使用长随机 Token1Panel 开启安全入口1Panel 开启强密码或二次认证noVNC 本身设置 VNC 密码对管理后台增加访问限制宝塔开启 HTTPSCloudflare 使用 Full (strict)不对公网开放 16081 / 2333二十五、最终效果最终可以实现:https://vnc.agblr.xyz ↓ Armbian noVNChttps://a.agblr.xyz ↓ Armbian 1Panel如果 Cloudflare 还有:xxx.com也可以通过:A / CNAME + Nginx server_name让:https://xxx.com访问同一个 noVNC 服务。整个方案不依赖第三方免费内网穿透节点,核心链路全部自己控制:Armbian ↓ FRPC ↓ 自己的公网 CentOS ↓ FRPS ↓ 宝塔 Nginx ↓ 自己的域名相比共享式内网穿透,优势主要是:节点自己控制 带宽自己控制 延迟更加可控 不限隧道数量 不限自定义域名 不限第三方免费流量配额 支持 HTTPS 支持 WebSocket 容易排错对于 noVNC、1Panel、SSH Web Terminal 等需要长期稳定访问的服务,这种架构更加合适。
2026年09月19日
3 阅读
0 评论
0 点赞
2026-09-19
Armbian ARM64 搭建 MATE + TigerVNC + noVNC + XRDP + 中文输入法 + Cloudflare Tunnel 完整教程
一、环境与最终架构本文适用于:系统:Armbian 23.02.2 Jammy 基础系统:Ubuntu 22.04 LTS 架构:aarch64 / arm64 内存:4GB 存储:约 15GB eMMC 桌面:MATE 使用用户:root最终架构: Internet │ Cloudflare Tunnel │ ▼ 自己的域名 │ ▼ noVNC :6081 │ ▼ TigerVNC :5901 │ ▼ DISPLAY=:1 │ MATE Desktop │ ┌───────────────────┼─────────────────┐ │ │ │ XRDP Firefox Clash Verge :3389 Fcitx5拼音整个系统只维护:DISPLAY=:1一个真实桌面。RDP 和浏览器 noVNC 全部看同一个桌面。二、更换 Ubuntu / Armbian 下载源1. 确认架构uname -m dpkg --print-architecture正常:aarch64 arm642. 备份源cp -a /etc/apt/sources.list \ /etc/apt/sources.list.bak.$(date +%Y%m%d-%H%M%S)cp -a /etc/apt/sources.list.d/armbian.list \ /etc/apt/sources.list.d/armbian.list.bak.$(date +%Y%m%d-%H%M%S) \ 2>/dev/null || true3. Ubuntu ARM64 使用 USTCcat > /etc/apt/sources.list <<'EOF' deb https://mirrors.ustc.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse EOF4. Armbian 使用台湾镜像cat > /etc/apt/sources.list.d/armbian.list <<'EOF' deb [signed-by=/usr/share/keyrings/armbian.gpg] http://mirror.twds.com.tw/armbian-apt jammy main jammy-utils jammy-desktop EOF注意:该源虽然比之前自动分配的 Netcup 节点好一些,但我们实测 Firefox 大文件仍可能只有几十 KB/s。所以 Firefox 后面不要从这个 Armbian 源下载安装。5. 更新apt clean rm -rf /var/lib/apt/lists/* apt updateUSTC 正常情况下应该能达到数 MB/s。三、安装 MATE / TigerVNC / XRDP / noVNC 基础组件apt install -y \ git wget curl gpg dbus-x11 \ xrdp \ tigervnc-standalone-server \ tigervnc-tools \ websockify \ mate-desktop-environment-core \ mate-terminal \ mate-system-monitor \ mate-utils \ mate-panel \ mate-applets \ caja \ caja-open-terminal \ mate-polkit \ mate-notification-daemon \ network-manager-gnome \ gnome-keyring \ at-spi2-core \ arc-theme \ papirus-icon-theme \ mate-applet-brisk-menu四、中文环境apt install -y \ language-pack-zh-hans \ language-pack-gnome-zh-hans \ fonts-noto-cjk \ fonts-wqy-microheilocale-gen zh_CN.UTF-8系统全局保持:cat > /etc/default/locale <<'EOF' LANG=en_US.UTF-8 LANGUAGE=en_US:en EOF不要设置全局:LC_ALL=zh_CN.UTF-8中文只在 MATE 桌面会话中启用。五、配置 MATEdbus-run-session -- gsettings set \ org.mate.session required-components-list \ "['windowmanager']"打开桌面:dbus-run-session -- gsettings set \ org.mate.background show-desktop-icons true主题:dbus-run-session -- gsettings set \ org.mate.interface gtk-theme 'Arc' dbus-run-session -- gsettings set \ org.mate.interface icon-theme 'Papirus' dbus-run-session -- gsettings set \ org.mate.Marco.general theme 'Arc'六、安装 Fcitx5 中文拼音apt install -y \ fcitx5 \ fcitx5-chinese-addons \ fcitx5-config-qt \ fcitx5-frontend-gtk3 \ fcitx5-frontend-qt5 \ im-config设置:im-config -n fcitx5创建目录:mkdir -p /root/.config/fcitx5 mkdir -p /root/.local/share/fcitx5/pinyin配置:cat > /root/.config/fcitx5/profile <<'EOF' [Groups/0] Name=默认 Default Layout=us DefaultIM=pinyin [Groups/0/Items/0] Name=pinyin Layout= [Groups/0/Items/1] Name=keyboard-us Layout= [GroupOrder] 0=默认 EOFShift 切中英文:cat > /root/.config/fcitx5/config <<'EOF' [Hotkey] EnumerateWithTriggerKeys=False EnumerateSkipFirst=False [Hotkey/TriggerKeys] 0=Control+space [Hotkey/AltTriggerKeys] 0=Shift_L 1=Shift_R [Behavior] ActiveByDefault=True EOF七、TigerVNC 常驻桌面设置密码mkdir -p /root/.vnc tigervncpasswd /root/.vnc/passwd chmod 600 /root/.vnc/passwd配置:cat > /root/.vnc/config <<'EOF' geometry=2160x1350 depth=24 localhost alwaysshared securitytypes=vncauth EOF绑定 root:grep -q '^:1=root$' /etc/tigervnc/vncserver.users \ || echo ':1=root' >> /etc/tigervnc/vncserver.users八、创建 MATE 桌面启动脚本cat > /usr/local/bin/mate-vnc-session.sh <<'EOF' #!/bin/bash export LANG=zh_CN.UTF-8 export LANGUAGE=zh_CN:zh:en_US:en export LC_MESSAGES=zh_CN.UTF-8 export XDG_SESSION_TYPE=x11 export XDG_CURRENT_DESKTOP=MATE export DESKTOP_SESSION=mate export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS=@im=fcitx if ! pgrep -x fcitx5 >/dev/null 2>&1; then fcitx5 -d >/tmp/fcitx5.log 2>&1 & fi sleep 1 mate-session & MATE_PID=$! sleep 2 if ! pgrep -x mate-panel >/dev/null 2>&1; then mate-panel >/tmp/mate-panel-vnc.log 2>&1 & fi sleep 1 pkill -TERM -x caja 2>/dev/null || true sleep 1 caja \ --no-default-window \ --force-desktop \ >/tmp/caja-vnc.log 2>&1 & wait "$MATE_PID" EOFchmod +x /usr/local/bin/mate-vnc-session.sh bash -n /usr/local/bin/mate-vnc-session.sh无输出即正常。九、TigerVNC Sessioncat > /root/.vnc/Xtigervnc-session <<'EOF' #!/bin/bash export LANG=zh_CN.UTF-8 export LANGUAGE=zh_CN:zh:en_US:en export LC_MESSAGES=zh_CN.UTF-8 export XDG_SESSION_TYPE=x11 export XDG_CURRENT_DESKTOP=MATE export DESKTOP_SESSION=mate export XDG_RUNTIME_DIR=/run/user/0 mkdir -p "$XDG_RUNTIME_DIR" chmod 700 "$XDG_RUNTIME_DIR" unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS exec dbus-run-session -- /usr/local/bin/mate-vnc-session.sh EOFchmod +x /root/.vnc/Xtigervnc-session十、安装 noVNCrm -rf /opt/novncgit clone \ --branch v1.3.0 \ --depth 1 \ https://github.com/novnc/noVNC.git \ /opt/novnc删除 Git 元数据:rm -rf /opt/novnc/.git创建首页:cat > /opt/novnc/index.html <<'EOF' <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="refresh" content="0;url=/vnc.html?path=websockify&resize=scale&autoconnect=true"> <title>Remote Desktop</title> <script> location.replace('/vnc.html?path=websockify&resize=scale&autoconnect=true'); </script> </head> <body></body> </html> EOF服务:cat > /etc/systemd/system/novnc.service <<'EOF' [Unit] Description=noVNC Web Remote Desktop After=network-online.target tigervncserver@:1.service Wants=network-online.target tigervncserver@:1.service [Service] Type=simple ExecStart=/usr/bin/websockify --web=/opt/novnc 0.0.0.0:6081 127.0.0.1:5901 Restart=always RestartSec=2 [Install] WantedBy=multi-user.target EOF配置novnc自动复制粘贴:cat > /opt/novnc/clipboard-sync.js <<'EOF' import UI from "./app/ui.js"; let lastRemoteText = ""; let lastLocalText = ""; /* * 获取当前 RFB 实例 */ function getRFB() { if (!UI || !UI.rfb) { return null; } return UI.rfb; } /* * 本机浏览器剪贴板 -> 远程 TigerVNC */ async function syncLocalToRemote() { const rfb = getRFB(); if (!rfb) { return; } if (!navigator.clipboard || !navigator.clipboard.readText) { return; } try { const text = await navigator.clipboard.readText(); if (!text) { return; } /* * 避免远端刚同步回来的内容又循环发送 */ if (text === lastRemoteText || text === lastLocalText) { return; } lastLocalText = text; rfb.clipboardPasteFrom(text); console.debug("[noVNC Clipboard] Local -> Remote"); } catch (err) { /* * Firefox / Safari 或未授权时可能进入这里。 * Ctrl+V 的 paste 事件仍然可以工作。 */ console.debug( "[noVNC Clipboard] Cannot read browser clipboard:", err ); } } /* * 用户直接 Ctrl+V 时: * 浏览器剪贴板 -> 远程 * * 这是兼容性最好的一种方式, * 不依赖 navigator.clipboard.readText 权限。 */ window.addEventListener("paste", function (event) { const rfb = getRFB(); if (!rfb) { return; } let text = ""; if (event.clipboardData) { text = event.clipboardData.getData("text/plain"); } if (!text) { return; } lastLocalText = text; rfb.clipboardPasteFrom(text); /* * 防止 Ctrl+V 同时被远程系统再次当作键盘事件, * 避免重复粘贴。 */ event.preventDefault(); event.stopPropagation(); console.debug("[noVNC Clipboard] Paste -> Remote"); }, true); /* * 远程 TigerVNC -> 本机系统剪贴板 */ function hookRemoteClipboard() { const rfb = getRFB(); if (!rfb) { return; } /* * 防止重复绑定 */ if (rfb.__autoClipboardHooked) { return; } rfb.__autoClipboardHooked = true; rfb.addEventListener("clipboard", async function (event) { if (!event.detail) { return; } const text = event.detail.text; if (typeof text !== "string") { return; } lastRemoteText = text; if (!navigator.clipboard || !navigator.clipboard.writeText) { return; } try { await navigator.clipboard.writeText(text); console.debug( "[noVNC Clipboard] Remote -> Local" ); } catch (err) { /* * 浏览器拒绝后台写剪贴板时, * noVNC 原本的 Clipboard 面板仍然可以使用。 */ console.debug( "[noVNC Clipboard] Cannot write browser clipboard:", err ); } }); console.info( "[noVNC Clipboard] Automatic clipboard synchronization enabled" ); } /* * UI.rfb 是连接时才创建, * 所以定期检测并挂载事件。 */ setInterval(hookRemoteClipboard, 500); /* * 切回 noVNC 窗口时, * 尝试自动把电脑剪贴板同步给远程。 */ window.addEventListener("focus", function () { setTimeout(syncLocalToRemote, 100); }); /* * 鼠标重新点击 VNC 区域时也尝试同步 */ document.addEventListener("pointerdown", function () { syncLocalToRemote(); }, { passive: true }); EOFsed -i '/<\/head>/i \ <script type="module" src="./clipboard-sync.js"></script>' /opt/novnc/vnc.html十一、配置 XRDP 共用 TigerVNC备份:cp -a /etc/xrdp/xrdp.ini \ /etc/xrdp/xrdp.ini.bak确认:find /usr/lib -name libvnc.so然后:python3 - <<'PY' from pathlib import Path import re p = Path("/etc/xrdp/xrdp.ini") text = p.read_text() for section in ("Xorg", "GEA-Desktop"): pattern = rf'(?ms)^\[{re.escape(section)}\]\s*\n.*?(?=^\[|\Z)' text = re.sub(pattern, '', text) text = re.sub(r'(?m)^autorun=.*$', 'autorun=', text) vnc = """[Xorg] name=GEA-Desktop lib=libvnc.so ip=127.0.0.1 port=5901 username=na password=ask code=0 delay_ms=2000 """ pos = text.find("[Channels]") if pos >= 0: text = text[:pos] + vnc + text[pos:] else: text += "\n" + vnc p.write_text(text) PY检查:grep -A10 '^\[Xorg\]' /etc/xrdp/xrdp.ini十二、开启远程桌面服务systemctl daemon-reload systemctl enable tigervncserver@:1.service systemctl enable novnc.service systemctl enable xrdp.service systemctl enable xrdp-sesman.servicesystemctl restart tigervncserver@:1.service sleep 4 systemctl restart novnc.service systemctl restart xrdp.service检查:ss -lntp | grep -E '3389|5901|6081'应该:*:3389 127.0.0.1:5901 0.0.0.0:6081十三、安装 Clash Verge Rev —— 完整版为什么要先装 Clash当前实际网络测试说明:USTC Ubuntu 源 几 MB/s Armbian 大文件 十几~几百 KB/s GitHub Release 直连 几十 KB/s GitHub 经 gh-proxy 约 5~6 MB/s因此后面的 Firefox 官方下载需要 Clash 帮忙。Clash Verge Rev 官方当前 v2.5.2 提供 Linux ARM64 .deb。1. 下载 Clash Verge Rev ARM64进入桌面目录:cd /root/Desktop使用 GitHub 加速:wget --no-proxy \ -O clash-verge-arm64.deb \ "https://gh-proxy.com/https://github.com/clash-verge-rev/clash-verge-rev/releases/download/v2.5.2/Clash.Verge_2.5.2_arm64.deb"检查:ls -lh clash-verge-arm64.deb确认架构:dpkg-deb -f clash-verge-arm64.deb Architecture必须:arm64确认软件:dpkg-deb -f clash-verge-arm64.deb Package dpkg-deb -f clash-verge-arm64.deb Version2. 安装 Clashapt install -y ./clash-verge-arm64.debAPT 可能额外安装:libjavascriptcoregtk libsoup libwebkit2gtk这是正常依赖。3. 查启动命令command -v clash-verge如果返回:/usr/bin/clash-verge直接启动:DISPLAY=:1 clash-verge >/tmp/clash-verge.log 2>&1 &如果找不到:dpkg -L clash-verge | grep -E '/bin/|\.desktop$'4. Clash Verge 中进行配置在图形界面:导入订阅 → 更新订阅 → 选择可用节点 → 启动系统代理建议开始阶段:先不用 TUN只使用系统代理。5. 检查 Mihomo 代理端口ss -lntp | grep -E '7890|7891|7897'之前这台设备实际端口为:127.0.0.1:7897如果输出:127.0.0.1:7897后文就全部使用 7897。6. 测试 Clashcurl -x http://127.0.0.1:7897 \ -I https://packages.mozilla.org/能够快速返回 HTTP 响应说明代理正常。十四、安装 Firefox —— 使用 Mozilla 官方 ARM64 DEB + Clash重要不要再执行:apt install firefox直接从 Armbian 源下载。因为现在会得到:http://mirror.twds.com.tw/armbian-apt Firefox 149而且下载可能只有:17 KB/s我们改为 Mozilla 官方 DEB 仓库。Mozilla 官方推荐 Debian/Ubuntu 使用 packages.mozilla.org APT 仓库安装 Firefox。1. 创建密钥目录install -d -m 0755 /etc/apt/keyrings2. 下载 Mozilla 官方密钥文件很小:wget -q \ https://packages.mozilla.org/apt/repo-signing-key.gpg \ -O /etc/apt/keyrings/packages.mozilla.org.asc检查:ls -lh /etc/apt/keyrings/packages.mozilla.org.asc可验证官方指纹:gpg -n -q \ --import \ --import-options import-show \ /etc/apt/keyrings/packages.mozilla.org.ascMozilla 官方给出的指纹为:35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A33. 添加 Mozilla 仓库cat > /etc/apt/sources.list.d/mozilla.list <<'EOF' deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main EOF4. 提高 Mozilla 优先级cat > /etc/apt/preferences.d/mozilla <<'EOF' Package: * Pin: origin packages.mozilla.org Pin-Priority: 1000 EOF5. 关键:明确让 APT 走 Clash仅在 Clash Verge 里开启“系统代理”:并不能保证 apt 使用代理所以必须明确指定:apt \ -o Acquire::http::Proxy="http://127.0.0.1:7897" \ -o Acquire::https::Proxy="http://127.0.0.1:7897" \ update然后:apt-cache policy firefox应该看到类似:Candidate: 156.x并且来源:https://packages.mozilla.org/apt优先级:10006. 通过 Clash 下载 Firefoxapt \ -o Acquire::http::Proxy="http://127.0.0.1:7897" \ -o Acquire::https::Proxy="http://127.0.0.1:7897" \ install -y firefox这一步 Firefox 的 70~80MB 文件会明确走:127.0.0.1:7897而不是依赖 Clash 的桌面系统代理设置。7. 安装中文语言包apt \ -o Acquire::http::Proxy="http://127.0.0.1:7897" \ -o Acquire::https::Proxy="http://127.0.0.1:7897" \ install -y firefox-l10n-zh-cn如果提示不存在:apt-cache search firefox-l10n | grep -i zh根据实际名称安装。Mozilla 官方 DEB 仓库提供 Firefox 的语言包。8. 验证 Firefoxwhich firefox firefox --version查看来源:apt-cache policy firefox必须优先来自:packages.mozilla.org9. 启动 Firefox从 MATE 菜单直接打开。或者:DISPLAY=:1 firefox >/tmp/firefox.log 2>&1 &十五、APT 临时与永久使用 Clash推荐平时使用临时代理。例如:apt \ -o Acquire::http::Proxy="http://127.0.0.1:7897" \ -o Acquire::https::Proxy="http://127.0.0.1:7897" \ install 包名如果确定 Clash 会长期运行,也可以:cat > /etc/apt/apt.conf.d/99clash-proxy <<'EOF' Acquire::http::Proxy "http://127.0.0.1:7897"; Acquire::https::Proxy "http://127.0.0.1:7897"; EOF以后:apt update默认走 Clash。但如果 Clash 关闭:APT 会连接失败。恢复:rm -f /etc/apt/apt.conf.d/99clash-proxy所以本文更推荐:APT 临时指定代理十六、安装 cloudflared —— 使用 GitHub 加速当前 cloudflared GitHub Release 提供 Linux ARM64 DEB。你已经实际测试:GitHub直连: 约 69 KB/s gh-proxy: 约 5.96 MB/s因此直接采用 GitHub 加速。1. 下载 cloudflaredcd /root/Desktop推荐固定当前版本 2026.9.1:wget --no-proxy \ -O cloudflared-arm64.deb \ "https://gh-proxy.com/https://github.com/cloudflare/cloudflared/releases/download/2026.9.1/cloudflared-linux-arm64.deb"2. 校验 SHA256因为 gh-proxy.com 是第三方代理,不是 Cloudflare/GitHub 官方域名,所以下载后必须校验。Cloudflare 官方 2026.9.1 ARM64 DEB 的 SHA256 为:ee3fe95ac038c70dc0bbe4823667a2794422fa30c6068520537dc2fe3d7ce282执行:echo \ "ee3fe95ac038c70dc0bbe4823667a2794422fa30c6068520537dc2fe3d7ce282 cloudflared-arm64.deb" \ | sha256sum -c -必须:cloudflared-arm64.deb: OK如果不是:OK不要安装,直接删除:rm -f cloudflared-arm64.deb3. 检查架构dpkg-deb -f cloudflared-arm64.deb Architecture应该:arm644. 安装apt install -y ./cloudflared-arm64.deb验证:cloudflared --version十七、配置 Cloudflare Tunnel进入 Cloudflare One:Networks → Connectors → Cloudflare Tunnel → Create Tunnel名字:agblr-desktopCloudflare 后台会生成类似:cloudflared service install eyJxxxxxxxxxxxxxxxx直接复制到设备执行。注意:不要把 Tunnel Token 发到聊天、论坛或 GitHub。检查服务systemctl status cloudflared --no-pagersystemctl is-enabled cloudflared应为:active (running) enabled十八、Cloudflare 映射 noVNCTunnel 中创建 Published Application:Hostname: agblr.funService:HTTPURL:http://127.0.0.1:6081最终:https://agblr.fun │ ▼ Cloudflare │ ▼ Cloudflare Tunnel │ ▼ 127.0.0.1:6081 │ ▼ noVNC │ ▼ TigerVNC :1十九、检查所有服务systemctl is-enabled tigervncserver@:1.service systemctl is-enabled novnc.service systemctl is-enabled xrdp.service systemctl is-enabled cloudflared 2>/dev/null检查端口ss -lntp | grep -E '3389|5901|6081|7897'正常:3389 xrdp 127.0.0.1:5901 Xtigervnc 0.0.0.0:6081 websockify 127.0.0.1:7897 verge-mihomo二十、检查唯一 MATE 桌面for PID in $(pgrep mate-session); do DISP=$(tr '\0' '\n' < /proc/$PID/environ 2>/dev/null | sed -n 's/^DISPLAY=//p' | head -1) echo "PID=$PID DISPLAY=$DISP" done只应存在:DISPLAY=:1二十一、重启最终验证reboot启动后:pgrep -a mate-session pgrep -a mate-panel pgrep -a caja pgrep -a fcitx5检查:ss -lntp | grep -E '3389|5901|6081'然后分别测试:局域网浏览器: http://设备IP:6081/ Windows RDP: 设备IP:3389 公网: https://agblr.fun/三个入口都必须进入:DISPLAY=:1同一个 MATE 桌面。二十二、重要下载原则这台机器当前网络建议:Ubuntu普通依赖 ↓ USTC GitHub大文件 ↓ gh-proxy.com ↓ 下载后尽量校验哈希 Firefox ↓ Mozilla官方APT ↓ 明确指定 Clash 127.0.0.1:7897 Armbian普通小包 ↓ mirror.twds.com.tw不要再让大 Firefox 包直接从:mirror.twds.com.tw/armbian-apt下载,因为实际已经测到只有:17.5 KB/s二十三、配置备份全部正常以后:mkdir -p /root/GEA-backupcp -a /root/.vnc /root/GEA-backup/ cp -a /root/.config/fcitx5 /root/GEA-backup/ cp -a /usr/local/bin/mate-vnc-session.sh /root/GEA-backup/ cp -a /etc/xrdp/xrdp.ini /root/GEA-backup/ cp -a /etc/systemd/system/novnc.service /root/GEA-backup/ cp -a /etc/apt/sources.list /root/GEA-backup/ cp -a /etc/apt/sources.list.d/armbian.list /root/GEA-backup/如果 Mozilla 已配置:cp -a /etc/apt/sources.list.d/mozilla.list \ /root/GEA-backup/ 2>/dev/null || true cp -a /etc/apt/preferences.d/mozilla \ /root/GEA-backup/ 2>/dev/null || true打包:tar czf /root/GEA-FULL-CONFIG-BACKUP.tar.gz \ -C /root GEA-backup务必再复制到其他电脑/NAS保存。
2026年09月19日
14 阅读
0 评论
1 点赞
2026-07-15
RHEL/CentOS 7.9 Chrony 时间同步服务
一、文档信息项目内容适用系统RHEL/CentOS 7.9服务名称chronyd端口UDP 123配置文件/etc/chrony.conf二、时间同步检查流程2.1 快速状态检查# 1. 检查系统时间同步状态 timedatectl期望输出:System clock synchronized: yesNTP service: active# 2. 检查 chrony 服务状态 systemctl status chronyd期望输出:Active: active (running)2.2 详细 NTP 源检查# 1. 查看 NTP 服务器源状态 chronyc sources -v状态符号说明:^* = 当前最佳源(系统正在使用)^+ = 良好备用源^- = 被排除的源^? = 源不可达或不可用^x = 被认为错误的源^~ = 时间波动太大# 2. 查看时间同步详情 chronyc tracking关键指标:Stratum:层级(1–15,越小越准确)System time:与 NTP 时间的偏差Leap status:Normal(正常)2.3 网络连通性检查# 测试内部 NTP 服务器连通性 ping -c 3 10.113.128.1 # 测试外部 NTP 服务器连通性 ping -c 3 ntp.aliyun.com三、Chrony 服务管理3.1 服务启停# 启动 chrony 服务 systemctl start chronyd # 停止 chrony 服务 systemctl stop chronyd # 重启 chrony 服务 systemctl restart chronyd # 重新加载配置(不重启服务) systemctl reload chronyd # 设置开机自启 systemctl enable chronyd # 删除开机自启 systemctl disable chronyd3.2 服务状态检查# 查看服务状态 systemctl status chronyd # 查看服务日志(实时) journalctl -u chronyd -f # 查看最近 50 行日志 journalctl -u chronyd --no-pager | tail -50四、Chrony 配置管理4.1 标准配置文件(/etc/chrony.conf)# 内部 NTP 服务器(主) server 10.113.128.1 iburst # 外部公共 NTP 服务器(备用) server ntp.aliyun.com iburst server ntp1.tencent.com iburst server cn.pool.ntp.org iburst参数说明:iburst:加速初始同步minpoll 6:最短轮询间隔 64 秒(2⁶)maxpoll 10:最长轮询间隔 1024 秒(2¹⁰)prefer:标记为首选服务器noselect:监控但不使用该源4.2 配置文件修改流程# 1. 备份原配置 cp /etc/chrony.conf /etc/chrony.conf.bak_$(date +%Y%m%d) # 2. 编辑配置文件 vi /etc/chrony.conf # 3. 检查配置文件语法(部分版本支持) chronyc -c reload sources # 4. 重新加载或重启服务 systemctl restart chronyd # 或 systemctl reload chronyd4.3 紧急手动时间设置# 查看当前时间 date # 手动设置时间(格式:YYYY-MM-DD HH:MM:SS) timedatectl set-time "2025-12-06 10:30:00"五、故障排查流程5.1 常见问题及解决方案问题现象可能原因解决方案System clock synchronized: no1. chronyd 未运行2. 无 NTP 服务器配置3. 网络不通1. systemctl start chronyd2. 编辑 /etc/chrony.conf3. 检查网络 / DNSchronyc sources 显示 ^?NTP 服务器不可达1. 检查网络连通性2. 检查防火墙3. 更换 NTP 服务器时间偏差很大初始时间设置错误1. 手动设置近似时间服务启动失败配置文件语法错误1. 检查配置文件2. 查看日志 journalctl -u chronyd层级(Stratum)过高时间源质量差1. 添加更多 NTP 服务器2. 设置 prefer 标记优选服务器5.2 防火墙配置# 检查防火墙状态 systemctl status firewalld firewall-cmd --state # 放行 NTP 服务(UDP 123) firewall-cmd --add-service=ntp --permanent firewall-cmd --reload # 验证规则 firewall-cmd --list-services | grep ntp5.3 DNS 配置检查# 检查 DNS 解析 nslookup ntp.aliyun.com nslookup 10.113.128.1 # 临时设置 DNS echo "nameserver 114.114.114.114" >> /etc/resolv.conf echo "nameserver 8.8.8.8" >> /etc/resolv.conf六、监控与维护6.1 日常监控命令# 监控时间同步状态(每 10 秒刷新) watch -n 10 'chronyc sources -v; echo "---"; chronyc tracking' # 查看时间偏差趋势 chronyc sourcestats6.2 日志检查# 实时查看日志 journalctl -u chronyd -f # 查看错误日志 journalctl -u chronyd -p err # 查看最近 100 行日志 journalctl -u chronyd -n 1006.3 性能指标指标正常范围检查命令时间偏差< 100mschronyc tracking层级(Stratum)2–5chronyc tracking服务器可达性377(八进制)chronyc sources轮询间隔64–1024 秒chronyc sources七、应急恢复流程7.1 Chrony 完全故障恢复# 1. 停止服务 systemctl stop chronyd # 2. 备份并重置配置 cp /etc/chrony.conf /etc/chrony.conf.bak cat > /etc/chrony.conf << EOF server 10.113.128.1 iburst server ntp.aliyun.com iburst server ntp1.tencent.com iburst driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync keyfile /etc/chrony.keys leapsectz right/UTC logdir /var/log/chrony local stratum 10 EOF # 3. 清除状态文件 rm -f /var/lib/chrony/* # 4. 启动服务 systemctl start chronyd # 5. 强制同步 chronyc -a makestep7.2 时间严重偏差恢复# 1. 停止 chrony systemctl stop chronyd # 2. 使用 ntpdate 手动同步 ntpdate -u 10.113.128.1 # 3. 启动 chrony systemctl start chronyd # 4. 检查状态 chronyc sources -v八、附录8.1 常用命令速查表命令功能示例timedatectl查看时间状态timedatectlchronyc sources查看 NTP 源chronyc sources -vchronyc tracking查看同步详情chronyc trackingchronyc activity查看活动状态chronyc activitychronyc ntpdata查看 NTP 数据chronyc ntpdatasystemctl status chronyd服务状态systemctl status chronydjournalctl -u chronyd查看日志journalctl -u chronyd -f8.2 国内推荐 NTP 服务器# 阿里云 ntp.aliyun.com ntp1.aliyun.com ntp2.aliyun.com # 腾讯云 ntp1.tencent.com ntp2.tencent.com time1.cloud.tencent.com # 国内公共 NTP 池 cn.pool.ntp.org # 教育网 ntp.tuna.tsinghua.edu.cn s1a.time.edu.cn8.3 配置验证清单[ ] chronyd 服务状态为 active (running)[ ] timedatectl 显示 System clock synchronized: yes[ ] chronyc sources 至少有一个 ^* 源[ ] chronyc tracking 显示 Leap status: Normal[ ] 时间偏差小于 100ms[ ] 防火墙已放行 UDP 123 端口[ ] DNS 可解析 NTP 服务器域名[ ] 日志无错误信息
2026年07月15日
7 阅读
0 评论
0 点赞
2026-07-15
vSphere 虚拟机磁盘扩容标准操作流程
一、前置说明本文适用于通过堡垒机登录 vSphere,对 Linux 虚拟机进行在线磁盘扩容的场景。操作前请务必确认业务可短暂停写,且已做好数据备份。二、登录 vSphere 并打开控制台通过堡垒机登录对应 vSphere 环境在 vSphere 顶部搜索框中,输入目标设备的 主机名或 IP,回车搜索在搜索结果中选中目标虚拟机,向下滑动页面点击 「启动 Web 控制台」若屏幕锁定,向上滑动解锁点击 「Not listed?」,切换为 root 用户登录输入用户名,点击 Next输入密码,点击 Sign In 或直接回车三、登录系统并查看当前磁盘在桌面空白处 右键 → 打开终端执行以下命令,查看当前磁盘结构:lsblk记录当前磁盘设备名(如 sda、sdb、sdc 等)及分区情况,为后续扩容做对照。四、在 vSphere 中为虚拟机创建快照(强烈建议)⚠️ 重要:扩容前务必先打快照,防止误操作导致数据丢失。切回 vSphere 管理界面选中目标虚拟机,点击 「快照」→「生成快照」填写快照名称(建议包含日期和用途,如 Before-disk-expand-20260121)点击 「创建」在底部 「近期任务」 中查看快照创建进度快照创建完成后,确认状态为 完成五、在 vSphere 中添加新硬盘在 vSphere 中选中目标虚拟机,点击 「操作」→「编辑设置」点击 「添加新设备」→「硬盘」设置新增硬盘容量(按需填写,如 100 GB)点击新添加的硬盘,展开详细配置:磁盘置备:选择 精简置备其余参数保持默认点击 「确定」 保存配置六、系统内识别新磁盘并分区回到 Web 控制台终端再次执行:lsblk此时应能看到新增加的磁盘(如 /dev/sdc),但无分区。对新磁盘进行分区:fdisk /dev/sdc按如下顺序输入:输入含义n新建分区p主分区回车默认分区号 1回车默认起始扇区回车默认结束扇区(使用整块磁盘)w保存并退出再次查看分区结果:lsblk确认出现新分区 /dev/sdc1。七、LVM 扩容操作1. 创建物理卷(PV)pvcreate /dev/sdc12. 将 PV 加入现有卷组(VG)本文示例卷组名为 vg01,请根据实际情况替换。vgextend vg01 /dev/sdc13. 扩展逻辑卷(LV)本文示例逻辑卷为 /dev/vg01/lv01,请按实际路径调整。lvextend -l +100%FREE /dev/vg01/lv014. 刷新文件系统⚠️ 注意:以下命令需根据实际文件系统类型选择其一。XFS 文件系统(常见于 CentOS 7+):xfs_growfs /dev/vg01/lv01ext4 文件系统:resize2fs /dev/vg01/lv01八、验证扩容结果执行以下任一命令进行验证:df -h或lsblk确认目标挂载点容量已正确增加。九、注意事项与最佳实践✅ 生产环境建议在 业务低峰期 操作✅ 扩容前必须 创建快照✅ 确认文件系统类型后再执行刷新命令✅ 操作后观察业务日志,确保无异常✅ 如扩容失败,可通过快照 恢复到操作前状态十、常见问题排查lsblk 看不到新盘? 尝试执行 echo "- - -" > /sys/class/scsi_host/host0/scan 触发总线扫描(host 编号根据实际情况调整)。xfs_growfs 报错? 确认 LV 已成功扩展,且挂载点正确(可先用 df -h 查看挂载路径)。vgextend 提示找不到 VG? 使用 vgdisplay 或 vgs 确认卷组名称是否正确。
2026年07月15日
2 阅读
0 评论
0 点赞