(五)学习笔记:软件管理rpm、dnf软件仓库搭建与管理

1.软链接于硬连接

Linux中的链接文件类似于windows中的快捷方式,但与windows快捷方式不同的是Linux系统中的链接文件分为软链接与硬链接
软连接特点:软连接可以跨文件系统,可以对目录进行链接,源文件删除后,链接文件不可用
——命令格式:ln -s 源文件路径 目标路径
[root@rhel8 ~]# ln -s /etc/passwd /opt/ //创建链接文件
[root@rhel8 ~]# cat /opt/passwd //查看链接文件
硬链接特点:硬连接不可以跨文件系统,不可以对目录进行链接,源文件删除后,链接文件仍然可用
——命令格式:ln 源文件路径 目标路径

注意:创建链接时一定要写目录或文件的绝对路径,哪怕是在当前路径下,也要写绝对路径。

2.使用rpm管理软件包

传统的安装软件包的命令
–——命令格式:rpm 选项 软件名…
——常用选项
-q 查询软件是否安装
-qa 查询指定软件包(配合grep使用)
-ivh 安装软件并显示进度和软件信息
-Uvh 升级安装软件包并显示进度和软件信息
–test 测试安装,并不实际安装
-e 卸载rpm包
–import 导入红帽签名
-ql 可以查看安装项的所有配置文件

2.1.安装软件实例

[root@localhost Packages]# ls |grep nginx
nginx-1.14.1-8.module+el8+2505+fe936cef.x86_64.rpm
nginx-all-modules-1.14.1-8.module+el8+2505+fe936cef.noarch.rpm
nginx-filesystem-1.14.1-8.module+el8+2505+fe936cef.noarch.rpm
nginx-mod-http-image-filter-1.14.1-8.module+el8+2505+fe936cef.x86_64.rpm
nginx-mod-http-perl-1.14.1-8.module+el8+2505+fe936cef.x86_64.rpm
nginx-mod-http-xslt-filter-1.14.1-8.module+el8+2505+fe936cef.x86_64.rpm
nginx-mod-mail-1.14.1-8.module+el8+2505+fe936cef.x86_64.rpm
nginx-mod-stream-1.14.1-8.module+el8+2505+fe936cef.x86_64.rpm
pcp-pmda-nginx-4.3.0-3.el8.x86_64.rpm
[root@localhost Packages]# rpm -ivh nginx-1.14.1-8.module+el8+2505+fe936cef.x86_64.rpm
warning: nginx-1.14.1-8.module+el8+2505+fe936cef.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
	nginx-all-modules = 1:1.14.1-8.module+el8+2505+fe936cef is needed by nginx-1:1.14.1-8.module+el8+2505+fe936cef.x86_64
	nginx-filesystem is needed by nginx-1:1.14.1-8.module+el8+2505+fe936cef.x86_64
	nginx-filesystem = 1:1.14.1-8.module+el8+2505+fe936cef is needed by nginx-1:1.14.1-8.module+el8+2505+fe936cef.x86_64
[root@localhost Packages]# ls |grep sac
sac-1.3-28.el8.noarch.rpm
[root@localhost Packages]# rpm -ivh nginx*
warning: nginx-1.14.1-8.module+el8+2505+fe936cef.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:nginx-filesystem-1:1.14.1-8.modul################################# [ 13%]
   2:nginx-mod-http-image-filter-1:1.1################################# [ 25%]
   3:nginx-mod-http-perl-1:1.14.1-8.mo################################# [ 38%]
   4:nginx-mod-http-xslt-filter-1:1.14################################# [ 50%]
   5:nginx-mod-mail-1:1.14.1-8.module+################################# [ 63%]
   6:nginx-all-modules-1:1.14.1-8.modu################################# [ 75%]
   7:nginx-1:1.14.1-8.module+el8+2505+################################# [ 88%]
   8:nginx-mod-stream-1:1.14.1-8.modul################################# [100%]

