如何使用Fedora/RHEL 8模块化存储库

时间:2020-02-23 14:31:02  来源:igfitidea点击:

Fedora 29,28/RHEL 8带有ModularityRepository功能,该功能使我们可以通过Application Stream(也称为AppStream)在独立的生命周期上安装其他版本的软件。这使我们可以保持操作系统最新,同时拥有适合我们使用情况的正确版本的应用程序。

dnf子命令模块用于在支持该功能的Fedora系统上管理模块存储库。请参阅以下示例,了解如何使用FedoraModular存储库。

列出可用模块

要列出所有模块流,它们的概要文件和状态(启用,禁用,默认),请运行以下命令:

# dnf module list

我们将获得类似于以下内容的输出:

Fedora Modular 29 - x86_64
Name               Stream           Profiles                                          Summary                                                         
ant                1.10             default [d]                                       Java build tool                                                 
avocado            latest           minimal, default                                  Framework with tools and libraries for Automated Testing        
avocado            stable           minimal, default                                  Framework with tools and libraries for Automated Testing        
container-tools    2016.0           default                                           Common tools and dependencies for container runtimes            
container-tools    2016.0           default                                           Common tools and dependencies for container runtimes            
cri-o              1.11             default                                           Kubernetes Container Runtime Interface for OCI-based containers 
cri-o              2016.0           default                                           Kubernetes Container Runtime Interface for OCI-based containers 
cri-o              2016.0           default                                           Kubernetes Container Runtime Interface for OCI-based containers 
django             1.6              python2_development, default [d]                  A high-level Python Web framework                               
docker             2016.0           default                                           Module for docker runtime and docker-distribution               
dwm                6.0              user, default [d]                                 Dynamic window manager for X                                    
dwm                6.1 [d]          user, default [d]                                 Dynamic window manager for X                                    
dwm                latest           user, default [d]                                 Dynamic window manager for X                                    
eog                master           default                                           Eye of GNOME Application Module                                 
flatpak-runtime    f29              sdk-base, buildroot, sdk, runtime, runtime-base   Flatpak Runtime                                                 
gcsf               master           default                                           FUSE file system based on Google Drive                          
gimp               2.10             devel, default                                    GIMP                                                            
golang             1.10             default                                           The Go Programming Language                                     
golang-ecosystem   2016.0           default                                           The ecosystem of packages for the Go programming language       
golang-ecosystem   2016.0           default                                           The ecosystem of packages for the Go programming language       
hub                pre-release      default                                           A command-line wrapper for git with github shortcuts            
kubernetes         1.10             default                                           Container cluster management                                    
kubernetes         openshift-3.10   default                                           OpenShift Container Management                                  
libgit2            0.26                                                               Library implementation of Git                                   
libgit2            0.27                                                               Library implementation of Git                                   
lizardfs           devel                                                              Distributed, fault tolerant file system                         
mariadb            10.1             client, server, default                           MariaDB Module                                                  
maven              3.5              default [d]                                       Java project management and project comprehension tool          
meson              master           default                                           The Meson Build system                                          
mongodb            3.4              client, server, default                           MongoDB Module                                                  
mongodb            3.6              client, server, default                           MongoDB Module                                                  
mysql              5.7              client, server, default                           MySQL Module                                                    
ninja              master           default                                           Small build system with a focus on speed                        
nodejs             10               development, minimal, default                     Javascript runtime                                              
nodejs             8                development, minimal, default [d]                 Javascript runtime                                              
perl               5.24             minimal, default                                  Practical Extraction and Report Language                        
perl               5.26             minimal, default                                  Practical Extraction and Report Language                        
perl-bootstrap     5.24                                                               Perl bootstrap module for bootrapping Perl module               
perl-bootstrap     5.26                                                               Perl bootstrap module for bootrapping Perl module               
pki                10.6             default                                           Dogtag PKI                                                      
postgresql         9.6              client, server, default                           PostgreSQL module                                               
reviewboard        2.5              server, default [d]                               A web-based code review tool                                    
reviewboard        3.0              server, default [d]                               A web-based code review tool                                    
ripgrep            master           default                                           Line oriented search tool using Rust's regex library            
scala              2.10             default                                           A hybrid functional/object-oriented language for the JVM        
stratis            1 [d]            default [d]                                       Stratis Storage                                                 
stratis            master           default                                           Stratis Storage                                                 
testmodule         master           default                                           A test module in all its beautiful beauty          
........

