搭建centos7,8本地epel源本地使用

环境准备

1,vmware上准备好挂载需要的镜像比如6,7,8系统
2,挂载在centos8系统
3,需要用centos7下载epel镜像
4,制作成repodata数据源
5,从centos7远程拷贝到centos8挂载目录

注意:这里不讲解怎么制作base源,原因太过简单,差不多与epel相同

第一步,在centos7操作

yum install epel-release

第二步,大概需要一个小时左右

[root@localhost ~]# reposync -r epel -p /root/

第三步,制作成repodata

[root@localhost ~]# yum -y install createrepo
[root@localhost ~]# createrepo -v /root/epel
[root@localhost ~]# ls
anaconda-ks.cfg  epel
[root@localhost ~]# cd epel/
[root@localhost epel]# ls
Packages  repodata

第四步,拷贝数据到目标服务器上

[root@localhost ~]# scp -rv epel/ 172.31.0.100:/var/www/html/epel/centos7
...
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 17431826984, received 4855652 bytes, in 425.1 seconds
Bytes per second: sent 41005321.5, received 11422.1
debug1: Exit status 0
[root@localhost ~]# 

使用机器验证

centos8下载epel源到本地操作,路径按照自己设置来

[root@localhost ~]# dnf reposync --repoid=epel --download-metadata -p /path

安装httpd并创建目录挂载

[root@localhost ~]# cd /var/www/html/
[root@localhost html]# mkdir centos/{6,7,8} -p
[root@localhost centos]# mount /dev/sr0 /var/www/html/centos/8

[root@localhost centos]# mount /dev/sr1 /var/www/html/centos/7

[root@localhost centos]# mount /dev/sr2 /var/www/html/centos/6

永久挂载

[root@localhost epel]# cat /etc/fstab
/dev/sr0                                /var/www/html/centos/8    iso9660 defaults        0 0
/dev/sr1                                /var/www/html/centos/7    iso9660 defaults        0 0
/dev/sr2                                /var/www/html/centos/6    iso9660 defaults        0 0


使用随便一台没有epel源的机器验证

[root@localhost ~]# cat /etc/yum.repos.d/centos7.repo
[base]
name=base
baseurl=http://www.longxuan.top/centos/7/
gpgcheck=0
enabled=1

[epel]
name=epel
baseurl=http://www.longxuan.top/epel/centos7/epel/
gpgcheck=0
enabled=1

路径设置成了需要域名解析,所有需要机器配置都要设置域名解析,不然不会成功,例如:

[root@localhost ~]# vim /etc/hosts
[root@localhost ~]# cat !*
cat /etc/hosts

# yum
172.31.0.100 www.longxuan.top

win系统也要设置hosts如上

重新yum repolist就会看到上面制作的本地epel源了

[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                                                                     repo name                                                                                 status
!base                                                                                       base                                                                                      0
!epel                                                                                       epel                                                                                      0
repolist: 0
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel
Cleaning up list of fastest mirrors
Other repos take up 46 M of disk space (use --verbose for details)
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
base                                                                                                                                                                 | 3.6 kB  00:00:00     
epel                                                                                                                                                                 | 2.9 kB  00:00:00     
(1/3): epel/primary_db                                                                                                                                               | 6.8 MB  00:00:00     
(2/3): base/group_gz                                                                                                                                                 | 166 kB  00:00:00     
(3/3): base/primary_db                                                                                                                                               | 3.1 MB  00:00:00     
repo id                                                                                     repo name                                                                                 status
base                                                                                        base                                                                                       4,021
epel                                                                                        epel                                                                                      13,584
repolist: 17,605


到此本地搭建完成,不用到外网去epel源了

使用本地的epel源安装一个Nginx试试吧

[root@localhost ~]# yum install -y nginx



从上图看到简直不要太爽,但也有缺点,就是要是epel第三方有更新就不能直接更新

posted @ 2021-04-29 10:40  空白的旋律  阅读(1335)  评论(0编辑  收藏  举报