首页 » Linux » 正文

CentOS 8 模块安装软件包

操作系统:CentOS 8
CentOS 8中采用模块的方式安装软件包,这样可以在一个源或者多个源中存在不同的版本的软件包,采用模块的方式可以根据需求选择不同版本的软件包,并且安装的时候不会产生冲突。

dnf module 或者 yum module命令帮助文档

Module Command
Module subcommands take … arguments that specify modules or profiles.
dnf [options] module install …
Install module profiles, including their packages.  In case no profile was provided, all default profiles  get  installed.
Module streams get enabled accordingly.
This  command cannot be used for switching module streams. It is recommended to remove all installed content from the module and reset the module using the reset command. After you reset the module, you can install the other stream. 
dnf [options] module update …
Update packages associated with an active module stream, optionally restricted to a profile.  If the profile_name is  provided, only the packages referenced by that profile will be updated.
dnf [options] module remove …
Remove  installed  module profiles, including their packages.  In case no profile was provided, all installed profiles get removed.
dnf [options] module enable …
Enable a module stream and make the stream RPMs available in the package set.
Modular dependencies are resolved, dependencies checked and also recursively enabled. In case of modular dependency  issue the operation will be rejected. To perform the action anyway please use --skip-broken option.
This  command cannot be used for switching module streams. It is recommended to remove all installed content from the module, and reset the module using the reset command. After you reset the module, you can enable the other stream.
dnf [options] module disable …
Disable a module. All related module streams will become unavailable. In case of modular dependency  issue  the  operation will be rejected. To perform the action anyway please use --skip-broken option.
dnf [options] module reset …
Reset module state so it's no longer enabled or disabled.
dnf [options] module list [--all] [module_name…]
Lists all module streams, their profiles and states (enabled, disabled, default).
dnf [options] module list --enabled [module_name…]
Lists module streams that are enabled.
dnf [options] module list --disabled [module_name…]
List module streams with installed profiles.
dnf [options] module info …
Print detailed information about given module stream.
dnf [options] module info --profile …
Print detailed information about given module profiles.
###列出所有模块:
    dnf module list  [--all] 
    输出所有可安装的模块的列表,其中[d]默认,[e]已启用,[x]已禁用,[i]已安装
###安装模块:
    dnf module install xxx
    安装默认的软件包模块,比如安装不同版本的nginx
[root@baidu ~]# dnf module list |grep nginx
nginx                1.14 [d]    common [d]                 nginx webserver
nginx                1.16        common                     nginx webserver
nginx                mainline    common                     nginx webserver
从上面可以看出,nginx包含三个版本,1.14 、 1.16 、mainline,默认是1.14版本,比如现在需要安装1.16版本,根据帮助文档提示,安装命令为(每一列表示的意思分别是Name Stream Profiles Summary),nginx的mainline版本存在于EPEL源的Modular源中。
dnf module install nginx:1.16/common
[root@baidu ~]# dnf module install nginx:1.16/common
上次元数据过期检查:0:05:03 前,执行于 2020年02月25日 星期二 13时16分28秒。
依赖关系解决。
===========================================================================================================================================
 软件包                                  架构               版本                                                仓库                   大小
===========================================================================================================================================
安装组/模块包:
 nginx                 x86_64    1:1.16.1-1.module_el8.1.0+250+351caf85     AppStream      581 k
 nginx-all-modules     noarch    1:1.16.1-1.module_el8.1.0+250+351caf85     AppStream      24 k
 nginx-filesystem      noarch    1:1.16.1-1.module_el8.1.0+250+351caf85     AppStream      25 k
 nginx-mod-http-image-filter   x86_64   1:1.16.1-1.module_el8.1.0+250+351caf85  AppStream  35 k
 nginx-mod-http-perl   x86_64    1:1.16.1-1.module_el8.1.0+250+351caf85     AppStream      46 k
 nginx-mod-http-xslt-filter    x86_64   1:1.16.1-1.module_el8.1.0+250+351caf85  AppStream  34 k
 nginx-mod-mail        x86_64    1:1.16.1-1.module_el8.1.0+250+351caf85     AppStream      64 k
 nginx-mod-stream      x86_64    1:1.16.1-1.module_el8.1.0+250+351caf85     AppStream      91 k
安装依赖关系:
gd                     x86_64    2.2.5-6.el8                                AppStream      144 k
libxslt                x86_64    1.1.32-3.el8                               BaseOS         249 k
安装模块配置档案:
 nginx/common
启用模块流:
 nginx                                                      1.16

事务概要
===========================================================================================================================================
安装  10 软件包

总下载:1.3 M
安装大小:3.6 M
确定吗?[y/N]:
###升级模块:
    dnf module update nginx
###重置模块:
    dnf module reset nginx
###模块信息:
    dnf module info nginx
###列出启用的模块:
    dnf module list --enabled
###列出禁用的模块:
    dnf module list --disabled
###列出XX软件包模块包含的软件包:
    dnf module info --profile xxxx
    比如dnf module info --profile nginx:1.16/common (如果不指定版本将会列出所有nginx不同版本的软件包)
###禁用软件包:
    dnf module disable xxx
    比如禁用nginx,dnf module disable nginx:1.16/common
###启用软件包:
    dnf module enable xxx
    比如启用nginx , dnf module enable nginx:1.16/common
###移除软件包:
    dnf module remove xxx
    比如移除nginx , dnf module remove nginx:1.16/common
所有的module 命令都可以指定或者不指定具体版本,不指定具体版本会执行默认配置,如果指定了具体版本需要以如下的命令格式进行具体版本的指定。
SPECIFYING MODULES
    allows one to select modules or profiles a particular operation should work on.
    It is in the form of NAME:STREAM:VERSION:CONTEXT:ARCH/PROFILE and supported partial forms are the following:    
    · NAME    
    · NAME:STREAM    
    · NAME:STREAM:VERSION    
    · NAME:STREAM:VERSION:CONTEXT    
    · all above combinations with ::ARCH (e.g. NAME::ARCH)    
    · NAME:STREAM:VERSION:CONTEXT:ARCH    
    · all above combinations with /PROFILE (e.g. NAME/PROFILE)   
    In  case stream is not specified, the enabled or the default stream is used, in this order. In case profile is not specified, the    system default profile or the 'default' profile is used.
dnf module模块指令可以使得相同或者不同的源中存在相同软件包的不同版本存在可能,这样可以根据实际需求去选择自己需要的版本,而不在受限于仅能安装某个版本的软件包。另外如果安装了某个版本的软件包,需要安装另外的版本的软件包的时候,需要执行dnf module reset xxx进行重置,此处不指定具体软件包版本,指定软件包名称即可

发表评论