centos7使用http配置yum源服务器

本例使用一台服务器,配置yum源服务器,其它机器可以通过该服务器建立yum源。

三台机器:

yum源服务器:

172.16.22.110

另外两台客户机:

172.16.22.180   centos74.

172.16.23.198   centos7.3

1、上传对应iso镜像,本例中只列举两个,一个centos7.4的镜像,一个centos7.3的镜像;

root@scc[/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服务

扫描二维码关注公众号,回复: 2861125 查看本文章

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

root@myhost1[/etc/yum.repos.d]#cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

配置文件

root@myhost1[/etc/yum.repos.d]#vi file.repo 
[http]
name=http_centos7.3
baseurl=http://172.16.22.110/centos7.3
gpgcheck=0
enabled=1

保存退出。

root@myhost1[/etc/yum.repos.d]#yum clean all
Loaded plugins: fastestmirror
Cleaning repos: http
Cleaning up everything
Cleaning up list of fastest mirrors
root@myhost1[/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
root@myhost1[/etc/yum.repos.d]#

6、在看centos7.4

root@myhost1[/etc/yum.repos.d]#cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
root@myhost1[/etc/yum.repos.d]#cat file.repo 
[http]
name=centos7-Server
baseurl=http://172.16.22.110/centos7.4
enabled=1
gpgcheck=0

root@myhost1[/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
root@myhost1[/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
root@myhost1[/etc/yum.repos.d]#

都没问题。

猜你喜欢

转载自blog.csdn.net/kadwf123/article/details/81635442
今日推荐