Nano Server 2015中的程序包管理

时间:2020-01-09 10:46:52  来源:igfitidea点击:

在Windows Server 2015中,除了熟悉的Server Core和Full GUI外,还有另一个名为" Nano Server"的安装选项。 Nano Server是Windows Server安装的更紧凑版本,旨在运行云容器和应用程序。为了减小系统的大小,所有角色,组件和驱动程序均从Nano Server镜像中删除。我们可以将它们下载并安装为软件包。我们可以从Windows Server 2015分发镜像(..\Nano Server\Packages)或者从联机程序包存储库中获取这些程序包。在本文中,我们将讨论Windows Nano Server 2015中软件包管理的特殊性。

可以将Nano Server程序包与Windows Server角色和组件进行比较,必要时管理员可以安装Windows Server角色和组件。我们可以在部署期间从主机系统在主机上的Nano Server镜像中安装软件包(使用New-NanoServerImage cmdlet),编辑镜像时(Edit-NanoServerImage)或者使用DISM或者PackageManagement模块(也称为OneGet) 。

从Hyper-V主机连接到已部署的Nano VM:

Enter-PSSession Nano1

下载并导入PowerShell的NanoServerPackage模块:

Save-Module -Path "$env:ProgramFiles\WindowsPowerShell\Modules" -Name NanoServerPackage -MinimumVersion 1.0.0.0
Import-PackageProvider NanoServerPackage

显示可用的Nano Server软件包的列表,如下所示:

find-NanoServerPackage -Name *

或者使用更通用的命令:

Find-Package -ProviderName NanoServerPackage

要在正在运行的Nano Server上安装软件包(例如,存储组件软件包Storage Package),请运行以下命令:

Install-NanoServerPackage -Name Microsoft-NanoServer-Storage-Package

要从PowerShell安装和启动IIS服务,安装命令将如下所示:

Install-Package -ProviderName NanoServerPackage -Name Microsoft-NanoServer-IIS-Package
Start-Service WAS
Start-Service W3SVC

我们可以将Nano程序包脱机直接安装到虚拟机的VHD/VHDX文件中:

Install-NanoServerPackage -Name Microsoft-NanoServer-Storage-Package  -culture en-us -RequiredVersion 10.0.14300.0 -ToVHd C:\VMstore\nano1\Nano1.vhd

可从官方存储库下载最新版本的Nano软件包,并将其添加到可用软件包列表中:

Find-NanoServerPackage -Name *Storage* -MaximumVersion 10.2 -MinimumVersion 1.0 -Culture en-us | Save-NanoServerPackage -Path C:\NanoBase\Packages

我们可以使用以下命令在线获取系统中已安装软件包的列表:

Get-Package

或者基于Nano VM镜像的VHD文件中的数据处于脱机模式:

Get-Package -provider NanoserverPackage -fromVhd C:\VMstore\nano1\Nano1.vhd

如果主机和Nano Server未连接到Internet,则可以使用DISM从CAB文件向系统镜像添加组件:

dism.exe /Mount-Image /ImageFile:C:\VMstore\nano1\Nano1.vhd /index:1 /mountdir:c:\mountdir
dism.exe /add-package /packagepath:c:\nanoserver\packages\Microsoft-NanoServer-IIS-Package_en-US.cab /image:c:\mountdir
dism.exe /unmount-image /mountdir:c:\mountdir /commit