软件包管理及yum源环境搭建

软件包管理 及yum源搭建

包管理器rpm

常见选项:

  • -i 安装软件包
  • -v: 提供更多的详细输出
  • -h: 以#显示程序包管理执行进度
    —test: 测试安装,但不真正执行安装,即dry run模式
    –nodeps:忽略依赖关系
    –replacepkgs | replacefiles
    –nosignature: 不检查来源合法性
    –nodigest:不检查包完整性
    –noscripts:不执行程序包脚本

rpm包升级

-U 安装有旧版程序包,则“升级”,如果不存在旧版程序包,则“安装”
-F 安装有旧版程序包,则“升级”, 如果不存在旧版程序包,则不执行升级操作
常见组合:
rpm -Uvh
rpm -Fvh
升级注意项:
(1) 不要对内核做升级操作;Linux支持多内核版本并存,因此直接安装新版本内核
(2) 如果原程序包的配置文件安装后曾被修改,升级时,新版本提供的同一个配置文件不会直接覆盖老版本的配置文件,而把新版本文件重命名(FILENAME.rpmnew)后保留

包查询

rqm -q

  • -a 所有包
    查询选项(用 -q 或 --query):
  • -f:查看指定的文件由哪个程序包安装生成
  • -p rpmfile:针对尚未安装的程序包文件做查询操作
  • -i:information
  • -l:查看指定的程序包安装后生成的所有文件
  • -R:查询指定的程序包所依赖的CAPABILITY
    – scripts 查看脚本

包校验

检查包的完整性和签名
rpm -K
rpm包安装时生成的信息,都放在rpm数据库中
/var/lib/rpm

软件在安装时,会将包里的每个文件的元数据,如:大小,权限,所有者,时间等记录下来,可以用来
检查包中的文件是否和当初安装时有所变化

rpm -V

[root@centos8|26|~]#rpm -Va  显示所有被修改的文件
....L....  c /etc/pam.d/fingerprint-auth
....L....  c /etc/pam.d/password-auth
....L....  c /etc/pam.d/postlogin
....L....  c /etc/pam.d/smartcard-auth
....L....  c /etc/pam.d/system-auth
[root@centos8|26|~]#rpm -V tree 显示安装的软件是否被修改
[root@centos8|26|~]#rpm -Vp 某个RPM文件的文件名
[root@centos8|26|~]#rpm -Vf /etc/crontab 某个文件是否被修改
#显示信息
S 文件大小是否被修改
M 文件属性 rwx
5 MD5内容已经不同
D 设备的主次代码
L 文件路径
U 所属用户
G 所属用户组
T 建立时间
P 文件功能

包卸载

-e 清除 (卸载) 软件包

–allfiles 安装全部文件,包含配置文件,否则配置文件会被跳过。
–allmatches 移除所有符合 的软件包(如果 被指定未多个软件包,常常会导致错误出现)

baseurl指向的路径

阿里云提供了写好的CentOS和ubuntu的仓库文件下载链接
http://mirrors.aliyun.com/repo/

CentOS系统的yum源


#阿里云 https://mirrors.aliyun.com/centos/$releasever/os/x86_64/ 
#清华大学 https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/x86_64/

EPEL的yum源

#阿里云 https://mirrors.aliyun.com/epel/$releasever/x86_64

yum源搭建

yum客户端配置文件
/etc/yum.conf #为所有仓库提供公共配置
/etc/yum.repos.d/*.repo: #为每个仓库的提供配置文件
帮助参考: man 5 yum.conf
[base]代表软件源的名称,中括号一定存在名称可以随便起单不能相同
gpgcheck 是否校验
enable 是否启用
mirrorlist 可以使用的镜像站
gpgkey 公钥位置
baseurl 软件源实际地址

[root@centos8_10:36:55|5|~]#vim /etc/yum.conf
[main]   #代表主要配置
gpgcheck=1  #校验数据包的合法来源=rpm -K 需要导入 
[root@centos8_10:40:29|6|~]#rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial 
installonly_limit=3 #同时可以安装3个包,最小值为2,如设为0或1,为不限制
clean_requirements_on_remove=True #删除包时,是否将不再使用的包删除
best=True #升级时,自动选择安装最新版,即使缺少包的依赖
~           

配置文件

[root@centos7|30|repodata]#cd /etc/yum.repos.d/
[root@centos7|32|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]    //主要的yum源  

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]  //用于升级的yum源

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]	//额外的yum源
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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值