安装nginx,由于单独安装其中一项会有其它依赖,所以使用rpm -ivh nginx*,这样可以将同名文件都安装。

[root@localhost Packages]# rpm -e nginx
error: Failed dependencies:
	nginx is needed by (installed) nginx-mod-http-image-filter-1:1.14.1-8.module+el8+2505+fe936cef.x86_64
	nginx is needed by (installed) nginx-mod-http-perl-1:1.14.1-8.module+el8+2505+fe936cef.x86_64
	nginx is needed by (installed) nginx-mod-http-xslt-filter-1:1.14.1-8.module+el8+2505+fe936cef.x86_64
	nginx is needed by (installed) nginx-mod-mail-1:1.14.1-8.module+el8+2505+fe936cef.x86_64
	nginx is needed by (installed) nginx-mod-stream-1:1.14.1-8.module+el8+2505+fe936cef.x86_64

这时可以使用yum卸载nginx

[root@localhost Packages]# yum remove -y nginx

yum的使用方法和dnf一致。

2.2.卸载安装实例

若nginxA依赖nginxB,nginxB依赖nginxC则安装的时候按照CBA的顺序,卸载的时候按照ABC的顺序,单独卸载B或C会出错。

3.使用dnf管理软件包

3.1.dnf仓库

dnf(软件仓库):集中提供软件安装包,并提供依赖关系支持
RHEL8中默认使用的软件批量管理工具由RHEL7版本的yum换成了速度更快的dnf,原有的yum命令仅为dnf的软链接,当然依旧可以使用的。
dnf源文件所在目录依旧为/etc/yum.repos.d/
[root@rhel8 rhel8]# vim /etc/yum.repos.d/rhel8.repo //仓库名字以 .repo结尾
[rhel8] //仓库标识
name=rhel8 //仓库名字
baseurl=file:///mnt/rhel8/AppStream //软件存放路径
enabled=1 //开机自启动
gpgcheck=0 //不检测红帽签名

3.2.dnf的常用选项

常用选项
dnf repolist //列出可用软件
dnf list 软件名 //搜索指定软件
dnf list installed //列出所有安装的RPM软件
dnf install 软件名 //安装软件
dnf clean all //清除仓库缓存
dnf update 软件名 //升级软件
dnf remove 软件名 //卸载软件
列出nginx可用软件

[root@localhost yum.repos.d]# dnf list|grep nginx
Cannot find a valid baseurl for repo: rhel8, ignoring this repo.
nginx.x86_64                                           1:1.14.1-9.module_el8.0.0+184+e34fea82               @AppStream
nginx-all-modules.noarch                               1:1.14.1-9.module_el8.0.0+184+e34fea82               @AppStream
nginx-filesystem.noarch                                1:1.14.1-9.module_el8.0.0+184+e34fea82               @AppStream
nginx-mod-http-image-filter.x86_64                     1:1.14.1-9.module_el8.0.0+184+e34fea82               @AppStream
nginx-mod-http-perl.x86_64                             1:1.14.1-9.module_el8.0.0+184+e34fea82               @AppStream
nginx-mod-http-xslt-filter.x86_64                      1:1.14.1-9.module_el8.0.0+184+e34fea82               @AppStream
nginx-mod-mail.x86_64                                  1:1.14.1-9.module_el8.0.0+184+e34fea82               @AppStream
nginx-mod-stream.x86_64                                1:1.14.1-9.module_el8.0.0+184+e34fea82               @AppStream
collectd-nginx.x86_64                                  5.9.0-5.el8                                          epel      
munin-nginx.noarch                                     2.0.65-2.el8                                         epel      
pagure-web-nginx.noarch                                5.12-2.el8                                           epel      
pcp-pmda-nginx.x86_64                                  5.1.1-3.el8                                          AppStream 
python3-certbot-nginx.noarch                           1.10.1-1.el8                                         epel      
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值