Linux云计算-05_Linux软件包管理

2023-11-20

本章介绍Linux系统软件的安装、卸载、配置、维护以及如何构建企业本地YUM光盘源及HTTP本地源。

1 RPM软件包管理

Linux软件包管理大致可分为二进制包、源码包,使用的工具也各不相同。Linux常见软件包分为两种,分别是源代码包(Source Code)、二进制包(Binary Code),源代码包是没有经过编译的包,需要经过GCC、C++编译器环境编译才能运行,二进制包无需编译,可以直接安装使用。

通常而言,可以通过后缀简单区别源码包和二进制包,例如.tar.gz、.zip、.rar结尾的包通常称之为源码包,以.rpm结尾的软件包称之为二进制包。真正区分是否为源码还是二进制还得基于代码里面的文件来判断,例如包含.h、.c、.cpp、.cc等结尾的源码文件,称之为源码包,而代码里面存在bin目录可以执行文件,称之为二进制包。

CentOS操作系统中有一款默认软件管理的工具,红帽包管理工具(Red Hat Package Manager,RPM)。

使用RPM工具可以对软件包实现快速安装、管理及维护。RPM管理工具适用的操作系统包括:CentOS,RedHat,Fedora,SUSE等,RPM工具常用于管理.rpm后缀结尾的软件包。

RPM软件包命令规则详解如下:

RPM包命名格式为:
name-version.rpm
name-version-noarch.rpm
name-version-arch.src.rpm
如下软件包格式:
epel-release-6-8.noarch.rpm
perl-Pod-Plainer-1.03-1.el6.noarch.rpm

以yasm-1.2.0-4.el7.x86_64.rpm为列解析如下:
RPM包格式解析如下:
    name              软件名称,例如yasm、perl-pod-Plainer;
    version         版本号,1.2.0通用格式:“主版本号.次版本号.修正号”;
4表示是发布版本号,该RPM包是第几次编译生成的;
    arch             适用的硬件平台,RPM支持的平台有:i386、i586、i686、x86_64、sparc、alpha等。
    .rpm            后缀包表示编译好的二进制包,可用rpm命令直接安装;
    .src.rpm        源代码包,源码编译生成.rpm格式的RPM包方可使用;
    el*              软件包发行版本,el6表示该软件包适用于RHEL 6.x/CentOS 6.x;
    devel:            开发包;
    noarch:           软件包可以在任何平台上安装。

RPM工具命令详解如下:

RPM 选项 PACKAGE_NAME
-a, --all                          查询所有已安装软件包;
-q,--query                        表示询问用户,输出信息;
-l, --list                      打印软件包的列表;
-f, --file                         FILE查询包含FILE的软件包;
-i, --info                         显示软件包信息,包括名称,版本,描述;
-v, --verbose                   打印输出详细信息;
-U, --upgrade                   升级RPM软件包;
-h,--hash                       软件安装,可以打印安装进度条;
--last                             列出软件包时,以安装时间排序,最新的在上面;
-e, --erase                     卸载rpm软件包
--force                         表示强制,强制安装或者卸载;
--nodeps                        RPM包不依赖
-l, --list                         列出软件包中的文件;
--provides                         列出软件包提供的特性;
-R, --requires                  列出软件包依赖的其它软件包;
--scripts                       列出软件包自定义的小程序。 

RPM企业案例演示:

# 检查sysstat包是否安装;
[root@superman-vm01 ~]# rpm -q sysstat
package sysstat is not installed
[root@superman-vm01 ~]# 

# 安装sysstat软件包;
[root@superman-vm01 ~]# rpm -ivh sysstat-10.1.5-17.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:sysstat-10.1.5-17.el7            ################################# [100%]
[root@superman-vm01 ~]#         

# 查看软件安装的路径;
[root@superman-vm01 ~]# rpm -ql sysstat
/etc/cron.d/sysstat
/etc/sysconfig/sysstat
/etc/sysconfig/sysstat.ioconf
/usr/bin/cifsiostat
/usr/bin/iostat
/usr/bin/mpstat
/usr/bin/nfsiostat-sysstat
/usr/bin/pidstat
/usr/bin/sadf
/usr/bin/sar
/usr/bin/tapestat
..........                                     

# 查看软件安装的版本信息;
[root@superman-vm01 ~]# rpm -qi sysstat
Name        : sysstat
Version     : 10.1.5
Release     : 17.el7
Architecture: x86_64
Install Date: Sat 10 Jul 2021 06:46:49 AM CST
Group       : Applications/System
Size        : 1172947
License     : GPLv2+
Signature   : RSA/SHA256, Mon 12 Nov 2018 10:47:27 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM  : sysstat-10.1.5-17.el7.src.rpm
Build Date  : Wed 31 Oct 2018 04:04:26 AM CST
Build Host  : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://sebastien.godard.pagesperso-orange.fr/
Summary     : Collection of performance monitoring tools for Linux
Description :
The sysstat package contains sar, sadf, mpstat, iostat, pidstat, nfsiostat-sysstat,
tapestat, cifsiostat and sa tools for Linux.
..........

# 卸载sysstat软件;
[root@superman-vm01 ~]# rpm -qa|grep sysstat
sysstat-10.1.5-17.el7.x86_64
[root@superman-vm01 ~]# 
[root@superman-vm01 ~]# rpm -e sysstat-10.1.5-17.el7.x86_64
[root@superman-vm01 ~]# 

# 升级sysstat软件;
[root@superman-vm01 ~]# rpm -Uvh sysstat-10.1.5-17.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:sysstat-10.1.5-17.el7            ################################# [100%]
[root@superman-vm01 ~]# 

# 检查sysstat相关的软件包是否安装;
[root@superman-vm01 ~]# rpm -qa|grep sysstat 
sysstat-10.1.5-17.el7.x86_64
[root@superman-vm01 ~]# 

# 强制卸载sysstat;
[root@superman-vm01 ~]# rpm -e --nodeps sysstat
[root@superman-vm01 ~]#

# 不依赖其它软件包;
[root@superman-vm01 ~]# rpm -ivh --nodeps sysstat-10.1.5-17.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:sysstat-10.1.5-17.el7            ################################# [100%]
[root@superman-vm01 ~]# 

2 Tar软件包管理

Linux操作系统除了使用RPM管理工具对软件包管理之外,还可以通过tar、zip、jar等工具进行源码包的管理。

2.1 Tar命令参数详解

