每次用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
========================================================================================================================================================
Package                         Arch                             Version                                    Repository                            Size
========================================================================================================================================================
Installing:
gpm                             i686                             1.20.6-12.el6                              c6-media                             175 k
Transaction Summary
========================================================================================================================================================
Install       1 Package(s)
Total download size: 175 k
Installed size: 373 k
Is this ok [y/N]:y           --确定安装

 

4.常用yum基本命令

yum --help                 --帮助信息

yum list         --列出软件包

yum repolist        --查看有多少仓库

yum info 软件包        --软件包的信息

yum install  软件包         --安装软件包

yum update 软件包      --更新软件包

yum provides 命令       --用命令查找要安装的软件包

yum reinstall 软件包        --覆盖安装软件包

yum remove 软件包      --删除软件

yum clean 软件包    --清除软件包

yum grouplist          --查看软件组

yum groupinstall "软件组"     --安装软件组

yum install info "软件组"    --查看软件组的信息

yum remove “组件组"     --删除软件组

yum   search   软件包    --检测是否有软件包     

yum install * --nogpgcheck     --跳过KEY安装软件包 

            

注:搭建Linux本地源:http://tongcheng.blog.51cto.com/6214144/1338949