yum怎么使用本地源的
发布网友
发布时间:2022-02-27 07:03
我来回答
共1个回答
热心网友
时间:2022-02-27 08:33
每次用rpm包安装软件是总有依赖包的出现,今天我搭建了本地yum仓库,使用yum从光盘安装软件可以解决包的依赖关系,具体操作如下:
1.挂载光盘镜像
[root@centos ~]# mkdir /mnt/cdrom
[root@centos ~]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@centos ~]# vim /etc/yum.repos.d/CentOS-Media.repo
[c6-media]
name=CentOS-$releasever - Media --仓库名
baseurl=file:///mnt/cdrom --软件包路径
gpgcheck=1 --启用包检查
enabled=1 --启用这个仓库
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-6
2.测试仓库
[root@centos ~]# yum clean all --清除所有包
Loaded plugins: fastestmirror, refresh-packagekit
Cleaning repos: c6-media
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@centos ~]# yum repolist --查找有几个仓库
Loaded plugins: fastestmirror, refresh-packagekit
Determining fastest mirrors
c6-media | 4.0 kB 00:00 ...
c6-media/primary_db | 3.5 MB 00:00 ...
repo id repo name status
c6-media CentOS-6 - Media 4,802
repolist: 4,802
[root@centos ~]#
3.安装软件
[root@centos ~]# yum install gpm --安装软件
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gpm.i686 0:1.20.6-12.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved