我们在真实主机中已经搭建好的软件仓库,在另一台主机中是无法访问的。可以搭建网络软件仓库,其他主机也可以访问,下载软件。
具体的网络仓库搭建方法如下:
1 dnf install httpd -y ##安装共享软件:我们需要采用http:// 超文本传输协议这种共享方式来搭建网络仓库
2 systemctl enable --now httpd ##开启httpd服务
4 systemctl disable --now firewalld.service ##关闭真实主机防火墙
5 cd /var/www/html ##共享软件Apache:Apache的共享位置为/var/www/html
7 vim index.html ##在这个目录下编写一个html文件,测试Apache软件是否成功启用
//编写内容
gyugujg
//
如图所示,Apache软件成功启用
10 mkdir rhel8.2 ##在共享位置/var/www/html下建立共享目录 /rhel8.2
13 umount /westos ##卸载(如果之前镜像挂载了的话)
16 mount /iso/rhel-8.2-x86_64-dvd.iso /var/www/html/rhel8.2/ ##设置镜像在开机时自动挂载
17 vim /etc/rc.d/rc.local
//
touch /var/lock/subsys/local
mount /iso/rhel-8.2-x86_64-dvd.iso /var/www/html/rhel8.2/
//
19 chmod +x /etc/rc.d/rc.local ##赋予该文件可执行权限
18 df ##通过df 命令可以看到镜像挂载成功
[westos@westos_student11 html]$ df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 1845580 0 1845580 0% /dev
tmpfs 1874280 41300 1832980 3% /dev/shm
tmpfs 1874280 18340 1855940 1% /run
tmpfs 1874280 0 1874280 0% /sys/fs/cgroup
/dev/sda3 118954244 20676012 98278232 18% /
/dev/sda1 518816 223880 294936 44% /boot
/dev/loop0 8238560 8238560 0 100% /var/www/html/rhe8.2
tmpfs 374856 12 374844 1% /run/user/42
tmpfs 374856 36 374820 1% /run/user/1000
/dev/sdb1 121226624 4652288 116574336 4% /run/media/westos/disk
[westos@westos_student11 html]$ cd /etc/yum.repos.d/
[westos@westos_student11 yum.repos.d]$ ls
redhat.repo westos.repo
修改软件仓库指向文件( . repo文件),更改其软件源地址:对于共享主机,其软件源寻址方式有 file:// 和 http:// 两种;对于远程主机,其软件源寻址方式只有 http:// 这一种。
[westos@westos_student11 yum.repos.d]$ vim westos.repo
23 ##修改软件仓库指向文件(westos . repo文件)
//
[AppStream]
name=AppStream
#baseurl=file:///westos/AppStream
baseurl=http://172.25.254.11/rhel8.2/AppStream
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-KEY-redhat-release
enable=1
[BaseOS]
name=BaseOS
#baseurl=file:///westos/BaseOS
baseurl=http://172.25.254.11/rhel8.2/BaseOS
gpgcheck=0
对于远程主机,可以对其软件仓库指向文件进行修改
[AppStream]
name=AppStream
baseurl=http://172.25.254.77/rhel8.2/AppStream
gpgcheck=0
[BaseOS]
name=BaseOS
baseurl=http://172.25.254.77/rhel8.2/BaseOS
gpgcheck=0