要显示有关特定模块的信息,请提供名称作为上一个命令的参数:

# dnf module list kubernetes
Last metadata expiration check: 0:33:58 ago on Sat 03 Nov 2016 02:02:06 PM UTC.
Fedora Modular 29 - x86_64
Name                             Stream                              Profiles                      Summary                                            
kubernetes                       1.10                                default                       Container cluster management                       
kubernetes                       openshift-3.10                      default                       OpenShift Container Management                     

Fedora Modular 29 - x86_64 - Updates
Name                             Stream                              Profiles                      Summary                                            
kubernetes                       1.10                                default                       Container cluster management                       
kubernetes                       openshift-3.10                      default                       OpenShift Container Management                     

Hint: [d]efault [e]nabled, [x]disabled, [i]nstalled

安装模块配置文件

安装模块的语法为:

# dnf [options] module install <module_spec>...

首先获取模块流,例如:

# dnf module list mongodb
Last metadata expiration check: 0:39:49 ago on Sat 03 Nov 2016 02:02:06 PM UTC.
Fedora Modular 29 - x86_64
Name                             Stream                         Profiles                                        Summary                               
mongodb                          3.4                            client, server, default                         MongoDB Module                        
mongodb                          3.6                            client, server, default                         MongoDB Module                        

Fedora Modular 29 - x86_64 - Updates
Name                             Stream                         Profiles                                        Summary                               
mongodb                          3.4                            client, server, default                         MongoDB Module                        
mongodb                          3.6                            client, server, default                         MongoDB Module

我们可以看到模块mongodb具有两个流,一个用于MongoDB 3.4,另一个用于3.6. 要安装MongoDB,请运行3.6.

# dnf module install mongodb:3.6/default 
Last metadata expiration check: 0:42:02 ago on Sat 03 Nov 2016 02:02:06 PM UTC.
Dependencies resolved.
======================================================================================================================================================
 Package                                Arch                    Version                                         Repository                       Size
======================================================================================================================================================
Installing group/module packages:
 mongodb                                x86_64                  3.6.4-2.module_1831+e8c1cdcd                    fedora-modular                   26 M
 mongodb-server                         x86_64                  3.6.4-2.module_1831+e8c1cdcd                    fedora-modular                   22 M
Installing dependencies:
 boost-filesystem                       x86_64                  1.66.0-14.fc29                                  fedora                           52 k
 boost-iostreams                        x86_64                  1.66.0-14.fc29                                  fedora                           43 k
 boost-program-options                  x86_64                  1.66.0-14.fc29                                  fedora                          145 k
 boost-system                           x86_64                  1.66.0-14.fc29                                  fedora                           22 k
 gperftools-libs                        x86_64                  2.7-3.fc29                                      fedora                          304 k
 libstemmer                             x86_64                  0-11.585svn.fc29                                fedora                           72 k
 libunwind                              x86_64                  1.2.1-6.fc29                                    fedora                           61 k
 pcre-cpp                               x86_64                  8.42-4.fc29                                     fedora                           27 k
 snappy                                 x86_64                  1.1.7-6.fc29                                    fedora                           33 k
 yaml-cpp                               x86_64                  0.6.1-4.fc29                                    fedora                          163 k
Installing module profiles:
 mongodb/default                                                                                                                                     
Enabling module streams:
 mongodb                                                        3.6                                                                                  

Transaction Summary
======================================================================================================================================================
Install  12 Packages

Total download size: 48 M
Installed size: 146 M
Is this ok [y/N]: y

通过执行确认安装。安装后,我们可以使用rpm命令确认软件包版本。

