Linux軟件包管理之2——yum在線命令

Linux軟件包管理

  1. rpm命令管理 https://blog.csdn.net/jiduochou963/article/details/86619233
  2. yum在線命令 https://blog.csdn.net/jiduochou963/article/details/86653645
  3. 源碼包管理 https://blog.csdn.net/jiduochou963/article/details/86653703
  4. 腳本安裝包 https://blog.csdn.net/jiduochou963/article/details/86655625

2、 yum在線命令

RPM缺點:php

  • 安裝過程當中,rpm包依賴性太強
  • 若是全部rpm包都是手工安裝,則rpm包使用難度較大,一些狀況下甚至比源碼包還要複雜。

注意:yum不支持查詢,查詢方法仍然依賴RPM包查詢命令java

yum在線安裝

  • 好處:將全部軟件包放到官方服務器上,當進行yum在線安裝時,能夠自動解決依賴性問題。
  • Redhat的yum在線安裝須要付費。

yum源文件

  • vim /etc/yum.repos.d/CentOS-Base.repo
[root@localhost Packages]# ls -al /etc/yum.repos.d/
總用量 44
drwxr-xr-x.   2 root root  187 4月  13 2018 .
drwxr-xr-x. 141 root root 8192 1月  24 09:45 ..
# 基本yum源文件,默認生效,另外幾個是默認不生效的
-rw-r--r--.   1 root root 1664 4月  29 2018 CentOS-Base.repo
-rw-r--r--.   1 root root 1309 4月  29 2018 CentOS-CR.repo
-rw-r--r--.   1 root root  649 4月  29 2018 CentOS-Debuginfo.repo
-rw-r--r--.   1 root root  314 4月  29 2018 CentOS-fasttrack.repo
-rw-r--r--.   1 root root  630 4月  29 2018 CentOS-Media.repo
-rw-r--r--.   1 root root 1331 4月  29 2018 CentOS-Sources.repo
-rw-r--r--.   1 root root 4768 4月  29 2018 CentOS-Vault.repo
[root@localhost Packages]# 
[root@localhost Packages]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# cat CentOS-Base.repo # 下面的內容 #...表示是我添加的註釋,以區別原來的。
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[root@localhost yum.repos.d]# 

CentOS-Base.repo文件內容中,如下面這幾行爲例介紹:python

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

  • [base] 容器的名稱,必定要放在[]中;簡單來講就是yum源的名字,名稱能夠本身指定。
  • name 容器說明,能夠本身隨便寫;至關於一個註釋
  • mirrorlist 鏡像站點,這個能夠註釋掉
  • baseurl 咱們的yum源服務器的地址。默認是CentOS官方的yum源服務器,是能夠使用的。國內若是網速慢能夠自行改成國內的鏡像。
  • enabled 此容器是否生效,默認生效(爲1)。即若是不寫或寫成enabled=1都是生效,寫成enabled=0就是不生效
  • gpgcheck 數字證書驗證,若是是1是指RPM的數字證書生效,若是是0則不生效。通常開啓,保護系統安全。
  • gpgkey 數字證書的公鑰文件保存位置,不用修改

  • gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    • //是協議後面跟的雙反斜槓,file://文件協議
    • /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7是協議及絕對路徑
  • 本機的數字證書以下:
[root@localhost yum.repos.d]# ls -al /etc/pki//rpm-gpg/ 
總用量 12
drwxr-xr-x.  2 root root  104 1月  23 17:34 .
drwxr-xr-x. 11 root root  131 1月  23 17:38 ..
-rw-r--r--.  1 root root 1690 4月  29 2018 RPM-GPG-KEY-CentOS-7
-rw-r--r--.  1 root root 1004 4月  29 2018 RPM-GPG-KEY-CentOS-Debug-7
-rw-r--r--.  1 root root 1690 4月  29 2018 RPM-GPG-KEY-CentOS-Testing-7
[root@localhost yum.repos.d]# 

光盤(系統鏡像)搭載本地yum源

若是沒有網絡,如何使用yum源?mysql

1. 掛載光盤

掛載步驟和前面同樣:c++

#...創建掛載點
[root@localhost cdrom]# mkdir /mnt/cdrom
#...掛載光盤
[root@localhost cdrom]# mount /dev/sr0 /mnt/cdrom/
mount: /dev/sr0 寫保護,將以只讀方式掛載
[root@localhost cdrom]#
2. 使網絡yum源失效

