#在系统中对软件进行管理
#rpm命令是不能解决依赖关系的
#如果需要软件在安装过程中自动解决依赖关系
#需要大家系统软件仓库
##搭建方法##
1.在系统中加载安装系统时使用的安装镜像
mount /isos/rhel-8.0-x86_64-dvd.iso /linux
2.编写软件仓库文件
/etc/yum.repos.d/ ##软件源指向文件配置目录
##在此目录中不能有无法访问的源指向
vim /etc/yum.repos.d/xxxx.repo ##软件仓库指向文件
1 [AppStream] ##仓库名称
2 name=linux AppStream ##描述
3 baseurl=file:///linux/AppStream ##地址
4 gpgcheck=0 ####不检测gpgkey (跳过授权检测—)
5 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release (授权检测)
6 enabled=1 ##开启
7
8 [BaseOS]
9 name=linux BaseOS
10 baseurl=file:///linux/BaseOS
11 gpgcheck=0
12 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
13 enabled=1
5.dnf 软件管理命令
dnf repolist ##列出仓库信息
clean all ##清除系统中已经加载的仓库缓存信息
list all ##列出所有软件
list available ##列出未安装软件
list installed ##列出已安装软件
install ##安装
remove ##卸载
reinstall ##重新安装
search ##搜索
whatprovides ##搜索包含文件的软件包
history ##dnf执行历史
history info ##dnf执行历史详细信息
group list ##列出软件组
group list --installed ##列出已安装软件组
group list --available ##列出未安装软件组
group list --hidden ##列出隐藏软件案组
group install ##安装软件组
group info ##查看软件组信息
[root@westos_student yum.repos.d]# dnf remove linuxqq
[root@westos_student yum.repos.d]# dnf search gcc 搜索软件
[root@westos_student yum.repos.d]# dnf whatprovides /bin/ls 搜索包含文件的软件包
[root@westos_student yum.repos.d]# dnf group list --hidden 列出隐藏软件案组
[root@westos_student yum.repos.d]# dnf group install “Virtualization Client” “Virtualization Hypervisor” “Virtualization Tools”
安装软件组
6.网络软件仓库的搭建
westos_linux: 172.25.254.10
westos_node1: 172.25.254.20
在westos_node1中已经搭建好软件仓库,
在westos_linux中是无法访问的
在企业中,我们维护的系统数量庞大,
当我们需要在每个系统安装软件管理软件时
可以在每个系统中各自搭建软件仓库
但是这样管理软件会浪费大量的资源
如何节省这部分重复的资源
需要把大家都要使用的资源共享到互联网中
这样大家就可以利用网络访问资源,不需要在每一台
主机中独立建立软件资源了。
##搭建方法##
1.利用景象搭建本地软件仓库
2.安装共享软件
#共享方式http:// 超文本传输协议
#提供此协议的软件 Apache
#软件包名称 httpd
#共享位置 /var/www/html/linux
#安装命令 在westos_node1: dnf install httpd -y
3.启用共享软件Apache
# systemctl stop firewalld
# systemctl disable firewalld
# systemctl enable --now httpd
4.建立共享目录
mkdir -p /var/www/html/linux
5.挂在景象到共享目录
# mount /xxxxxxx.iso /var/www/html/linux 当镜像在系统中存在
# mount /dev/cdrom /var/www/html/linux 当使用光驱读取镜像
# vim /etc/rc.d/rc.local 在开机时自动挂在
# mount /isos/rhe /var/www/html/linux
# chmod 755 /etc/rc.d/rc.local +x
6.在远程主机westos_linux中访问资源并书写repo文件
vim /etc/yum.repos.d/linux.repo
1 [AppStream]
2 name=linux AppStream
3 baseurl=http://192.168.31.139/linux/AppStream
4 gpgcheck=0
5 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
6 enabled=1
7
8 [BaseOS]
9 name=linux BaseOS
10 baseurl=http://192.168.31.139/linux/BaseOS
11 gpgcheck=0
12 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
13 enabled=1
6.第三方软件仓库的搭建方法
可以使用dnf命令管理第三方软件
并使第三方软件在网络中共享
##步骤##
1.建立共享目录
# mkdir /var/www/html/software
2.把所有的第三方软件存放到/var/www/html/software中
# /var/www/html/software中只能存在rpm类型的文件,压缩包是不能使用dnf管理的
3.采集第三方软件数据生成repodate目录
# dnf install createrepo -y 安装采集工具
# cd /var/www/html/software 进入到共享目录
# createrepo . 对共享目录中进行扫描生成repodate数据目录
4.在测试主机中指定第三方共享源
# vim /etc/yum.repos.d/linux.repo
[software]
name=software baseurl=http://192.168.31.139/software
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
enabled=1
测试:列出linuxqq