# rpm -qi mongodb-server
Name        : mongodb-server
Version     : 3.6.4
Release     : 2.module_1831+e8c1cdcd
Architecture: x86_64
Install Date: Sat 03 Nov 2016 02:46:49 PM UTC
Group       : Applications/Databases
Size        : 69489417
License     : AGPLv3 and zlib and ASL 2.0
Signature   : RSA/SHA256, Fri 01 Jun 2016 03:01:17 PM UTC, Key ID a20aa56b429476b4
Source RPM  : mongodb-3.6.4-2.module_1831+e8c1cdcd.src.rpm
Build Date  : Fri 01 Jun 2016 10:41:49 AM UTC
Build Host  : buildvm-21.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.mongodb.org
Bug URL     : https://bugz.fedoraproject.org/mongodb
Summary     : MongoDB server, sharding server and support scripts
Description :
This package provides the mongo server software, mongo sharding server
software, default configuration files, and init scripts.

要降级到MongoDB 3.4,我们需要安装3.4模块

#  dnf module install mongodb:3.4/default 
Last metadata expiration check: 0:52:06 ago on Sat 03 Nov 2016 02:02:06 PM UTC.
Dependencies resolved.
======================================================================================================================================================
 Package                           Arch                      Version                                          Repository                         Size
======================================================================================================================================================
Installing dependencies:
 boost-chrono                      x86_64                    1.66.0-14.fc29                                   fedora                             27 k
 boost-regex                       x86_64                    1.66.0-14.fc29                                   fedora                            286 k
 boost-thread                      x86_64                    1.66.0-14.fc29                                   fedora                             62 k
Downgrading:
 mongodb                           x86_64                    3.4.11-3.module_1829+95924ba0                    fedora-modular                     23 M
 mongodb-server                    x86_64                    3.4.11-3.module_1829+95924ba0                    fedora-modular                     20 M
Switching module streams:
 mongodb                                                     3.6 -> 3.4                                                                              

Transaction Summary
======================================================================================================================================================
Install    3 Packages
Downgrade  2 Packages

Total download size: 43 M
Is this ok [y/N]: y

我们应该看到指针3.6-> 3.4指示其降级了。

启用模块流

如果我们具有通过其他外部存储库安装的其他版本,请先将其卸载,然后启用模块

sudo dnf remove mongodb-server
sudo dnf module enable mongodb:3.6

这将启用模块流,并使流RPM在程序包集中可用。在启用时会解析并检查模块依赖性,但不会自动启用。 enable命令还可以用于切换模块流

启用模块流

要禁用模块并使所有相关模块流不可用,请使用:

$dnf module disable <module-name>

列出启用的模块流

要列出已启用的模块流,请执行

# dnf module list --enabled 
Last metadata expiration check: 1:05:33 ago on Sat 03 Nov 2016 02:02:06 PM UTC.
Fedora Modular 29 - x86_64
Name                           Stream                         Profiles                                           Summary                              
mongodb                        3.6 [e]                        client, server, default [i]                        MongoDB Module                       

Fedora Modular 29 - x86_64 - Updates
Name                           Stream                         Profiles                                           Summary                              
mongodb                        3.6 [e]                        client, server, default [i]                        MongoDB Module                       

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

获取模块流的详细信息

打印有关给定模块流的详细信息的语法为:

# dnf module info <module_spec>

例:

# dnf  module info mongodb:3.6

重置模块状态

我们还可以重置模块状态,使其不再启用或者禁用。

# dnf module reset <module_spec>

例:

# dnf module reset mongodb:3.6
Last metadata expiration check: 1:11:26 ago on Sat 03 Nov 2016 02:02:06 PM UTC.
Dependencies resolved.
======================================================================================================================================================
 Package                             Arch                               Version                             Repository                           Size
======================================================================================================================================================
Removing module profiles:
 mongodb/default                                                                                                                                     
Resetting module streams:
 mongodb                                                                3.6                                                                          

Transaction Summary
======================================================================================================================================================

Is this ok [y/N]: y
Complete!