-A, --catenate, --concatenate     将存档与已有的存档合并
-c, --create                     建立新的存档
-d, --diff, --compare            比较存档与当前文件的不同之处
--delete                        从存档中删除
-r, --append                    附加到存档结尾
-t, --list                      列出存档中文件的目录
-u, --update                    仅将较新的文件附加到存档中
-x, --extract, --get            解压文件
-j, --bzip2, --bunzip2            有bz2属性的软件包;
-z, --gzip, --ungzip            有gz属性的软件包;
-b, --block-size N              指定块大小为Nx512字节(缺省时 N=20);
-B, --read-full-blocks          读取时重组块;
-C, --directory DIR             指定新的目录;
--checkpoint                    读取存档时显示目录名;
-f, --file [HOSTNAME:]F         指定存档或设备,后接文件名称;
--force-local                   强制使用本地存档,即使存在克隆;
-G, --incremental               建立老GNU格式的备份;
-g, --listed-incremental        建立新GNU格式的备份;
-h, --dereference               不转储动态链接,转储动态链接指向的文件;
-i, --ignore-zeros              忽略存档中的0字节块(通常意味着文件结束);
--ignore-failed-read            在不可读文件中作0标记后再退出;
-k, --keep-old-files            保存现有文件;从存档中展开时不进行覆盖;
-K, --starting-file F           从存档文件F开始;
-l, --one-file-system           在本地文件系统中创建存档;
-L, --tape-length N             在写入N*1024个字节后暂停,等待更换磁盘;
-m, --modification-time         当从一个档案中恢复文件时,不使用新的时间标签;
-M, --multi-volume              建立多卷存档,以便在几个磁盘中存放;
-O, --to-stdout                 将文件展开到标准输出;
-P, --absolute-paths            不要从文件名中去除'/';
-v, --verbose                    详细显示处理的文件;
--version                        显示tar程序的版本号;
--exclude                         FILE不把指定文件包含在内;
-X, --exclude-from FILE            从指定文件中读入不想包含的文件的列表。
2.2.1 TAR命令实战
# 查看keepalived-2.2.2.tar.gz包中内容;
[root@superman-vm01 ~]# tar -tf keepalived-2.2.2.tar.gz
keepalived-2.2.2/
keepalived-2.2.2/tools/
keepalived-2.2.2/tools/timed_reload
keepalived-2.2.2/Makefile.in
keepalived-2.2.2/build-aux/
keepalived-2.2.2/build-aux/install-sh
keepalived-2.2.2/build-aux/missing
keepalived-2.2.2/build-aux/compile
keepalived-2.2.2/build-aux/depcomp
keepalived-2.2.2/build-aux/ar-lib
keepalived-2.2.2/bin_install/
keepalived-2.2.2/bin_install/Makefile.in
keepalived-2.2.2/bin_install/Makefile.am
keepalived-2.2.2/keepalived.spec.in
..........

# 解压keepalived-2.2.2.tar.gz程序包;
[root@superman-vm01 ~]# tar -xvf keepalived-2.2.2.tar.gz
keepalived-2.2.2/
keepalived-2.2.2/tools/
keepalived-2.2.2/tools/timed_reload
keepalived-2.2.2/Makefile.in
keepalived-2.2.2/build-aux/
keepalived-2.2.2/build-aux/install-sh
keepalived-2.2.2/build-aux/missing
keepalived-2.2.2/build-aux/compile
keepalived-2.2.2/build-aux/depcomp
keepalived-2.2.2/build-aux/ar-lib
keepalived-2.2.2/bin_install/
keepalived-2.2.2/bin_install/Makefile.in
keepalived-2.2.2/bin_install/Makefile.am
keepalived-2.2.2/keepalived.spec.in
keepalived-2.2.2/snap/
keepalived-2.2.2/snap/snapcraft.yaml
keepalived-2.2.2/snap/hooks/
keepalived-2.2.2/snap/hooks/post-refresh
keepalived-2.2.2/snap/hooks/install
keepalived-2.2.2/INSTALL
keepalived-2.2.2/doc/
keepalived-2.2.2/doc/Makefile.in
keepalived-2.2.2/doc/man/
keepalived-2.2.2/doc/man/man8/
........

# 打包keepalived文件或者目录,打包后名称keepalived-2.2.2.tar;
[root@superman-vm01 ~]# tar -cvf keepalived-2.2.2.tar keepalived-2.2.2
keepalived-2.2.2/
keepalived-2.2.2/tools/
keepalived-2.2.2/tools/timed_reload
keepalived-2.2.2/Makefile.in
keepalived-2.2.2/build-aux/
keepalived-2.2.2/build-aux/install-sh
keepalived-2.2.2/build-aux/missing
keepalived-2.2.2/build-aux/compile
keepalived-2.2.2/build-aux/depcomp
keepalived-2.2.2/build-aux/ar-lib
keepalived-2.2.2/bin_install/
keepalived-2.2.2/bin_install/Makefile.in
keepalived-2.2.2/bin_install/Makefile.am
keepalived-2.2.2/keepalived.spec.in
keepalived-2.2.2/snap/
keepalived-2.2.2/snap/snapcraft.yaml
keepalived-2.2.2/snap/hooks/
keepalived-2.2.2/snap/hooks/post-refresh
keepalived-2.2.2/snap/hooks/install
keepalived-2.2.2/INSTALL
keepalived-2.2.2/doc/
keepalived-2.2.2/doc/Makefile.in
keepalived-2.2.2/doc/man/
keepalived-2.2.2/doc/man/man8/
........

# 将a.txt文件追加到keepalived-2.2.2.tar中;
[root@superman-vm01 ~]# tar -rf keepalived-2.2.2.tar abc.txt
[root@superman-vm01 ~]# 
[root@superman-vm01 ~]# tar tf keepalived-2.2.2.tar | grep abc.txt 
abc.txt
[root@superman-vm01 ~]#

# 使用gzip格式打包并压缩keepalived-2.2.2目录;
[root@superman-vm01 ~]# tar -czvf keepalived-2.2.2.tar.gz keepalived-2.2.2
keepalived-2.2.2/
keepalived-2.2.2/tools/
keepalived-2.2.2/tools/timed_reload
keepalived-2.2.2/Makefile.in
keepalived-2.2.2/build-aux/
keepalived-2.2.2/build-aux/install-sh
keepalived-2.2.2/build-aux/missing
keepalived-2.2.2/build-aux/compile
keepalived-2.2.2/build-aux/depcomp
keepalived-2.2.2/build-aux/ar-lib
keepalived-2.2.2/bin_install/
keepalived-2.2.2/bin_install/Makefile.in
keepalived-2.2.2/bin_install/Makefile.am
keepalived-2.2.2/keepalived.spec.in
keepalived-2.2.2/snap/
keepalived-2.2.2/snap/snapcraft.yaml
keepalived-2.2.2/snap/hooks/
keepalived-2.2.2/snap/hooks/post-refresh
keepalived-2.2.2/snap/hooks/install
.........

