使用Ubuntu系统管理工具Landscape来构建离线APT仓库:第三篇
by liam zheng on 26 January 2022
继续第二篇博客文章,现在我们将注册Landscape客户端到服务端并管理软件仓库。
使用 https注册客户端
客户端可以通过https的方式进行注册从而使用本地软件仓库。大概的操作步骤如下:
- sudo apt-get update
- sudo apt-get install landscape-client
- 从Landscape服务器传送/etc/ssl/certs/landscape_server_ca.crt landscape到客户端
- 客户端能解析到Landscape服务器的FQDN
- sudo landscape-config –account-name standalone –url https://<server>/message-system –ping-url http://<server>/ping
- 从Landscape server 仪表板接受注册的客端
演示代码如下:
ubuntu@vm-ceph1:~$ sudo mv landscape_server_ca.crt /etc/ssl/certs/ ubuntu@vm-ceph1:~$ ping -c1 vm-landscape-server.maas PING vm-landscape-server.maas (192.168.122.91) 56(84) bytes of data. 64 bytes from vm-landscape-server.maas (192.168.122.91): icmp_seq=1 ttl=64 time=0.430 ms ubuntu@vm-ceph1:~$ ubuntu@vm-ceph1:~$ sudo landscape-config --account-name standalone --url https://vm-landscape-server.maas/message-system --ping-url http://vm-landscape-server.maas/ping enabled This script will interactively set up the Landscape client. It will ask you a few questions about this computer and your Landscape account, and will submit that information to the Landscape server. After this computer is registered it will need to be approved by an account administrator on the pending computers page. Please see https://landscape.canonical.com for more information. The computer title you provide will be used to represent this computer in the Landscape user interface. It's important to use a title that will allow the system to be easily recognized when it appears on the pending computers page. This computer's title [vm-ceph1]: A registration key may be associated with your Landscape account to prevent unauthorized registration attempts. This is not your personal login password. It is optional, and unless explicitly set on the server, it may be skipped here. If you don't remember the registration key you can find it at https://landscape.canonical.com/account/standalone Account registration key: The Landscape client communicates with the server over HTTP and HTTPS. If your network requires you to use a proxy to access HTTP and/or HTTPS web sites, please provide the address of these proxies now. If you don't use a proxy, leave these fields empty. HTTP proxy URL: HTTPS proxy URL: Landscape has a feature which enables administrators to run arbitrary scripts on machines under their control. By default this feature is disabled in the client, disallowing any arbitrary script execution. If enabled, the set of users that scripts may run as is also configurable. Enable script execution? [Y/n]: y By default, scripts are restricted to the 'landscape' and 'nobody' users. Please enter a comma-delimited list of users that scripts will be restricted to. To allow scripts to be run by any user, enter "ALL". Script users [ALL]: You may provide an access group for this computer e.g. webservers. Access group [ceph]: You may provide tags for this computer e.g. server,precise. Tags [vm-ceph1]: Please wait... Request a new registration for this computer now? [Y/n]: Y System successfully registered. ubuntu@vm-ceph1:~$
完成上述操作后,从仪表板接受客户端:

