###yum命令仅仅是对软件进行管理,rpm命令才是真正安装软件的,yum的好处是可以解决软件依赖性。
mkdir /iso 建立个目录
mv /home/kiosk/Desktop/*.iso /iso 防止误删除
mkdir /source7.0 /source7.2 挂载点
mount /iso/rhel-server-7.0-x86_64-dvd.iso /source7.0 分别挂载
mount /iso/rhel-server-7.2-x86_64-dvd.iso /source7.2
此处的7.0与7.2是我们真机和虚拟机的版本,例如我重新安装系统之后版本为7.1,所以镜像就得挂载相对应的。
cd /etc/yum.repos.d/ 切换到yum源的路径
mkdir /repobackup 建立目录
mv * /repobackup 只是做一个备份
vim yum.repo
[source7.2]
name=source7.2
baseurl=file:///source7.2
gpgcheck=0
[root@foundation21 ~]# mkdir /iso
[root@foundation21 ~]# mv /home/kiosk/Desktop/*.iso /iso
[root@foundation21 ~]# mkdir /source7.0 /source7.2
[root@foundation21 ~]# mount /iso/rhel-server-7.0-x86_64-dvd.iso /source7.0
mount: /dev/loop0 is write-protected, mounting read-only
[root@foundation21 ~]# mount /iso/rhel-server-7.2-x86_64-dvd.iso /source7.2
mount: /dev/loop1 is write-protected, mounting read-only
[root@foundation21 ~]# cd /etc/yum.repos.d/
[root@foundation21 yum.repos.d]# mkdir /repobackup
[root@foundation21 yum.repos.d]# mv * /repobackup
[root@foundation21 yum.repos.d]# vim yum.repo
[root@foundation21 yum.repos.d]# yum clean all 清空yum缓存
[root@foundation21 yum.repos.d]# cd
[root@foundation21 ~]# yum install dhcp 安装dhcp
安装dhcp成功代表yum源搭建完成:
共享yum源:
1,上个实验在本地yum源配置完成之后安装apache点击打开链接,链接里面有阿帕奇的详细解释:
yum install httpd
systemctl start httpd 打开服务
systemctl enable httpd 永久打开
systemctl stop firewalld 关闭防火墙
systemctl disable firewalld 永久关闭
mkdir /var/www/html/source7.0 /var/www/html/source7.2
执行完如下命令后会挂载成功,但是在系统重启之后就需要重新挂载!
mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/source7.0
mount /iso/rhel-server-7.2-x86_64-dvd.iso /var/www/html/source7.2
编辑如下文件可以实现开机永久性挂载。
vim /etc/rc.d/rc.local
写入:
mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/source7.0
mount /iso/rhel-server-7.2-x86_64-dvd.iso /var/www/html/source7.2
:wq退出保存
chmod +x /etc/rc.d/rc.local 赋予执行权限,必须给权限不然没办法成功共享yum源
在浏览器中输入地址,依次测试连接
http://ip/source7.0
http://172.25.254.78/source7.0,78为主机IP。
http://172.25.254.78/source7.2
rm -fr /etc/yum.repos.d/*
vim /etc/yum.repos.d/yum.repo
[source7.0]
name=source7.0
baseurl=http://172.25.254.78/source7.0
gpgcheck=0
配置文件完成后可以在虚拟机输入yum install dhcp进行下载
[root@foundation21 ~]# df 重启之后可以看到已经挂载完成
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 307974224 17399728 290574496 6% /
devtmpfs 1868044 0 1868044 0% /dev
tmpfs 1881152 88 1881064 1% /dev/shm
tmpfs 1881152 8868 1872284 1% /run
tmpfs 1881152 0 1881152 0% /sys/fs/cgroup
/dev/sda1 505580 149472 356108 30% /boot
/dev/loop0 3654720 3654720 0 100% /var/www/html/source7.0
/dev/loop1 3947824 3947824 0 100% /var/www/html/source7.2
tmpfs 376232 12 376220 1% /run/user/1000