yum的全称为Yellow dog Updater,Modified,是一个基于RPM的shell前端包管理器,能够从指定服务器上(一个或者多个)自动下载并安装或更新软件、删除软件。其最大的好处就是能解决依赖关系
一、本地yum源配置
1.虚拟机搭建所需环境
[root@rhel7 Desktop]# mkdir /ios [root@rhel7 Desktop]# mount /dev/cdrom /ios/ mount: /dev/sr0 is write-protected, mounting read-only [root@rhel7 Desktop]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/rhel-root 9754624 2972192 6782432 31% / devtmpfs 926516 0 926516 0% /dev tmpfs 942060 420 941640 1% /dev/shm tmpfs 942060 8996 933064 1% /run tmpfs 942060 0 942060 0% /sys/fs/cgroup /dev/sda1 201388 145464 55924 73% /boot tmpfs 188412 4 188408 1% /run/user/42 tmpfs 188412 8 188404 1% /run/user/0 /dev/sr0 3947824 3947824 0 100% /ios
注意:之所以新建挂载目录是因为yum指令无法识别空格符,因为挂在的镜像名字有空格符。
2.配置yum文件
[root@rhel7 Desktop]# cd /etc/yum.repos.d/ [root@rhel7 yum.repos.d]# ls redhat.repo [root@rhel7 yum.repos.d]# vim rhel.repo [root@rhel7 yum.repos.d]# yum clean all Loaded plugins: langpacks, product-id, search-disabled-repos, subscription- : manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Cleaning repos: rhel7.2 Cleaning up everything [root@rhel7 yum.repos.d]# yum repolist Loaded plugins: langpacks, product-id, search-disabled-repos, subscription- : manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. rhel7.2 | 4.1 kB 00:00 (1/2): rhel7.2/group_gz | 136 kB 00:00 (2/2): rhel7.2/primary_db | 3.6 MB 00:00 repo id repo name status rhel7.2 rhel7.2 4,620 repolist: 4,620
注意:以上的yum源头配置都为临时间配置
3.永久配置yum源
[root@rhel7 Desktop]# vim /etc/rc.d/rc.local [root@rhel7 Desktop]# reboot
真机中配置yum源直接将镜像挂载到挂载目录,重复以上即可。
二、网络yum源的搭建
1.搭建实验所需要环境(真机中搭建)
安装Apache
2.重新搭建本机的yum 源配置
[root@foundation69 ~]# mkdir /var/www/html/rhel7.2 [root@foundation69 ~]# mount /ios/rhel-server-7.2-x86_64-dvd.iso /var/www/html/rhel7.2 mount: /dev/loop0 is write-protected, mounting read-only [root@foundation69 ~]# vim /etc/yum.repos.d/junzi.repo [root@foundation69 ~]# vim /etc/yum.repos.d/rhel7.2.repo [root@foundation69 ~]# vim /etc/rc.d/rc.local [root@foundation69 ~]# systemctl restart httpd
3.制作火墙策略
[root@foundation69 ~]# firewall-cmd --permanent --add-service=http success [root@foundation69 ~]# firewall-cmd --permanent --add-masquerade success
4.客户端作测试
搭建成功 更改客户端yum源配置文件