# 使用bzip2格式打包并压缩superman目录;
[root@superman-vm01 ~]# tar -cjvf keepalived-2.2.2.tar.bz2 keepalived-2.2.2
keepalived-2.2.2/
keepalived-2.2.2/tools/
keepalived-2.2.2/tools/timed_reload
keepalived-2.2.2/Makefile.in
keepalived-2.2.2/build-aux/
keepalived-2.2.2/build-aux/install-sh
keepalived-2.2.2/build-aux/missing
keepalived-2.2.2/build-aux/compile
keepalived-2.2.2/build-aux/depcomp
keepalived-2.2.2/build-aux/ar-lib
keepalived-2.2.2/bin_install/
keepalived-2.2.2/bin_install/Makefile.in
keepalived-2.2.2/bin_install/Makefile.am
keepalived-2.2.2/keepalived.spec.in
keepalived-2.2.2/snap/
keepalived-2.2.2/snap/snapcraft.yaml
keepalived-2.2.2/snap/hooks/
keepalived-2.2.2/snap/hooks/post-refresh
keepalived-2.2.2/snap/hooks/install
..........

# 使用gzip格式打包并压缩当前目录所有文件,排除abc.txt中记录的文件;
[root@superman-vm01 ceshi]# ls
abc.txt  keepalived-2.2.2
[root@superman-vm01 ceshi]# 
[root@superman-vm01 ceshi]# tar -czf keepalived-2.2.2.tar.gz * -X abc.txt
[root@superman-vm01 ceshi]# 
[root@superman-vm01 ceshi]# tar tf keepalived-2.2.2.tar.gz | grep abc.txt
abc.txt
[root@superman-vm01 ceshi]# 

# 使用gzip格式打包并压当前目录所有文件及目录,排除abc.txt。 
[root@superman-vm01 ceshi]# ls
abc.txt  keepalived-2.2.2
[root@superman-vm01 ceshi]# 
[root@superman-vm01 ceshi]# tar -czf keepalived-2.2.2.tar.gz * --exclude=abc.txt
[root@superman-vm01 ceshi]# 
[root@superman-vm01 ceshi]# tar tf keepalived-2.2.2.tar.gz | grep abc.txt
[root@superman-vm01 ceshi]# 

3 源码包软件安装

通常使用RPM工具管理.rpm结尾的二进制包,而标准的.zip、tar结尾的源代码包则不能使用RPM工具去安装、卸载及升级,源码包安装有三个步骤,如下:

    ./configure       预编译,主要用于检测系统基准环境库是否满足,生成MakeFile文件;
    make              编译,基于第一步生成的makefile文件,进行源代码的编译;
    make install      安装,编译完毕之后,将相关的可运行文件安装至系统中;
使用make编译时,Linux操作系统必须有GCC编译器,用于编译源码。

源码包安装通常需要./configure、make、make install三个步骤,某些特殊源码可以只有三步中的其中一个步骤,或者两个步骤。

3.1 源码安装实战

以CentOS 7 Linux系统为基准,在其上安装Nginx源码包,企业中源码安装的详细步骤如下:

1、nginx.org官网下载nginx-1.19.9.tar.gz包
[root@superman-vm01 ~]# wget http://nginx.org/download/nginx-1.19.9.tar.gz
--2021-07-10 07:43:34--  http://nginx.org/download/nginx-1.19.9.tar.gz
Resolving nginx.org (nginx.org)... 52.58.199.22, 3.125.197.172, 2a05:d014:edb:5702::6, ...
Connecting to nginx.org (nginx.org)|52.58.199.22|:80... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying.

--2021-07-10 07:43:35--  (try: 2)  http://nginx.org/download/nginx-1.19.9.tar.gz
Connecting to nginx.org (nginx.org)|52.58.199.22|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 887908 (867K) [application/octet-stream]
Saving to: ‘nginx-1.19.9.tar.gz’

57% [=====================>                 ] 507,913     --.-K/s   in 16m 50s 

2021-07-10 08:00:26 (503 B/s) - Read error at byte 507913/887908 (Connection timed out). Retrying.

--2021-07-10 08:00:28--  (try: 3)  http://nginx.org/download/nginx-1.19.9.tar.gz
Connecting to nginx.org (nginx.org)|52.58.199.22|:80... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 887908 (867K), 379995 (371K) remaining [application/octet-stream]
Saving to: ‘nginx-1.19.9.tar.gz’

100%[++++++++++++++++++++++================>] 887,908     6.46KB/s   in 52s    

2021-07-10 08:01:20 (7.11 KB/s) - ‘nginx-1.19.9.tar.gz’ saved [887908/887908]

[root@superman-vm01 ~]# 

2、Nginx源码包解压
[root@superman-vm01 ~]# tar -xvf nginx-1.19.9.tar.gz  
nginx-1.19.9/
nginx-1.19.9/auto/
nginx-1.19.9/conf/
nginx-1.19.9/contrib/
nginx-1.19.9/src/
nginx-1.19.9/configure
nginx-1.19.9/LICENSE
nginx-1.19.9/README
nginx-1.19.9/html/
nginx-1.19.9/man/
nginx-1.19.9/CHANGES.ru
nginx-1.19.9/CHANGES
nginx-1.19.9/man/nginx.8
nginx-1.19.9/html/50x.html
nginx-1.19.9/html/index.html
nginx-1.19.9/src/core/
..........

3、源码Configure预编译,需进入解压后的目录执行./configure指令,分号“;”表示连接多个命令。
[root@superman-vm01 ~]# cd nginx-1.19.9/;./configure
checking for OS
 + Linux 3.10.0-957.el7.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
...........

