局域网yum源配置(纯内网)

准备工作:

  • yum源安装服务器一台
  • Centos的镜像文件一份

开始配置

1、上传Centos系统镜像文件到yum源安装服务器/home目录下
2、在/mnt目录下创建cdrom目录
3、执行挂载命令

[root@node8 home]# mount -o  loop /home/CentOS-7-x86_64-DVD-1708.iso   /mnt/cdrom

4、备份原有repo文件,新建repo文件

[root@node8 home]# cd /etc/yum.repos.d/
[root@node8 yum.repos.d]# mkdir bak
[root@node8 yum.repos.d]# mv *.repo /etc/yum.repos.d/bak
[root@node8 yum.repos.d]# vi base.repo
# 在base.repo中加入如下内容
[base]
name=CentOS
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0
gpgkey=file:///mnt/cdrom/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@node8 yum.repos.d]# yum clean all

5、安装http服务

[root@node8 yum.repos.d]# yum install -y httpd
[root@node8 yum.repos.d]# systemctl start httpd

6、验证http服务是否启动
在浏览器中输入服务器ip验证


image.png

7、创建软连接

[root@node8 yum.repos.d]# ln -s /mnt/cdrom/ /var/www/html/centos7

测试访问


image.png

8、在同一局域网内其他服务器配置yum源地址

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://192.168.100.88/centos7
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=http://192.168.100.88/centos7
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=http://192.168.100.88/centos7
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=http://192.168.100.88/centos7
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

9、清除缓存

[root@node1 yum.repos.d]# yum clean all

你可能感兴趣的:(局域网yum源配置(纯内网))