方法一:web

  • vim /etc/yum.repos.d/CentOS-Base.repo編輯enable=0使容器(yum源)不生效,可是每個yum源都要編輯(修改或者添加enable語句),比較麻煩。

方法二:sql

  • 進入yum源目錄
    • cd /etc/yum.repos.d/
  • 修改yum源文件後綴名,使其失效——達到刪除的效果,使網絡yum源失效
    • mv CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost yum.repos.d]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls -al 
總用量 44
drwxr-xr-x.   2 root root  187 4月  13 2018 .
drwxr-xr-x. 141 root root 8192 1月  24 09:45 ..
-rw-r--r--.   1 root root 1664 4月  29 2018 CentOS-Base.repo
-rw-r--r--.   1 root root 1309 4月  29 2018 CentOS-CR.repo
-rw-r--r--.   1 root root  649 4月  29 2018 CentOS-Debuginfo.repo
-rw-r--r--.   1 root root  314 4月  29 2018 CentOS-fasttrack.repo
-rw-r--r--.   1 root root  630 4月  29 2018 CentOS-Media.repo
-rw-r--r--.   1 root root 1331 4月  29 2018 CentOS-Sources.repo
-rw-r--r--.   1 root root 4768 4月  29 2018 CentOS-Vault.repo
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost yum.repos.d]# ls -al
總用量 44
drwxr-xr-x.   2 root root  191 1月  24 22:10 .
drwxr-xr-x. 141 root root 8192 1月  24 09:45 ..
-rw-r--r--.   1 root root 1664 4月  29 2018 CentOS-Base.repo.bak
-rw-r--r--.   1 root root 1309 4月  29 2018 CentOS-CR.repo
-rw-r--r--.   1 root root  649 4月  29 2018 CentOS-Debuginfo.repo
-rw-r--r--.   1 root root  314 4月  29 2018 CentOS-fasttrack.repo
-rw-r--r--.   1 root root  630 4月  29 2018 CentOS-Media.repo
-rw-r--r--.   1 root root 1331 4月  29 2018 CentOS-Sources.repo
-rw-r--r--.   1 root root 4768 4月  29 2018 CentOS-Vault.repo
[root@localhost yum.repos.d]# 
讓光盤yum源生效
  • vim CentOS-Media.repo
[root@localhost yum.repos.d]# cat CentOS-Media.repo # ...下面的 #...是我本身添加的
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-7. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c7-media [command]
# 
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command]

[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/  #...將地址改成本身的光盤掛載地址,把下面兩個不存在的地址註釋(註釋必定在行首),否則可能會報錯。
        file:///media/cdrom/  
        file:///media/cdrecorder/
gpgcheck=1
enabled=0  #...這裏改成enabled=1,讓yum源配置文件生效
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@localhost yum.repos.d]# vim CentOS-Media.repo
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-7. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c7-media [command]
# 
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command]

[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom/
# file:///media/cdrom/
# file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
:wq
[root@localhost yum.repos.d]# cat CentOS-Media.repo 
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-7. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c7-media [command]
# 
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command]