5、make install安装
[root@superman-vm01 nginx-1.19.9]# make install
make -f objs/Makefile install
make[1]: Entering directory `/root/nginx-1.19.9'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin'                 || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx'                 || mv '/usr/local/nginx/sbin/nginx'                     '/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf'                 || mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types'              || cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params'          || cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params          '/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf'            || cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params'            || cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params            '/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params'             || cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params             '/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf'              || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs'                 || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' ||              mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html'                 || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' ||              mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/root/nginx-1.19.9'
[root@superman-vm01 nginx-1.19.9]#  

通过以上五个步骤,源码包软件安装成功,源码包在编译及安装时,可能会遇到各种错误,需要把错误解决之后,然后再进行下一步安装即可,后面章节会重点针对企业使用的软件进行案例演练。

4 YUM软件包管理

前端软件包管理器(Yellow Updater Modified,YUM)适用于CentOS、Fedora、RedHat及SUSE中的Shell命令行,主要用于管理RPM包,于RPM工具使用范围类似,YUM工具能够从指定的服务器自动下载RPM包并且安装,还可以自动处理依赖性关系。

使用RPM工具管理和安装软件时,会发现rpm包有依赖,需要逐个手动下载安装,而YUM工具的最大便利就是可以自动安装所有依赖的软件包,从而提升效率,节省时间。

4.1 YUM工作原理

学习YUM,一定要理解YUM工作原理,YUM正常运行,需要依赖两个部分,一是YUM源端,二是YUM客户端,也即用户使用端。

YUM客户端安装的所有RPM包都是来自YUM服务端,YUM源端通过HTTP或者FTP服务器发布。而YUM客户端能够从YUM源端下载依赖的RPM包是由于在YUM源端生成了RPM包的基准信息,包括RPM包版本号、配置文件、二进制信息、依赖关系等。

YUM客户端需要安装软件或者搜索软件,会查找/etc/yum.repos.d下以.repo结尾文件,CentOS Linux默认的.repo文件名为CentOS-Base.repo,该文件中配置了YUM源端的镜像地址,所以每次安装、升级RPM包,YUM客户端均会查找.repo文件。

YUM客户端如果配置了CentOS官方repo源,客户端操作系统必须能联外网,满足网络条件,才能下载软件并安装,如果没有网络,也可以构建光盘源或者内部YUM源。在只要YUM客户端时,YUM客户端安装软件,默认会把YUM源地址、Header信息、软件包、数据库信息、缓存文件存储在/var/cache/yum中,每次使用YUM工具,YUM优先通过Cache查找相关软件包,Cache中不存在,然后在访问外网YUM源。

4.2 YUM参数详解

由于YUM工具的使用简便、快捷、高效,在企业中得到广泛的使用,得到众多IT运维、程序人员的青睐,要能熟练使用YUM工具,需要先掌握YUM命令行参数的使用,如下为YUM命令工具的参数详解及实战步骤:

YUM命令工具指南,YUM格式为:
YUM [command] [package] -y|-q 其中的[options]是可选。-y安装或者卸载出现YES时,自动确认yes;-q不显示安装的过程。
yum install sysstat                     安装sysstat软件包;
yum reinstall sysstat                   重新安装sysstat软件包
yum search sysstat                        YUM搜索软件包;
yum list sysstat                           显示指定程序包安装情况sysstat;
yum list                                  显示所有已安装及可安装的软件包;
yum remove sysstat                         删除程序包sysstat;
yum erase sysstat                         删除程序包sysstat;
yum update                                  内核升级或者软件更新;
yum update sysstat                         更新sysstat软件;
yum check-update                         检查可更新的程序;
yum info sysstat                           显示安装包信息sysstat;
yum provides                             列出软件包提供哪些文件;
yum provides "*/rz"                     列出rz命令由哪个软件包提供;
yum grouplist                           询可以用groupinstall安装的组名称;
yum groupinstall "Chinese Support"      安装中文支持;
yum groupremove "Chinese Support"          删除程序组Chinese Support;
yum deplist sysstat                     查看程序sysstat依赖情况;
yum clean   packages                     清除缓存目录下的软件包;
yum clean   headers                     清除缓存目录下的headers;
yum clean   all                           清除缓存目录下的软件包及旧的headers。
yum repolist {all|enabled|disabled}     列出所有/已启用/已禁用的yum源
yum list {all|installed|avaliable}      列出所有/已安装/可安装的软件包
4.2.1 YUM安装实战

1、基于CentOS 7 Linux,执行命令yum install sysstat -y,安装sysstat服务

[root@superman-vm01 ~]# yum install sysstat -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile

 * base: mirrors.aliyun.com
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package sysstat.x86_64 0:10.1.5-17.el7 will be updated
    ---> Package sysstat.x86_64 0:10.1.5-19.el7 will be an update
    --> Finished Dependency Resolution

Dependencies Resolved

================================================================================

 Package          Arch            Version                   Repository     Size
================================================================================

Updating:
 sysstat          x86_64          10.1.5-19.el7             base          315 k

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

Upgrade  1 Package

Total size: 315 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Updating   : sysstat-10.1.5-19.el7.x86_64                                 1/2 
  Cleanup    : sysstat-10.1.5-17.el7.x86_64                                 2/2 
  Verifying  : sysstat-10.1.5-19.el7.x86_64                                 1/2 
  Verifying  : sysstat-10.1.5-17.el7.x86_64                                 2/2 

Updated:
  sysstat.x86_64 0:10.1.5-19.el7                                                

Complete!
[root@superman-vm01 ~]# 

2、执行命令yum grouplist,检查groupinstall的软件组名

[root@superman-vm01 ~]# yum grouplist
Loaded plugins: fastestmirror, langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   Basic Web Server
   Virtualization Host
   Server with GUI
   GNOME Desktop
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   Compatibility Libraries
   Console Internet Tools
   Development Tools
   Graphical Administration Tools
   Legacy UNIX Compatibility
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
Done
[root@superman-vm01 ~]# 

3、执行命令yum groupinstall "GNOME Desktop" -y,安装Linux图像界面

[root@superman-vm01 ~]# yum groupinstall "GNOME Desktop" -y
Loaded plugins: fastestmirror, langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.bfsu.edu.cn
Warning: Group core does not have any packages to install.
Warning: Group gnome-desktop does not have any packages to install.
Warning: Group guest-agents does not have any packages to install.
Package gtk2-immodule-xim-2.24.31-1.el7.x86_64 already installed and latest version
Warning: Group guest-desktop-agents does not have any packages to install.
Warning: Group fonts does not have any packages to install.
Warning: Group print-client does not have any packages to install.
Warning: Group desktop-debugging does not have any packages to install.
Warning: Group dial-up does not have any packages to install.
Package gstreamer1-plugins-bad-free-1.10.4-3.el7.x86_64 already installed and latest version
Package gstreamer1-plugins-good-1.10.4-2.el7.x86_64 already installed and latest version
Package gstreamer1-plugins-ugly-free-1.10.4-3.el7.x86_64 already installed and latest version
Warning: Group multimedia does not have any packages to install.
Warning: Group base does not have any packages to install.
Group base does have 1 conditional packages, which may get installed.
Warning: Group internet-browser does not have any packages to install.
Warning: Group x11 does not have any packages to install.
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager-bluetooth.x86_64 1:1.18.8-2.el7_9 will be installed
.........

4、执行命令yum install sysstat php php-devel php-mysql mariadb mariadb-server -y,安装中小企业LAMP架构环境

[root@superman-vm01 ~]# yum install sysstat php php-devel php-mysql mariadb mariadb-server -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
Package sysstat-10.1.5-19.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.68-1.el7 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.68-1.el7 for package: 1:mariadb-5.5.68-1.el7.x86_64
---> Package mariadb-server.x86_64 1:5.5.68-1.el7 will be installed
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.68-1.el7.x86_64
---> Package php.x86_64 0:5.4.16-48.el7 will be installed
--> Processing Dependency: php-common(x86-64) = 5.4.16-48.el7 for package: php-5.4.16-48.el7.x86_64
..........

5、执行命令yum remove ntpdate -y,卸载ntpdate软件包

[root@superman-vm01 ~]# yum remove ntpdate -yLoaded plugins: fastestmirror, langpacksResolving Dependencies--> Running transaction check---> Package ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2 will be erased--> Processing Dependency: ntpdate = 4.2.6p5-29.el7.centos.2 for package: ntp-4.2.6p5-29.el7.centos.2.x86_64--> Running transaction check---> Package ntp.x86_64 0:4.2.6p5-29.el7.centos.2 will be erased--> Processing Dependency: ntp for package: ipa-client-4.6.8-5.el7.centos.6.x86_64--> Running transaction check---> Package ipa-client.x86_64 0:4.6.8-5.el7.centos.6 will be erased--> Finished Dependency ResolutionDependencies Resolved================================================================================ Package         Arch        Version                        Repository     Size================================================================================Removing: ntpdate         x86_64      4.2.6p5-29.el7.centos.2        @base         121 kRemoving for dependencies: ipa-client      x86_64      4.6.8-5.el7.centos.6           @updates      255 k ntp             x86_64      4.2.6p5-29.el7.centos.2        @base         1.4 MTransaction Summary================================================================================Remove  1 Package (+2 Dependent packages)Installed size: 1.7 MDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction  Erasing    : ipa-client-4.6.8-5.el7.centos.6.x86_64                       1/3   Erasing    : ntp-4.2.6p5-29.el7.centos.2.x86_64                           2/3   Erasing    : ntpdate-4.2.6p5-29.el7.centos.2.x86_64                       3/3   Verifying  : ntp-4.2.6p5-29.el7.centos.2.x86_64                           1/3   Verifying  : ntpdate-4.2.6p5-29.el7.centos.2.x86_64                       2/3   Verifying  : ipa-client-4.6.8-5.el7.centos.6.x86_64                       3/3 Removed:  ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2                                      Dependency Removed:  ipa-client.x86_64 0:4.6.8-5.el7.centos.6 ntp.x86_64 0:4.2.6p5-29.el7.centos.2Complete![root@superman-vm01 ~]# 

6、执行命令yum provides rz或者yum provides "*/rz",查找rz命令的提供者

[root@superman-vm01 ~]# yum provides rzLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.bfsu.edu.cn * extras: mirrors.bfsu.edu.cn * updates: mirrors.bfsu.edu.cnextras/7/x86_64/filelists_db                             | 235 kB     00:00     updates/7/x86_64/filelists_db                            | 5.1 MB     00:04     lrzsz-0.12.20-36.el7.x86_64 : The lrz and lsz modem communications programsRepo        : baseMatched from:Filename    : /usr/bin/rzlrzsz-0.12.20-36.el7.x86_64 : The lrz and lsz modem communications programsRepo        : @anacondaMatched from:Filename    : /usr/bin/rz[root@superman-vm01 ~]# [root@superman-vm01 ~]# yum provides "*/rz"Loaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.huaweicloud.com * extras: mirrors.huaweicloud.com * updates: mirrors.huaweicloud.comlrzsz-0.12.20-36.el7.x86_64 : The lrz and lsz modem communications programsRepo        : baseMatched from:Filename    : /usr/bin/rzlrzsz-0.12.20-36.el7.x86_64 : The lrz and lsz modem communications programsRepo        : @anacondaMatched from:Filename    : /usr/bin/rz[root@superman-vm01 ~]# 

7、执行命令yum update -y,升级Linux所有可更新的软件包或Linux内核升级

[root@superman-vm01 ~]# yum update -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package GeoIP.x86_64 0:1.5.0-13.el7 will be updated
---> Package GeoIP.x86_64 0:1.5.0-14.el7 will be an update
--> Processing Dependency: geoipupdate for package: GeoIP-1.5.0-14.el7.x86_64
---> Package ModemManager.x86_64 0:1.6.10-1.el7 will be updated
---> Package ModemManager.x86_64 0:1.6.10-4.el7 will be an update
---> Package ModemManager-glib.x86_64 0:1.6.10-1.el7 will be updated
---> Package ModemManager-glib.x86_64 0:1.6.10-4.el7 will be an update
---> Package PackageKit.x86_64 0:1.1.10-1.el7.centos will be updated
---> Package PackageKit.x86_64 0:1.1.10-2.el7.centos will be an update
...........

4.3 配置网络源

# 安装163的yum源:
[root@superman-vm01 ~]# wget -O /etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
--2021-07-10 17:07:57--  http://mirrors.163.com/.help/CentOS7-Base-163.repo
Resolving mirrors.163.com (mirrors.163.com)... 1.193.221.38, 124.116.156.215, 124.116.156.214, ...
Connecting to mirrors.163.com (mirrors.163.com)|1.193.221.38|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1572 (1.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS7-Base-163.repo’

100%[======================================>] 1,572       --.-K/s   in 0s      

2021-07-10 17:07:57 (76.7 MB/s) - ‘/etc/yum.repos.d/CentOS7-Base-163.repo’ saved [1572/1572]

[root@superman-vm01 ~]# 

# 安装阿里云的yum源:
[root@superman-vm01 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2021-07-10 17:08:52--  http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 1.180.14.242, 1.180.14.241, 1.180.14.248, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|1.180.14.242|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

100%[======================================>] 2,523       --.-K/s   in 0s      

2021-07-10 17:08:52 (384 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]

[root@superman-vm01 ~]# 
# 搜狐没有现成的yum源文件下载,需要自己配置:
[root@superman-vm01 ~]# echo "[sohu]
name=Centos-$releasever-sohu
baseurl=http://mirrors.sohu.com/centos/$releasever/os/$basearch
gpgcheck=1
gpgkey=http://mirrors.sohu.com/centos/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-$releasever" > /etc/yum.repos.d/CentOS-souhu.repo
[root@superman-vm01 ~]# 
[root@superman-vm01 ~]# 
[root@superman-vm01 ~]# 
[root@superman-vm01 ~]# yum makecache
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile

4.4 配置本地源

[root@superman-vm01 ~]# mkdir /mnt/cdrom
[root@superman-vm01 ~]# mount /dev/cdrom /mnt/cdrom
echo "[local]
name=centos-$releasever-local
baseurl=file:///mnt/cdrom
gpgcheck=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7" > /etc/yum.repos.d/centos-7-local.repomount: /dev/sr0 is write-protected, mounting read-only
[root@superman-vm01 ~]# echo "[local]
name=centos-$releasever-local
baseurl=file:///mnt/cdrom
gpgcheck=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7" > /etc/yum.repos.d/centos-7-local.repo
[root@superman-vm01 ~]# 

4.5 自动配置仓库

# 安装yum的扩展包:
[root@superman-vm01 ~]# yum install yum-utils -y         
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                     | 3.6 kB     00:00     
extras                                                   | 2.9 kB     00:00     
local                                                    | 3.6 kB     00:00     
updates                                                  | 2.9 kB     00:00  

# 自动配置国内epel仓库:
[root@superman-vm01 ~]# yum-config-manager --add-repo=https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
adding repo from: https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/

[mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_]
name=added from: https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/
enabled=1


[root@superman-vm01 ~]# 

4.6 禁用/启用仓库

# epel 是仓库的id [epel]
[root@superman-vm01 ~]# yum-config-manager --disable epel
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
[root@superman-vm01 ~]# 
[root@superman-vm01 ~]# yum-config-manager --enable epel
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
[root@superman-vm01 ~]# 

# 查看仓库状态:
[root@superman-vm01 ~]# yum repolist all
Loaded plugins: fastestmirror, langpacks
Repository 'sohu' is missing name in configuration, using id
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
repo id                             repo name                         status
C7.0.1406-base/x86_64               CentOS-7.0.1406 - Base            disabled
C7.0.1406-centosplus/x86_64         CentOS-7.0.1406 - CentOSPlus      disabled
C7.0.1406-extras/x86_64             CentOS-7.0.1406 - Extras          disabled
C7.0.1406-fasttrack/x86_64          CentOS-7.0.1406 - Fasttrack       disabled
C7.0.1406-updates/x86_64            CentOS-7.0.1406 - Updates         disabled
C7.1.1503-base/x86_64               CentOS-7.1.1503 - Base            disabled
C7.1.1503-centosplus/x86_64         CentOS-7.1.1503 - CentOSPlus      disabled
C7.1.1503-extras/x86_64             CentOS-7.1.1503 - Extras          disabled
C7.1.1503-fasttrack/x86_64          CentOS-7.1.1503 - Fasttrack       disabled
C7.1.1503-updates/x86_64            CentOS-7.1.1503 - Updates         disabled
C7.2.1511-base/x86_64               CentOS-7.2.1511 - Base            disabled
C7.2.1511-centosplus/x86_64         CentOS-7.2.1511 - CentOSPlus      disabled
C7.2.1511-extras/x86_64             CentOS-7.2.1511 - Extras          disabled
C7.2.1511-fasttrack/x86_64          CentOS-7.2.1511 - Fasttrack       disabled
C7.2.1511-updates/x86_64            CentOS-7.2.1511 - Updates         disabled
C7.3.1611-base/x86_64               CentOS-7.3.1611 - Base            disabled
C7.3.1611-centosplus/x86_64         CentOS-7.3.1611 - CentOSPlus      disabled
C7.3.1611-extras/x86_64             CentOS-7.3.1611 - Extras          disabled
C7.3.1611-fasttrack/x86_64          CentOS-7.3.1611 - Fasttrack       disabled
C7.3.1611-updates/x86_64            CentOS-7.3.1611 - Updates         disabled
C7.4.1708-base/x86_64               CentOS-7.4.1708 - Base            disabled
C7.4.1708-centosplus/x86_64         CentOS-7.4.1708 - CentOSPlus      disabled
C7.4.1708-extras/x86_64             CentOS-7.4.1708 - Extras          disabled
C7.4.1708-fasttrack/x86_64          CentOS-7.4.1708 - Fasttrack       disabled
C7.4.1708-updates/x86_64            CentOS-7.4.1708 - Updates         disabled
C7.5.1804-base/x86_64               CentOS-7.5.1804 - Base            disabled
C7.5.1804-centosplus/x86_64         CentOS-7.5.1804 - CentOSPlus      disabled
C7.5.1804-extras/x86_64             CentOS-7.5.1804 - Extras          disabled
C7.5.1804-fasttrack/x86_64          CentOS-7.5.1804 - Fasttrack       disabled
C7.5.1804-updates/x86_64            CentOS-7.5.1804 - Updates         disabled
C7.6.1810-base/x86_64               CentOS-7.6.1810 - Base            disabled
C7.6.1810-centosplus/x86_64         CentOS-7.6.1810 - CentOSPlus      disabled
C7.6.1810-extras/x86_64             CentOS-7.6.1810 - Extras          disabled
C7.6.1810-fasttrack/x86_64          CentOS-7.6.1810 - Fasttrack       disabled
C7.6.1810-updates/x86_64            CentOS-7.6.1810 - Updates         disabled
C7.7.1908-base/x86_64               CentOS-7.7.1908 - Base            disabled
C7.7.1908-centosplus/x86_64         CentOS-7.7.1908 - CentOSPlus      disabled
C7.7.1908-extras/x86_64             CentOS-7.7.1908 - Extras          disabled
C7.7.1908-fasttrack/x86_64          CentOS-7.7.1908 - Fasttrack       disabled
C7.7.1908-updates/x86_64            CentOS-7.7.1908 - Updates         disabled
C7.8.2003-base/x86_64               CentOS-7.8.2003 - Base            disabled
C7.8.2003-centosplus/x86_64         CentOS-7.8.2003 - CentOSPlus      disabled
C7.8.2003-extras/x86_64             CentOS-7.8.2003 - Extras          disabled
C7.8.2003-fasttrack/x86_64          CentOS-7.8.2003 - Fasttrack       disabled
C7.8.2003-updates/x86_64            CentOS-7.8.2003 - Updates         disabled
base/7/x86_64                       CentOS-7 - Base - mirrors.aliyun. enabled: 0
base-debuginfo/x86_64               CentOS-7 - Debuginfo              disabled
base-source/7                       CentOS-7 - Base Sources           disabled
c7-media                            CentOS-7 - Media                  disabled
centos-kernel/7/x86_64              CentOS LTS Kernels for x86_64     disabled
centos-kernel-experimental/7/x86_64 CentOS Experimental Kernels for x disabled
centosplus/7/x86_64                 CentOS-7 - Plus - mirrors.aliyun. disabled
centosplus-source/7                 CentOS-7 - Plus Sources           disabled
contrib/7/x86_64                    CentOS-7 - Contrib - mirrors.aliy disabled
cr/7/x86_64                         CentOS-7 - cr                     disabled
extras/7/x86_64                     CentOS-7 - Extras - mirrors.aliyu enabled: 0
extras-source/7                     CentOS-7 - Extras Sources         disabled
fasttrack/7/x86_64                  CentOS-7 - fasttrack              disabled
sohu                                sohu                              enabled: 0
updates/7/x86_64                    CentOS-7 - Updates - mirrors.aliy enabled: 0
updates-source/7                    CentOS-7 - Updates Sources        disabled
repolist: 0
[root@superman-vm01 ~]#

5. 同步外网源

在企业实际应用场景中,仅仅靠光盘里面的RPM软件包是不能满足需要,我们可以把外网的YUM源中的所有软件包同步至本地,可以完善本地YUM源的软件包数量及完整性。

5.1 安装reposync工具

[root@superman-vm01 ~]# yum install yum-utils createrepo -y
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_              | 4.7 kB     00:00     
(1/3): mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_/group_g |  96 kB   00:00     
(2/3): mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_/updatei | 1.0 MB   00:04     
(3/3): mirrors.tuna.tsinghua.edu.cn_epel_7_x86_64_/primary | 6.9 MB   00:07 

5.2 同步源

# 创建本地目录:
[root@superman-vm01 ~]# mkdir /data/{centos,epel}
[root@superman-vm01 ~]# 

# 同步yum源:
[root@superman-vm01 ~]# reposync -r base -r updates -p /data/centos/
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
No Presto metadata available for base
389-ds-base-1.3.10.2-6.el7.x86 FAILED                                          
389-ds-base-devel-1.3.10.2-6.e FAILED                                           
(1/10072): 389-ds-base-snmp-1.3.10.2-6.el7.x86_64.rpm      | 178 kB   00:00     
(2/10072): ElectricFence-2.2.2-39.el7.i686.rpm             |  35 kB   00:00     
(3/10072): ElectricFence-2.2.2-39.el7.x86_64.rpm           |  35 kB   00:00     
(4/10072): GConf2-3.2.6-8.el7.i686.rpm                     | 1.0 MB   00:01     
(5/10072): Cython-0.19-5.el7.x86_64.rpm                    | 1.9 MB   00:03     
(6/10072): GConf2-3.2.6-8.el7.x86_64.rpm                   | 1.0 MB   00:01     
(7/10072): GConf2-devel-3.2.6-8.el7.i686.rpm               | 110 kB   00:00     
(8/10072): GConf2-devel-3.2.6-8.el7.x86_64.rpm             | 110 kB   00:00  
.........

# 生成元数据:
[root@superman-vm01 ~]# createrepo /data/centos
[root@superman-vm01 ~]# 

# 结合前面所学制作本地源,如果想让其它服务器使用该源,后面可以结合nginx发布。

欢迎关注我的微信公众号【超哥的IT私房菜】获取更多技术干货!

image-20210707074326947

有什么吐槽或反馈意见,直接告诉我! 我会解决您说的问题,进一步更好的服务您哦!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Linux云计算-05_Linux软件包管理 的相关文章

  • 突发!ITELLYOU要改版了!

    微信公众号 网管小贾 个人博客 www sysadm cc 经常下载Windows系统镜像的老司机中 我敢保证十之八九对 MSDN 我告诉你 这个网站再熟悉不过 可是对于新手小白们来说 这个站TA究竟是个啥 其实 MSDN 我告诉你 是个名
  • 解决火狐首次启动太慢的方法

    众所周知 火狐浏览器有一定的优越性 现在众多的网站都采用了jquery技术 而ie在加载jquery上效果实在太差 尤其是配置稍低的情况下 ie很容易被卡死 这就体现出了火狐的优势 但火狐唯一不足的就是第一次启动的速度非常的慢 下面就是解决
  • 世界芯中国芯RISC-V相关资源及进展

    目录 1 RISC V介绍 RISC V为何会在最近两年迅速崛起 RISC V处理器生态 RISC V商业模式 2 RISC V发展历程 3 RISC V国际协会 4 中国RISC V产业联盟 5 RISC V相关资源 1 指令集规范 2
  • kotlin 之于 java 的差异

    一 变量声名 赋值和访问 kotlin 变量是空安全的 一般要求声明时就赋值 声名变量有两个关键字var和val 其中val相当于 java 的中的final 变量类型可显式给出 也可隐式推断 变量也可分可空类型和非空类型 以下给出几种声名
  • ROS1 ROS2学习

    ROS1 ROS2学习 安装 ROS ROS1 ROS2 命令行界面 ROS2 功能包相关指令 ROS 命令行工具 ROS1 CLI工具 ROS2 CLI工具 ROS 通信核心概念 节点 Node 节点相关的CLI 话题 Topic 编写发
  • Altium Designer 20 常见错误

    记录学习过程中出现的错误及解决方法 1 off grid pin问题和Off grid Net Label问题 Off grid Net Label问题解决 只需要选中出现警告的元件 然后按A再按G即可 或者按Shift Ctrl D也行
  • 【网络通信】TCP网络编程

    TCP网络编程 一 面向连接的TCP流模式 二 server程序 三 client程序 四 相关文章 1 TCP网络编程 2 sockaddr和sockaddr in详解 3 socket编程为什么需要htons ntohl ntohs h
  • huggingfacer QuestionAnswerig问答模型调用方式

    huggingface网站提供了大量深度学习预训练模型及其调用方式 本文主要介绍问答模型调用方式 主要是针对问答结果输出完整上下文的问题 其现象在于问题答案为输入的上下文 而不是答案部分 出现该问题主要原因是transformers版本过低
  • Linux流行的发行版本

    Linux是一种广泛使用的自由开源操作系统 具有高度的可定制性 可靠性和安全性 在Linux世界中 存在着许多流行的发行版本 这些版本针对不同的用户需求和技能水平提供了不同的特性和功能 下面将介绍几个流行的Linux发行版本 一 Ubunt
  • 独家解读丨2019,技术传播去向何方?

    如果您是 Technical writer 关于2019年技术传播的发展一定有独到见解 欢迎拉到文末参加有奖活动 小编说 三年一晃而过 The Content Wrangler 再度重磅发布2019技术传播基准调研报告 今天小编要带大家好好
  • 替换JSONObject某个对象的值

    有时候我们只想替换JSONObject某个对象的值 不想把所有对象的值都列出来 那就用for循环把所有的值重新赋值一遍 再单独给需要赋值的对象重新赋值 JSONObject itemObject new JSONObject sJson S

随机推荐

  • 已解决 Request execution error. endpoint=DefaultEndpoint{ serviceUrl=‘http://localhost:8761/eureka/}

    Requestexecutionerror endpoint DefaultEndpoint serviceUrl http localhost 8761 eureka 注册中心报错 问题原因 可能就是yml文件有一步写错了然后照成报错 报
  • 多线程中如何去保证线程安全

    http www cnblogs com qingche p 5695743 html 一 前言 前段时间看了几个开源项目 发现他们保持线程同步的方式各不相同 有 synchronized NSLock dispatch semaphore
  • 12.29练习总结

    第一题 迷宫 题目描述 给定一个N M 方格的迷宫 迷宫里有 T处障碍 障碍处不可通过 在迷宫中移动有上下左右四种方式 每次只能移动一个方格 数据保证起点上没有障碍 给定起点坐标和终点坐标 每个方格最多经过一次 问有多少种从起点坐标到终点坐
  • [C++]外观模式

    外观模式 Facade Pattern 隐藏系统的复杂性 并向客户端提供了一个客户端可以访问系统的接口 这种类型的设计模式属于结构型模式 它向现有的系统添加一个接口 来隐藏系统的复杂性 这种模式涉及到一个单一的类 该类提供了客户端请求的简化
  • Bridge Champ举办人机对战赛:NFT游戏与传统竞技共生发展编织新格局

    概要 现在 NFT与体育竞技正日益紧密地联系在一起 一些体育项目开始推出与赛事或球队相关的NFT 同时也有部分NFT游戏开始举办电子竞技赛事 这种共生发展正在改变体育竞技的生态 笔者采访了桥牌冠军项目相关负责人 探讨NFT游戏与传统体育竞技
  • Visual Studio 2019 详细安装和使用教程

    简介 此处省略很多字 下载 社区版本下载网址 https visualstudio microsoft com zh hans downloads 选择安装路径 建议为VS2019新建一个专属的文件夹 用于存储安装包 安装信息等 在这里你可
  • 什么是loader?

    什么是loader 我们使用webpack 来处理我们写的js代码 并且webpack 会自动处理js之间的相关依赖 在实际项目中 不仅有js文件 还有css 图片 ES6转ES5 tpyescript转ES5 将less scss转化cs
  • js逆向-国家某智慧教育平台登录参数

    目标网址 aHR0cHM6Ly93d3cuenh4LmVkdS5jbi91Yz9zZHAtYXBwLWlkPWU1NjQ5OTI1LTQ0MWQtNGE1My1iNTI1LTUxYTJmMWM0ZTBhOCZyZWRpcmVjdF91cmk
  • 【C++】语法小课堂 --- auto关键字 & typeid查看实际类型 & 范围for循环 & 空指针nullptr

    文章目录 一 auto关键字 C 11 1 auto的简介 2 auto的使用细则 auto与指针和引用结合起来使用 在同一行定义多个变量 3 auto不能推导的场景 1 auto不能作为函数的参数 2 auto不能直接用来声明数组 4 a
  • NodeMCU项目(一)天气时钟

    weather clock 概述 首先使NodeMCU模块连接WiFi 接入互联网 然后连接阿里的NTP服务器 获取网络授时 向心知天气服务器发送HTTP请求 对返回的天气信息进行解析 获得今天 明天 后天的天气信息 最后通过OLED屏幕显
  • 盘点

    漏洞与信息化进程相伴而生 为加强网络安全防护 避免漏洞所引发的威胁 漏洞管理成为重要IT策略 2021年 因漏洞导致的各类安全事件频发 涉及经济 民生的方方面面 提高安全意识已势在必行 以下为中科三方梳理的2021年十大网络安全漏洞 一起来
  • [vuex] vuex requires a Promise polyfill in this browser.报错

    出现这个错误 我第一眼就知道是ES6新增特征之一promise在IE低版本浏览器不兼容的原因 知道了原理就好解决了 第一步 安装 babel polyfill babel polyfill可以模拟ES6使用的环境 可以使用ES6的所有新方法
  • 作为工具制造者的大型语言模型

    文章目录 摘要 1 简介 2 相关工作 3 LLM as Tool Maker LATM 3 1 制作新工具并重用它们 3 2 用Dispatcher处理流数据 4 实验 4 1 实验设置 4 2 工具制作阶段的有效性 4 3 LATM提高
  • 安装cmake3.18.2,执行sudo ./bootstrap,出现-- Could NOT find OpenSSL, ...的问题

    安装cmake3 18 2 执行sudo bootstrap 出现 Could NOT find OpenSSL 的问题 问题描述 问题解决 引用 问题描述 ms ubuntu Downloads cmake 3 18 2 sudo boo
  • 【经验分享】h3c模拟器HCL安装问题集锦

    转载来源 经验分享 h3c模拟器HCL安装问题集锦 https mp weixin qq com s dzDO7WvnjPJF3M6LipGbaQ 问题一 HCL安装完成后启动失败 提示 当前系统用户名中包含非ASCII字符 解决方案 HC
  • flutterApp隐藏/显示状态栏和底部栏

    import package flutter services dart SystemChrome setEnabledSystemUIOverlays 隐藏状态栏 底部按钮栏 SystemChrome setEnabledSystemUI
  • ORACLE表的在线重定义

    一 在线表重定义的用处 1 修改表或者簇的存储参数 2 在相同schema的表空间之间 可以移动表或簇 注意 如果表的可以停止dml操作 则可以利用alter table move来进行表空间的更改 3 增加 修改或者删除一个或多个表或簇的
  • leetcode-712. 两个字符串的最小ASCII删除和

    712 两个字符串的最小ASCII删除和 题目 给定两个字符串s1 和 s2 返回使两个字符串相等所需删除字符的 ASCII 值的最小和 示例1 输入 s1 sea s2 eat 输出 231 解释 在 sea 中删除 s 并将 s 的值
  • [ vulhub漏洞复现篇 ] Apache APISIX 默认密钥漏洞 CVE-2020-13945

    博主介绍 博主介绍 大家好 我是 PowerShell 很高兴认识大家 主攻领域 渗透领域 数据通信 通讯安全 web安全 面试分析 点赞 评论 收藏 养成习惯 一键三连 欢迎关注 一起学习 一起讨论 一起进步 文末有彩蛋 作者水平有限 欢
  • Linux云计算-05_Linux软件包管理

    本章介绍Linux系统软件的安装 卸载 配置 维护以及如何构建企业本地YUM光盘源及HTTP本地源 1 RPM软件包管理 Linux软件包管理大致可分为二进制包 源码包 使用的工具也各不相同 Linux常见软件包分为两种 分别是源代码包 S