接受后,您可以看到这台计算机的标签是“vm-ceph1”,此标签将用于下一步的操作。
管理软件仓库
要让由Landscape管理的客户端使用您的本地仓库,您还需要进行下面的操作:
- 软件仓库创建一个存储库配置文件,如:
landscape-api create-repository-profile –description “This profile is for Landscape On-Premises servers.” example-profile - 计算机与存储库配置文件相关联,如:
landscape-api associate-repository-profile –tags example-tag example-profile - 将Pockets添加到存储库配置文件,如:
landscape-api add-pockets-to-repository-profile example-profile release,updates,security bionic ubuntu - 确认客户端 /etc/apt/source.list 变成:
deb http://your-server.com/repository/standalone/ubuntu focal-security main restricted universe multiverse
deb http://your-server.com/repository/standalone/ubuntu focal main restricted universe multiverse
deb http://your-server.com/repository/standalone/ubuntu focal-updates main restricted universe multiverse - 如果需要恢复:
landscape-api disassociate-repository- profile –tags example-tag example-profile
示例命令和输出:
ubuntu@vm-landscape-server:~$ landscape-api create-repository-profile --description "This profile is for Landscape On-Premises servers." example-profile
{u'access_group': u'global',
u'all_computers': False,
u'apt_sources': [],
u'description': u'This profile is for Landscape On-Premises servers.',
u'id': 1,
u'name': u'example-profile',
u'pending_count': 0,
u'pockets': [],
u'tags': [],
u'title': u'example-profile'}
ubuntu@vm-landscape-server:~$
ubuntu@vm-landscape-server:~$ landscape-api associate-repository-profile --tags vm-ceph1 example-profile
{u'access_group': u'global',
u'all_computers': False,
u'apt_sources': [],
u'description': u'This profile is for Landscape On-Premises servers.',
u'id': 1,
u'name': u'example-profile',
u'pending_count': 1,
u'pockets': [],
u'tags': [u'vm-ceph1'],
u'title': u'example-profile'}
ubuntu@vm-landscape-server:~$
ubuntu@vm-landscape-server:~$ landscape-api add-pockets-to-repository-profile example-profile updates focal ubuntu
{u'access_group': u'global',
u'all_computers': False,
u'apt_sources': [],
u'description': u'This profile is for Landscape On-Premises servers.',
u'id': 1,
u'name': u'example-profile',
u'pending_count': 1,
u'pockets': [{u'apt_source_line': u'deb http://vm-landscape-server.maas/repository/standalone/ubuntu focal-updates restricted',
u'architectures': [u'amd64'],
u'components': [u'restricted'],
u'creation_time': u'2022-01-04T08:50:46Z',
u'gpg_key': {u'fingerprint': u'be50:6aea:aaaa:977f:0302:b161:c308:d9a6:a02f:e060',
u'has_secret': True,
u'id': 1,
u'key_id': u'C308D9A6A02FE060',
u'name': u'mirror-key'},
u'include_udeb': False,
u'mirror_suite': u'focal-updates',
u'mirror_uri': u'http://hk.archive.ubuntu.com/ubuntu/',
u'mode': u'mirror',
u'name': u'updates'}],
u'tags': [u'vm-ceph1'],
u'title': u'example-profile'}
ubuntu@vm-landscape-server:~$
到此就完成了利用Landscape创建APT本地离线软件仓库的教程。Landscape系统管理工具可免费在10台机器上使用,如您有超过10台的机器需要使用Landscape来管理,那么建议您通过Ubuntu Advantage订阅服务来获得单节点最多40000台机器的功能。
如您有相关问题,可联系我们以了解更多关于Landscape的支持服务内容。
附录: 有用的参考文档链接
订阅博客文章
查看更多内容
Canonical 发布 Ubuntu 26.04 LTS Resolute Raccoon
Ubuntu 为企业工作负载提供深度芯片优化与前沿安全防护(第 11 个长期支持版本)。 2026 年 4 月 23 日,Canonical 正式发布代号为 “Resolute Raccoon” 的 Ubuntu 26.04 LTS,用户可通过 Ubuntu 下载页面进行下载并安装。 Resolute Raccoon 在过渡版本推出的高稳定性优化基础上进一步升级,支持 TPM 硬件全盘加密、优化应用权限弹窗提示功能、为基于 Arm® 架构的服务器提供 Livepatch 实时补丁更新,并采用基于 Rust 语言的工具以提升内存安全性。该版本原生支持 NVIDIA CUDA、AMD ROCm 等行业领先的 AI/ML 工具包,使 Ubuntu 26.04 LTS 成为 AI […]
Ubuntu Pro 部署 Nutanix 裸机 Kubernetes
Nutanix 与 Canonical 扩大合作,为容器化工作负载提供更多选择 企业级 Kubernetes® 正逐步发展为高度灵活的多架构模型。随着 AI/ML 及数据密集型工作负载对硬件吞吐量的要求不断提升,企业在追求裸机性能的同时,也希望兼顾云平台的运维一致性。 为满足这一需求,Nutanix 与 Canonical 已将 Ubuntu Pro 服务拓展至裸机环境下运行的 Nutanix Kubernetes 平台 (NKP) 实例,涵盖最新发布的 NKP Metal 解决方案。本次功能拓展基于双方 2025 年达成的合作,彼时搭载安全补丁的 Ubuntu 操作系统可支持虚拟机环境下运行的 NKP 实例。安全补丁服务隶属于 Ubuntu Pro,是 Canonica […]
Canonical 发布 Ubuntu Core 26
Ubuntu Core 26 推出精准化 Linux 构建、优化的 OTA 更新、实时内核补丁,以及面向关键任务部署的增强型硬件级安全防护。 2026 年 5 月 19 日,Canonical 宣布正式发布 Ubuntu Core 26。该系统为极简不可变操作系统,提供长达 15 年的安全维护支持。 Ubuntu Core 26 针对关键任务操作与低延迟 AI 工作负载实现重大系统改进:安装时长缩短、OTA 更新包体积缩减 90%,并借助 Chisel 工具实现精准化系统构建。与以往版本一致,所有组件均为经过沙箱隔离、加密签名的 Snap 软件包,构建可信启动链,仅允许运行经验证的软件。凭借这款全新长期支持(LTS)版本,Ubuntu Core 仍是适用于关键任务系统的 […]