本例使用一台伺服器,配置yum源伺服器,其它機器可以通過該伺服器建立yum源。
三台機器:
yum源伺服器:
172.16.22.110
另外兩台客戶機:
172.16.22.180 centos74.
172.16.23.198 centos7.3
1、上傳對應iso鏡像,本例中隻列舉兩個,一個centos7.4的鏡像,一個centos7.3的鏡像;
[email protected][/root]#ll
-rw-r--r--. 1 root root 8694792192 Aug 13 18:59 CentOS-7.4-x86_64-Everything-1708.iso
-rw-r--r--. 1 root root 8280604672 Aug 21 2017 CentOS-7-x86_64-Everything-1611.iso
2、鏡像伺服器安裝http服務
mount -o loop /root/CentOS-7-x86_64-Everything-1611.iso /mnt
vi /etc/yum.repos.d/local.repo
[centos7.3]
name=centos7.3
baseurl=file:///mnt
enabled=1
gpgcheck=0
儲存退出。
yum update
配置了本地yum源。
然後安裝http服務
yum -y install httpd
啟動并添加自啟動
systemctl start httpd
systemctl enable httpd
3、在/var/www/html/目錄下建立對應挂載點
cd /var/www/html
mkdir centos7.3
mkdir centos7.4
4、修改/etc/fstab檔案
添加如下内容:
/root/CentOS-7-x86_64-Everything-1611.iso /var/www/html/centos7.3 iso9660 defaults,ro,loop 0 0
/root/CentOS-7.4-x86_64-Everything-1708.iso /var/www/html/centos7.4 iso9660 defaults,ro,loop 0 0
儲存退出,然後
mount -a
df -Th
/dev/loop0 iso9660 8.1G 8.1G 0 100% /var/www/html/centos7.4
/dev/loop1 iso9660 7.8G 7.8G 0 100% /var/www/html/centos7.3
确認挂載成功。
5、配置客戶機
先看centos7.3
[email protected][/etc/yum.repos.d]#cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
配置檔案
[email protected][/etc/yum.repos.d]#vi file.repo
[http]
name=http_centos7.3
baseurl=http://172.16.22.110/centos7.3
gpgcheck=0
enabled=1
儲存退出。
[email protected][/etc/yum.repos.d]#yum clean all
Loaded plugins: fastestmirror
Cleaning repos: http
Cleaning up everything
Cleaning up list of fastest mirrors
[email protected][/etc/yum.repos.d]#yum makecache
Loaded plugins: fastestmirror
http | 3.6 kB 00:00:00
(1/4): http/group_gz | 155 kB 00:00:00
(2/4): http/filelists_db | 6.6 MB 00:00:00
(3/4): http/primary_db | 5.6 MB 00:00:00
(4/4): http/other_db | 2.4 MB 00:00:00
Determining fastest mirrors
Metadata Cache Created
[email protected][/etc/yum.repos.d]#
6、在看centos7.4
[email protected][/etc/yum.repos.d]#cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[email protected][/etc/yum.repos.d]#cat file.repo
[http]
name=centos7-Server
baseurl=http://172.16.22.110/centos7.4
enabled=1
gpgcheck=0
[email protected][/etc/yum.repos.d]#yum clean all
Loaded plugins: fastestmirror
Cleaning repos: http
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
[email protected][/etc/yum.repos.d]#yum makecache
Loaded plugins: fastestmirror
http | 3.6 kB 00:00:00
(1/4): http/group_gz | 156 kB 00:00:00
(2/4): http/primary_db | 5.7 MB 00:00:00
(3/4): http/filelists_db | 6.7 MB 00:00:00
(4/4): http/other_db | 2.5 MB 00:00:00
Determining fastest mirrors
Metadata Cache Created
[email protected][/etc/yum.repos.d]#
都沒問題。