拜拜五花肉

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

2、测试环境:

服务器1:44.135.8.19(yum源)

服务器2:44.135.8.1(局域网机器)

系统:centos7.4

 

上传iso镜像到服务器,并挂载iso镜像

mount -t iso9660 CentOS-7-x86_64-Everything-1511.iso /mnt/cdrom/

备份本地repo文件,并创建自己的repo

[root@HikvisionOS yum.repos.d]# mkdir /opt/repobak
[root@HikvisionOS yum.repos.d]# mv /etc/yum.repos.d/* /opt/repobak

创建新的repo

[root@HikvisionOS yum.repos.d]# vi myiso.repo
[c7-media]
name=CentOS-$releasever - Media
#这里的IP根据现场的yum源决定
#baseurl=http://44.135.8.19/centos7
baseurl=file:///mnt/cdrom
gpgcheck=1
#enabled=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

清除缓存并新建缓存

[root@HikvisionOS yum.repos.d]# yum clean all
[root@HikvisionOS yum.repos.d]# yum makecache

OK啦,测试下!

[root@HikvisionOS yum.repos.d]# yum list

安装并启动httpd服务

[root@HikvisionOS yum.repos.d]# yum -y install httpd

[root@HikvisionOS yum.repos.d]# systemctl start httpd.service

建立centos软连接

[root@HikvisionOS var]# ln -s /mnt/cdrom /var/www/html/centos7

浏览器试下http://44.135.8.19/centos7能否打开,如果可以,即已成功

修改repo文件,将baseurl改成以上浏览器打开的地址,见上repo代码,注释一下就好了

重新清除缓存新建缓存

局域网内其他机器也一样,修改一下baseurl即可,yum测试下吧

[root@HikvisionOS yum.repos.d]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 44.135.8.1  netmask 255.255.255.0  broadcast 44.135.8.255
        inet6 fe80::2a6e:d4ff:fe88:c62d  prefixlen 64  scopeid 0x20<link>
        ether 28:6e:d4:88:c6:2d  txqueuelen 1000  (Ethernet)
        RX packets 193899509  bytes 33451794784 (31.1 GiB)
        RX errors 0  dropped 5574671  overruns 0  frame 0
        TX packets 112575924  bytes 42120101103 (39.2 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 225833801  bytes 26370004359 (24.5 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 225833801  bytes 26370004359 (24.5 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@HikvisionOS yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识                                                  源名称                                                         状态
!c7-media                                               CentOS-7 - Media                                               9,007
repolist: 9,007
[root@HikvisionOS yum.repos.d]# cat 
bak/               CentOS-Media.repo  
[root@HikvisionOS yum.repos.d]# cat CentOS-Media.repo 
# CentOS-Media.repo
#
#  This repo can be used with mounted DVD media, verify the mount point for
#  CentOS-7.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c7-media [command]
#  
# or for ONLY the media repo, do this:
#
#  yum --disablerepo=\* --enablerepo=c7-media [command]

[c7-media]
name=CentOS-$releasever - Media
#baseurl=file:///media/CentOS/
#        file:///media/cdrom/
#        file:///media/cdrecorder/
baseurl=http://44.135.8.19/centos7
gpgcheck=1
#enabled=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@HikvisionOS yum.repos.d]# 

PS:也可以用ftp的方式,我这里采用了http方式,本文为备忘记录一下

posted on 2019-03-31 14:18  拜拜五花肉  阅读(9964)  评论(0编辑  收藏  举报