[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom/
# file:///media/cdrom/
# file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[root@localhost yum.repos.d]# 

驗證:yum list——查看yum源裏有哪些軟件包能夠安裝(下面會詳細介紹)shell

[root@localhost yum.repos.d]# yum list
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
...

...
zziplib.i686                                                                          0.13.62-5.el7                                                      c7-media 
zziplib.x86_64                                                                        0.13.62-5.el7                                                      c7-media 
zziplib-devel.i686                                                                    0.13.62-5.el7                                                      c7-media 
zziplib-devel.x86_64                                                                  0.13.62-5.el7                                                      c7-media 
zziplib-utils.x86_64                                                                  0.13.62-5.el7                                                      c7-media 
[root@localhost yum.repos.d]# 

按列從左到右依次是:[包的名稱]–[版本]–[yum源的名字]數據庫

yum命令

經常使用yum命令

1. 查詢

yum list 查詢全部可用軟件包列表vim

[root@localhost ~]# yum list
...

yum search 關鍵字 搜索服務器上全部和關鍵字相關的包

[root@localhost ~]# yum search httpd
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
======================================================================= N/S matched: httpd =======================================================================
keycloak-httpd-client-install.noarch : Tools to configure Apache HTTPD as Keycloak client
libmicrohttpd-devel.i686 : Development files for libmicrohttpd
libmicrohttpd-devel.x86_64 : Development files for libmicrohttpd
libmicrohttpd-doc.noarch : Documentation for libmicrohttpd
python2-keycloak-httpd-client-install.noarch : Tools to configure Apache HTTPD as Keycloak client
httpd.x86_64 : Apache HTTP Server
httpd-devel.x86_64 : Development interfaces for the Apache HTTP server
httpd-manual.noarch : Documentation for the Apache HTTP server
httpd-tools.x86_64 : Tools for use with the Apache HTTP Server
libmicrohttpd.i686 : Lightweight library for embedding a webserver in applications
libmicrohttpd.x86_64 : Lightweight library for embedding a webserver in applications
mod_auth_mellon.x86_64 : A SAML 2.0 authentication module for the Apache Httpd Server
mod_dav_svn.x86_64 : Apache httpd module for Subversion server

  名稱和簡介匹配 only,使用「search all」試試。
[root@localhost ~]# 
2. 安裝
  • yum -y install 包名
  • 選項:
    • install 安裝
    • -y 自動回答yes
      注意:yum中只寫包名便可。

如1:mysql-connector-odbc-5.2.5-7.el7.x86_64.rpm

[root@localhost ~]# yum search mysql
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
======================================================================= N/S matched: mysql =======================================================================
MySQL-python.x86_64 : An interface to MySQL
akonadi-mysql.x86_64 : Akonadi MySQL backend support
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
dovecot-mysql.x86_64 : MySQL back end for dovecot
freeradius-mysql.x86_64 : MySQL support for freeradius
libdbi-dbd-mysql.x86_64 : MySQL plugin for libdbi
mysql-connector-java.noarch : Official JDBC driver for MySQL
mysql-connector-odbc.x86_64 : ODBC driver for MySQL
pcp-pmda-mysql.x86_64 : Performance Co-Pilot (PCP) metrics for MySQL
perl-DBD-MySQL.x86_64 : A MySQL interface for Perl
php-mysql.x86_64 : A module for PHP applications that use MySQL databases
php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
qt-mysql.i686 : MySQL driver for Qt's SQL classes qt-mysql.x86_64 : MySQL driver for Qt's SQL classes
qt3-MySQL.i686 : MySQL drivers for Qt 3's SQL classes qt3-MySQL.x86_64 : MySQL drivers for Qt 3's SQL classes
qt5-qtbase-mysql.i686 : MySQL driver for Qt5's SQL classes qt5-qtbase-mysql.x86_64 : MySQL driver for Qt5's SQL classes
redland-mysql.x86_64 : MySQL storage support for Redland
rsyslog-mysql.x86_64 : MySQL support for rsyslog
mariadb.x86_64 : A community developed branch of MySQL
mariadb-devel.i686 : Files for development of MariaDB/MySQL applications
mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications
mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients
mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients

  名稱和簡介匹配 only,使用「search all」試試。
[root@localhost ~]# yum -y install mysql-connector-odbc.x86_64 ^C
[root@localhost ~]# rpm -ivh mysql-connector-odbc-5.2.5-7.el7.x86_64.rpm
錯誤:打開 mysql-connector-odbc-5.2.5-7.el7.x86_64.rpm 失敗: 沒有那個文件或目錄
[root@localhost ~]# rpm -ivh /mnt/cdrom/Packages/mysql-connector-odbc-5.2.5-7.el7.x86_64.rpm 
警告:/mnt/cdrom/Packages/mysql-connector-odbc-5.2.5-7.el7.x86_64.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID f4a80eb5: NOKEY
錯誤:依賴檢測失敗:
        libodbc.so.2()(64bit) 被 mysql-connector-odbc-5.2.5-7.el7.x86_64 須要
        libodbcinst.so.2()(64bit) 被 mysql-connector-odbc-5.2.5-7.el7.x86_64 須要
[root@localhost ~]# yum -y install mysql-connector-odbc.x86_64 
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
c7-media                                                                                                                                   | 3.6 kB  00:00:00     
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 mysql-connector-odbc.x86_64.0.5.2.5-7.el7 將被 安裝
--> 正在處理依賴關係 libodbcinst.so.2()(64bit),它被軟件包 mysql-connector-odbc-5.2.5-7.el7.x86_64 須要
--> 正在處理依賴關係 libodbc.so.2()(64bit),它被軟件包 mysql-connector-odbc-5.2.5-7.el7.x86_64 須要
--> 正在檢查事務
---> 軟件包 unixODBC.x86_64.0.2.3.1-11.el7 將被 安裝
--> 解決依賴關係完成

依賴關係解決

==================================================================================================================================================================
 Package                                        架構                             版本                                    源                                  大小
==================================================================================================================================================================
正在安裝:
 mysql-connector-odbc                           x86_64                           5.2.5-7.el7                             c7-media                           142 k
爲依賴而安裝:
 unixODBC                                       x86_64                           2.3.1-11.el7                            c7-media                           413 k

事務概要
==================================================================================================================================================================
安裝  1 軟件包 (+1 依賴軟件包)

總下載量:555 k
安裝大小:1.6 M
Downloading packages:
警告:/mnt/cdrom/Packages/mysql-connector-odbc-5.2.5-7.el7.x86_64.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID f4a80eb5: NOKEY
mysql-connector-odbc-5.2.5-7.el7.x86_64.rpm 的公鑰還沒有安裝
------------------------------------------------------------------------------------------------------------------------------------------------------------------
總計                                                                                                                               11 MB/s | 555 kB  00:00:00     
從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 檢索密鑰
導入 GPG key 0xF4A80EB5:
 用戶ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指紋       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 軟件包     : centos-release-7-5.1804.el7.centos.x86_64 (@anaconda)
 來自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 數據庫已被非 yum 程序修改。
  正在安裝    : unixODBC-2.3.1-11.el7.x86_64                                                                                                                  1/2 
  正在安裝    : mysql-connector-odbc-5.2.5-7.el7.x86_64                                                                                                       2/2 
  驗證中      : mysql-connector-odbc-5.2.5-7.el7.x86_64                                                                                                       1/2 
  驗證中      : unixODBC-2.3.1-11.el7.x86_64                                                                                                                  2/2 

已安裝:
  mysql-connector-odbc.x86_64 0:5.2.5-7.el7                                                                                                                       

做爲依賴被安裝:
  unixODBC.x86_64 0:2.3.1-11.el7                                                                                                                                  

完畢!
[root@localhost ~]# 

如2:yum -y install gcc——C語言編譯器

[root@localhost ~]# yum search gcc
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
======================================================================== N/S matched: gcc ========================================================================
gcc-c++.x86_64 : C++ support for GCC
gcc-gnat.x86_64 : Ada 95 support for GCC
gcc-objc.x86_64 : Objective-C support for GCC
gcc-objc++.x86_64 : Objective-C++ support for GCC
gcc-plugin-devel.x86_64 : Support for compiling GCC plugins
libgcc.i686 : GCC version 4.8 shared support library
libgcc.x86_64 : GCC version 4.8 shared support library
relaxngcc-javadoc.noarch : Javadoc for relaxngcc
compat-gcc-44.x86_64 : Compatibility GNU Compiler Collection
compat-gcc-44-c++.x86_64 : C++ support for compatibility compiler
compat-gcc-44-gfortran.x86_64 : Fortran support for compatibility compiler
gcc.x86_64 : Various compilers (C, C++, Objective-C, Java, ...)
gcc-gfortran.x86_64 : Fortran support
gcc-go.x86_64 : Go support
libgomp.i686 : GCC OpenMP v3.0 shared support library
libgomp.x86_64 : GCC OpenMP v3.0 shared support library
libmudflap.i686 : GCC mudflap shared support library
libmudflap.x86_64 : GCC mudflap shared support library
libmudflap-devel.i686 : GCC mudflap support
libmudflap-devel.x86_64 : GCC mudflap support
libquadmath.i686 : GCC __float128 shared support library
libquadmath.x86_64 : GCC __float128 shared support library
libquadmath-devel.i686 : GCC __float128 support
libquadmath-devel.x86_64 : GCC __float128 support
relaxngcc.noarch : RELAX NG Compiler Compiler

  名稱和簡介匹配 only,使用「search all」試試。
[root@localhost ~]# gcc
bash: gcc: 未找到命令...
[root@localhost ~]# rpm -ivh /mnt/cdrom/Packages/gcc-c++-4.8.5-28.el7.x86_64.rpm 
錯誤:依賴檢測失敗:
        gcc = 4.8.5-28.el7 被 gcc-c++-4.8.5-28.el7.x86_64 須要
        libmpc.so.3()(64bit) 被 gcc-c++-4.8.5-28.el7.x86_64 須要
        libstdc++-devel = 4.8.5-28.el7 被 gcc-c++-4.8.5-28.el7.x86_64 須要
[root@localhost ~]# yum -y install gcc
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 gcc.x86_64.0.4.8.5-28.el7 將被 安裝
--> 正在處理依賴關係 cpp = 4.8.5-28.el7,它被軟件包 gcc-4.8.5-28.el7.x86_64 須要
--> 正在處理依賴關係 glibc-devel >= 2.2.90-12,它被軟件包 gcc-4.8.5-28.el7.x86_64 須要
--> 正在處理依賴關係 libmpc.so.3()(64bit),它被軟件包 gcc-4.8.5-28.el7.x86_64 須要
--> 正在檢查事務
---> 軟件包 cpp.x86_64.0.4.8.5-28.el7 將被 安裝
---> 軟件包 glibc-devel.x86_64.0.2.17-222.el7 將被 安裝
--> 正在處理依賴關係 glibc-headers = 2.17-222.el7,它被軟件包 glibc-devel-2.17-222.el7.x86_64 須要
--> 正在處理依賴關係 glibc-headers,它被軟件包 glibc-devel-2.17-222.el7.x86_64 須要
---> 軟件包 libmpc.x86_64.0.1.0.1-3.el7 將被 安裝
--> 正在檢查事務
---> 軟件包 glibc-headers.x86_64.0.2.17-222.el7 將被 安裝
--> 正在處理依賴關係 kernel-headers >= 2.2.1,它被軟件包 glibc-headers-2.17-222.el7.x86_64 須要
--> 正在處理依賴關係 kernel-headers,它被軟件包 glibc-headers-2.17-222.el7.x86_64 須要
--> 正在檢查事務
---> 軟件包 kernel-headers.x86_64.0.3.10.0-862.el7 將被 安裝
--> 解決依賴關係完成

依賴關係解決

==================================================================================================================================================================
 Package                                   架構                              版本                                       源                                   大小
==================================================================================================================================================================
正在安裝:
 gcc                                       x86_64                            4.8.5-28.el7                               c7-media                             16 M
爲依賴而安裝:
 cpp                                       x86_64                            4.8.5-28.el7                               c7-media                            5.9 M
 glibc-devel                               x86_64                            2.17-222.el7                               c7-media                            1.1 M
 glibc-headers                             x86_64                            2.17-222.el7                               c7-media                            678 k
 kernel-headers                            x86_64                            3.10.0-862.el7                             c7-media                            7.1 M
 libmpc                                    x86_64                            1.0.1-3.el7                                c7-media                             51 k

事務概要
==================================================================================================================================================================
安裝  1 軟件包 (+5 依賴軟件包)

總下載量:31 M
安裝大小:59 M
Downloading packages:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
總計                                                                                                                               41 MB/s |  31 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安裝    : libmpc-1.0.1-3.el7.x86_64                                                                                                                     1/6 
  正在安裝    : cpp-4.8.5-28.el7.x86_64                                                                                                                       2/6 
  正在安裝    : kernel-headers-3.10.0-862.el7.x86_64                                                                                                          3/6 
  正在安裝    : glibc-headers-2.17-222.el7.x86_64                                                                                                             4/6 
  正在安裝    : glibc-devel-2.17-222.el7.x86_64                                                                                                               5/6 
  正在安裝    : gcc-4.8.5-28.el7.x86_64                                                                                                                       6/6 
  驗證中      : gcc-4.8.5-28.el7.x86_64                                                                                                                       1/6 
  驗證中      : cpp-4.8.5-28.el7.x86_64                                                                                                                       2/6 
  驗證中      : glibc-devel-2.17-222.el7.x86_64                                                                                                               3/6 
  驗證中      : kernel-headers-3.10.0-862.el7.x86_64                                                                                                          4/6 
  驗證中      : glibc-headers-2.17-222.el7.x86_64                                                                                                             5/6 
  驗證中      : libmpc-1.0.1-3.el7.x86_64                                                                                                                     6/6 

已安裝:
  gcc.x86_64 0:4.8.5-28.el7                                                                                                                                       

做爲依賴被安裝:
  cpp.x86_64 0:4.8.5-28.el7         glibc-devel.x86_64 0:2.17-222.el7       glibc-headers.x86_64 0:2.17-222.el7       kernel-headers.x86_64 0:3.10.0-862.el7      
  libmpc.x86_64 0:1.0.1-3.el7      

完畢!
[root@localhost ~]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
Copyright © 2015 Free Software Foundation, Inc.
本程序是自由軟件;請參看源代碼的版權聲明。本軟件沒有任何擔保;
包括沒有適銷性和某一專用目的下的適用性擔保。
[root@localhost ~]# yum -y gcc
已加載插件:fastestmirror, langpacks
沒有該命令:gcc。請使用 /usr/bin/yum --help
[root@localhost ~]# yum -y install gcc
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
軟件包 gcc-4.8.5-28.el7.x86_64 已安裝而且是最新版本
無須任何處理
[root@localhost ~]# 
升級
  • yum -y update 包名
  • 選項:
    • update 升級
    • -y 自動回答yes
[root@localhost ~]# yum -y update httpd
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
No packages marked for update
[root@localhost ~]# 

注:除非爆發致命漏洞,不然應該考慮穩定性,不升級儘可能不要升級。
yum -y update是升級Linux中全部的軟件包,包括Linux內核。新的內核啓用須要人爲配置才能啓動,直接升級可能會形成系統崩潰。

卸載
  • yum -y remove 包名
  • 選項:
    • remove 卸載
    • -y 自動回答yes

原則:服務器使用最小化安裝,用什麼軟件安裝什麼,儘可能不卸載。
安裝有依賴性,卸載一樣有依賴性。萬一卸載了所依賴的系統包,致使系統崩潰。

yum軟件組管理命令

  • yum grouplist
    • 列出全部可用的軟件組列表
  • yum groupinstall 軟件組名
    • 安裝指定軟件組,組名能夠由grouplist查詢出來
    • 注意: 軟件組名必須是英文
  • yum groupremove 軟件組名
    • 卸載指定軟件組
[root@localhost ~]# yum grouplist
已加載插件:fastestmirror, langpacks
沒有安裝組信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
可用的環境分組:
   最小安裝
   基礎設施服務器
   計算節點
   文件及打印服務器
   基本網頁服務器
   虛擬化主機
   帶 GUI 的服務器
   GNOME 桌面
   KDE Plasma Workspaces
   開發及生成工做站
可用組:
   傳統 UNIX 兼容性
   兼容性程序庫
   圖形管理工具
   安全性工具
   開發工具
   控制檯互聯網工具
   智能卡支持
   科學記數法支持
   系統管理
   系統管理工具
完成
[root@localhost ~]# 

軟件包名必須是英文;儘管Linux是用中文安裝,但Linux本機是不支持中文的(若是是在Linux本機上操做就是純英文。終端工具中顯示的是安裝時的語言,因此看到的是中文。)
在終端工具中將語系臨時從中文改成英文便可:

[root@localhost ~]# LANG=en_US
[root@localhost ~]# 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
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@localhost ~]# 

安裝指定軟件組

[root@localhost ~]# yum groupinstall "Server with GUI"
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
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
Package imsettings-gsettings-1.6.3-9.el7.x86_64 already installed and latest version
Package ibus-gtk3-1.5.17-2.el7.x86_64 already installed and latest version
Package ibus-gtk2-1.5.17-2.el7.x86_64 already installed and latest version
Package gtk3-immodule-xim-3.22.26-3.el7.x86_64 already installed and latest version
Warning: Group input-methods does not have any packages to install.
Group input-methods does have 2 conditional packages, which may get installed.
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.
Warning: Group hardware-monitoring 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.
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 internet-browser does not have any packages to install.
Warning: Group x11 does not have any packages to install.
Maybe run: yum groups mark install (see man yum)
No packages in any requested group available to install or update
[root@localhost ~]# 

由於已經安裝過GUI,haha。
改回來:LANG=zh_CN.utf8


  1. 源碼包管理 https://blog.csdn.net/jiduochou963/article/details/86653703
相關文章
相關標籤/搜索