搭建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第三方有更新就不能直接更新


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM