Landscape Ubuntu 系统管理
Landscape 是 Canonical(Ubuntu 的母公司)推出的系统管理工具,专门用于管理 Ubuntu 服务器。它提供了集中化的系统监控、补丁管理、合规审计和批量操作功能。Landscape 分为 SaaS 版(Landscape Hosted)和自托管版(Landscape On-Premises)。对于管理多台搬瓦工 VPS 的用户来说,Landscape 可以大幅简化 Ubuntu 系统的维护工作。
一、Landscape 版本选择
- Landscape Hosted(SaaS):由 Canonical 托管,无需自行部署服务端。Ubuntu Pro 用户免费使用,最多管理 5 台机器。
- Landscape On-Premises(自托管):在自己的服务器上部署,适合管理大量服务器的场景。需要 Ubuntu Pro 订阅。
二、使用 Landscape Hosted(推荐入门)
2.1 注册与配置
# 首先注册 Ubuntu Pro 账户(免费个人版支持 5 台机器)
# 访问 https://ubuntu.com/pro 获取 token
# 在搬瓦工 VPS 上激活 Ubuntu Pro
pro attach YOUR_TOKEN
# 验证 Pro 状态
pro status
2.2 安装 Landscape 客户端
# 安装客户端
apt update
apt install landscape-client -y
# 注册到 Landscape Hosted
landscape-config --computer-title "my-bwg-vps" \
--account-name your-account \
--url https://landscape.canonical.com/message-system \
--ping-url http://landscape.canonical.com/ping
三、自托管 Landscape 部署
3.1 系统要求
- Ubuntu 22.04 LTS 或更高版本
- 至少 4GB 内存(推荐 8GB)
- 至少 20GB 磁盘空间
- PostgreSQL 数据库
3.2 安装 Landscape Server
# 添加 Landscape PPA
add-apt-repository ppa:landscape/self-hosted-24.04 -y
apt update
# 安装 Landscape Server
apt install landscape-server-quickstart -y
# 安装过程中会自动配置:
# - PostgreSQL 数据库
# - Apache Web 服务器
# - RabbitMQ 消息队列
# 访问 Web 界面完成初始设置
# https://your-landscape-server/
3.3 注册客户端到自托管服务
# 在被管理的 VPS 上安装客户端
apt install landscape-client -y
# 注册到自托管 Landscape
landscape-config --computer-title "web-server-01" \
--account-name standalone \
--url https://landscape-server/message-system \
--ping-url http://landscape-server/ping \
--ssl-public-key /etc/landscape/server.pem
四、核心功能
4.1 系统监控
Landscape 仪表板显示所有注册机器的状态概览,包括:
- CPU 和内存使用趋势
- 磁盘空间监控
- 网络流量统计
- 进程列表
- 安全更新状态
4.2 补丁管理
# 在 Landscape Web 界面中:
# 1. 查看所有可用更新
# 2. 选择特定服务器或服务器组
# 3. 批准并应用安全更新
# 4. 安排更新计划(如维护窗口期执行)
# 也可以通过命令行查看待更新包
landscape-sysinfo
4.3 批量操作
Landscape 支持对多台服务器同时执行操作:
- 批量安装/卸载软件包
- 批量执行 Shell 脚本
- 批量应用安全补丁
- 批量修改配置
4.4 合规审计
- USN(Ubuntu Security Notice)跟踪
- CVE 漏洞扫描状态
- 系统配置合规检查
- 软件包版本审计
五、服务器分组管理
# 在 Landscape 中可以创建服务器组(Tags)
# 例如:
# - production: 生产环境服务器
# - staging: 测试环境服务器
# - web-servers: Web 服务器集群
# - db-servers: 数据库服务器
# 基于标签可以:
# 1. 按组查看监控数据
# 2. 按组批量执行操作
# 3. 按组设置更新策略
六、脚本执行
# 在 Landscape Web 界面中可以远程执行脚本
# Activities > Run Script
# 示例:收集所有服务器的系统信息
#!/bin/bash
echo "=== $(hostname) ==="
echo "OS: $(lsb_release -ds)"
echo "Kernel: $(uname -r)"
echo "Uptime: $(uptime -p)"
echo "Disk: $(df -h / | tail -1 | awk '{print $5}')"
echo "Memory: $(free -h | grep Mem | awk '{print $3"/"$2}')"
# 脚本会在选中的所有服务器上执行
# 结果集中显示在 Landscape 界面中
七、Landscape 客户端管理
# 查看客户端状态
landscape-config --is-registered
# 重新配置客户端
landscape-config --reconfigure
# 禁用客户端
systemctl stop landscape-client
systemctl disable landscape-client
# 从 Landscape 中移除客户端
# 在 Web 界面中选择机器 > Actions > Remove
八、替代方案对比
- Landscape vs Ansible:Landscape 更偏向监控和补丁管理,Ansible 更偏向自动化部署和配置管理。
- Landscape vs Foreman:Landscape 专注 Ubuntu 系统,Foreman 支持多种 Linux 发行版。
- Landscape vs Cockpit:Landscape 适合批量管理多台服务器,Cockpit 适合单台服务器的图形化管理。
总结
Landscape 是管理 Ubuntu 服务器的专业工具,特别适合需要统一管理多台搬瓦工 VPS 的用户。它的补丁管理、合规审计和批量操作功能可以大幅降低运维成本。对于个人用户,Ubuntu Pro 的免费额度(5 台机器)已经足够使用。如果需要管理不同发行版的服务器,建议参考 Foreman 系统生命周期管理。选购搬瓦工 VPS 请查看全部方案,使用优惠码 NODESEEK2026 可享受 6.77% 循环折扣。