创建光盘挂载点目录
[root@localhost ~]# mkdir /mount
挂载光盘
[root@localhost ~]# mount /dev/cdrom /mount
mount: /dev/sr0 is write-protected, mounting read-only
挂载完毕后 就可以看到光盘内的rpm包 rpm包在挂载路径下的Packages目录
[root@localhost ~]# ls /mount/Packages/
··· ···
zip-3.0-11.el7.x86_64.rpm
zlib-1.2.7-18.el7.x86_64.rpm
zlib-devel-1.2.7-18.el7.x86_64.rpm
zsh-5.0.2-33.el7.x86_64.rpm
zziplib-0.13.62-11.el7.x86_64.rpm
如果不需要挂载光盘了 可以卸载
[root@localhost ~]# umount /mount/
yum的文件默认存在/etc/yum.repos.d/下
centos7自带网络yum 如下所示
[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
如果想要有一个更好的使用本地yum的体验 建议把网络yum隐藏起来 如下操作
注意 不要删除centos7自带的网络yum 后期使用起来非常方便
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir data
[root@localhost yum.repos.d]# mv C* data/
[root@localhost yum.repos.d]# ls
data
编写本地yum文件 yum文件的名字自拟 后缀是.repo 注意 repo文件一定要放在/etc/yum.repos.d/目录下 放在其他地方都不好使
[root@localhost yum.repos.d]# vim vase.repo
[vase]
name=vase
baseurl=file:///mount
enabled=1
gpgcheck=0
参数释义:
[vase] #yum名字
name=vase #可以不写 yum的描述信息
baseurl=file:///mount #仓库地址 file:// 表示从文件系统中寻找后边的路径(可类比http://) 后边写上挂载点即可 我的挂载点目录是/mount 所以两个拼接在一起就是file:///mount
enabled=1 是否启用此yum 1表示启用 0表示不启用
gpgcheck=0 使用此yum时室友验证gpg-key
检测本地yum是否可用 最后一列可以看到自己写的yum的名称
[root@localhost yum.repos.d]# yum list
389-ds-base.x86_64 1.3.9.1-10.el7 vase
389-ds-base-libs.x86_64 1.3.9.1-10.el7 vase
ElectricFence.x86_64 2.2.2-39.el7 vase
GConf2.x86_64 3.2.6-8.el7 vase
GeoIP.x86_64 1.5.0-14.el7 vase
ImageMagick.x86_64 6.7.8.9-18.el7 vase
ImageMagick-c++.x86_64 6.7.8.9-18.el7 vase
ImageMagick-perl.x86_64 6.7.8.9-18.el7 vase
LibRaw.x86_64 0.19.2-1.el7 vase
使用yum安装服务
[root@localhost ~]# yum -y install zsh
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64 0:5.0.2-33.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================
Package Arch Version Repository Size
======================================================================================
Installing:
zsh x86_64 5.0.2-33.el7 vase 2.4 M
Transaction Summary
======================================================================================
Install 1 Package
Total download size: 2.4 M
Installed size: 5.6 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : zsh-5.0.2-33.el7.x86_64 1/1
Verifying : zsh-5.0.2-33.el7.x86_64 1/1
Installed:
zsh.x86_64 0:5.0.2-33.el7
Complete!
-y:自动应答yes
安装:yum -y install zsh
卸载:yum -y remove zsh
更新:yum -y update zsh