linux中yum源的搭建

xiaoxiao2025-11-10  4

一.什么是yum

yum:上层软件管理工具,最重要的功能是可以解决软件的依赖性;yum能够投入使用的前提是必须要有yum源头,以及配置源指向文件。

二.配置本地yum源

1.从网络上下载与本机系统版本匹配的iso镜像文件

rhel-server-7.0-x86_64-dvd.iso

2,挂载镜像

把rhel-server-7.0-x86_64-dvd.iso挂载到/mnt以便系统访问镜像文件 mount rhel-server-7.0-x86_64-dvd.iso /mnt(目录里不存在重要文件和目录,可以自己新建目录)

3.配置本机yum源指向

rm -fr /etc/yum.repos.d/* vim /etc/yum.repos.d/yum.repo [Server] name=rhel7.0 baseurl=file:///mnt gpgcheck=0 ##表示不检测gpgkey,gpgkey表示软件的出品logo

4.测试安装软件

yum clean all yum install httpd -y

扩:软件名称识别

[abrt-addon-ccpp]-[2.1.11-19].[el7].[x86_64].rpm ##rpm结尾的适用与redhat操作系统 | | | | | | | | 软件名称 软件版本 软件盛适用系统 64位

三.yum源共享

1.在一台已经连安装好域名源的主机中安装httpd服务 yum install httpd -y 2.开启httpd服务并且关闭防火墙 systemctl stop firewalld systemctl disable firewalld systemctl start httpd systemctl enable httpd

3.建立共享目录,并挂载镜像文件到共享目录上 cd /var/www/html mkdir rhel7.0 umount /mnt (解除之前的挂载) mount rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0

4.测试(前提:虚拟机和真机能够彼此ping通) 在虚拟机浏览器中输入 http://真机ip/rhel7.0 可以看到镜像中的内容 ##真机中配置好的yum源

5.修改真机的yum源指向 vim /etc/yum.repos.d/yum.repo [Server] name=rhel7.0 baseurl=file:///var/www/html/rhel7.0 gpgcheck=0

6.修改虚拟机的yum源地址 rm -fr /etc/yum.repos.d/* vim /etc/yum.repos.d/yum.repo [Server] name=server baseurl=http://ip/rhel7.0 7.开机自动挂载在iso vim /etc/rc.d/rc.local mount /root/Desktop/rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0 chmod +x /etc/rc.d/rc/local

三. yum命令

yum install softwarename -y ##安装软件 yum repolist ##列出设定yum源信息 yum remove softwarename ##卸载软件 yum list all ##列主所有软件的名称 yum list softwarename ##查看软件源中是否有该软件 yum list installd softwarename ##是否安装改软件 yum list available ##列出可以用yum安装的软件名称 yum clean all ##清空yum缓存 yum search softwareinfo ##根据软件信息搜索软件名 yum whatprovides filename ##在yum源中查找包含filename文件的软件包 yum update ##更新软件 yum history ##查看系统软件改变历史 yum reinstall softwarename ##重新安装软件

四.第三方源的搭建

把所有的rpm软件放到一个目录中,这个目录只能存在.rpm 文件 createrepo -v /rpm存放目录 修改本机yum源 [software] name=software baseurl=file:///software gpgcheck=0

五.用rmp命令处理软件

rpm rpm -ivh name.rpm ##安装软件 -v:显示过程 -h指定加密方式为hash rpm -e name ##卸载 rpm -ql name ## 查看软件生成的文件 rpm -qlp name ##查看软件安装后会生成什么文件 rpm -qa ##查看系统中安装的所有软件名称 rpm -qa | grep wps rpm -pq name.rpm ##查询软件包安装后的名字 rpm -ivh name.rpm --force ##强制安装,但是不能忽略依赖性 rpm -ivh name.rpm --nodeps --force ##忽略软件的依赖性并且强制安装 rpm -qi name ## 查看软件的信息

转载请注明原文地址: https://www.6miu.com/read-5039417.html

最新回复(0)