RPM命名“RedHat Package Manager”,简称则为RPM。属于Red Hat阵营的,与其并列的则是debian。centos中大部分我们安装都是使用yum install,而debian的Ubuntu中我们大部分使用的就是apt-get了。两大阵营、
优点:RPM会将软件包信息记录在Linux主机的数据库中,/var/lib/rpm 每一个RPM包都是编译好的(二进制安装),方便查询本地安装版本和升级卸载。
缺点:软件信息包安装的环境必须与打包时的环境一致或相当。必须安装了软件的依赖软件,例如docker必须将docker包依赖的包一并安装才能正常使用docker,RPM有属性依赖的问题。
软件名称-版本号-发布次数.适合linux系统.硬件平台.rpm
例如:docker-ce-19.03.12-3.el7.x86_64.rpm
看下当前系统版本 cat /etc/redhat-release centos查看方式
lsb_release -a ubuntu查看方式
-i 表示安装
-v表示查看更详细的安装信息画面
-h以安装信息栏显示安装进度
-U更新软件,若系统中没有这个软件则安装
-F更新系统已安装的某个软件,如果不存在则不会安装
-e卸载。卸载需要注意的是从上层往下卸载,不然卸载可能会出问题,很der (所以不是万不得已就用yum别用rpm)
rpm {-q|–query} [select-options] [query-options] 常用参数说明:
-a:all,列出已经安装在本机的所有软件(Query all instaled packages.)
-p:package,查询一个RPM文件的信息(Query an (uninstalled) package. )
-f:file,由后面接的文件名称找出该文件属于哪狐假虎威已安装的软件(Query package owning file.)
-i:information,列出该软件的详细信息,包含开发商、版本与说明等
-l:list,列出该软件所有的文件与目录所在完整文件名(List file in package)
-c:configuration,列出该软件的所有设置文件(找出在/etc/下面的文件名而已)(List only configuration files)
-d:documentation,列出该软件所有的帮助文档(List only documentation files)
-R:required,列出与该软件有关的依赖软件所含的文件(List capabilities on which this depends.)
YUM通过依赖rpm软件包管理器
当你想安装一个软件 yum install wget 需要访问/etc/yum.repos.d/*.repo 找到配置的源端(包从源端下),从源读取说明文件XXX.xml然后存储xml到本地 /var/cache/yum中通过xml文件知道需要安装的依赖程序包在server的具体位置,然后去server下载这个包就OK了。
对于server端要提前存储包以及rpm数据库文件中程序包之间的依赖关系数据,生成对应的依赖关系和所需文件在本地存放位置的说明文件XXX.xml 存放到 /path/repodata目录供客户端获取。
[base]
name=CentOS-7 - Base - 163.com
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
[base]:代表容器的名字。中括号一定要存在,里面的名称可以随意起,但不能有两个相同的容器名称,否则yum会不知道去哪里找容器相关软件列表清单文件。配置的baseurl路径才是最重要的。
name:只是说明一下这个容器的意义而已,重要性不高。
mirrorlist:列出这个容器可以使用的镜像站点,如果不想使用可以批注掉这一行。
baseurl:这个最重要,因为后面接的就是容器的实际网址。mirrorlist是由yum程序自行去找镜像站点,baseurl则是指定固定的一个容器网址。
enable=1:启动这个容器,默认值也为1。关闭这个容器可以设置enable=0。
gpgcheck=1:指定是否需要查阅RPM文件内的数字证书。
gpgkey:数字证书的公钥文件所在位置,使用默认值即可。
yum -y update 升级所有包,改变软件设置和系统设置,系统版本内核都升级
yum -y upgrade 升级所有包,不改变软件设置和系统设置,系统版本升级,内核不改变
已经上线的用yum -y upgrade 比较稳
全新的用yum -y update 会更好
对应配置路径:/etc/yum.repos.d/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-7 - Base - 163.com
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
关于没有互联网的环境下,如果想安装软件就需要提前下载rpm包进行安装了,以docker为例。
安装详情:https://blog.csdn.net/finalheart/article/details/107741251
这个是debian-Ubuntu下的包管理方式类比yum、跟yum的道理是一样的,本地记录软件信息和源端的对应关系。
apt-get update 命令会扫描每一个软件源服务器,并为该服务器所具有软件包资源建立索引文件,存放在本地的/var/lib/apt/lists/目录中。 使用apt-get执行安装、更新操作时,都将依据这些索引文件,向软件源服务器申请资源。因此,在计算机设备空闲时,经常使用“apt-get update”命令刷新软件源,是一个好的习惯。
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial main
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial main
下面这个配置是Ubuntu阿里云服务器上面的配置
deb/deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial main
仓库-----地址-----发行版本-----软件包分类
deb 档案类型为二进制预编译软件包,一般我们所用的档案类型。
deb-src档案类型为用于编译二进制软件包的源代码。
main: 完全的自由软件。
restricted: 不完全的自由软件。
universe: Ubuntu官方不提供支持与补丁,全靠社区支持。
multiverse:非自由软件,完全不提供支持和补丁。
## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
## or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial main
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial main
## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial-updates main
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial-updates main
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial universe
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial universe
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
# deb http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial multiverse
# deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial multiverse
# deb http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial-updates multiverse
# deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial-updates multiverse
## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ xenial-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security main
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security main
deb http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security universe
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security universe
# deb http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security multiverse
# deb-src http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security multiverse