三种方式搭建yum源
1、本地搭建yum源:
[root@Nginx1 x86_64]# vim /etc/yum.repos.d/mnt.repo
[root@Nginx1 x86_64]# cd /etc/yum.repos.d/
[root@Nginx1 yum.repos.d]# ll
total 36
-rw-r--r--. 1 root root 1664 Dec 9 2015 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Dec 9 2015 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Dec 9 2015 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 290 Dec 9 2015 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Dec 9 2015 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Dec 9 2015 CentOS-Sources.repo
-rw-r--r--. 1 root root 1952 Dec 9 2015 CentOS-Vault.repo
-rw-r--r-- 1 root root 57 Sep 6 15:23 mnt.repo
-rw-r--r--. 1 root root 100 Jul 14 05:54 Nginx.repo
[root@Nginx1 yum.repos.d]# pwd
/etc/yum.repos.d
[root@Nginx1 yum.repos.d]#cat/etc/yum.repos.d/mnt.repo
[mnt] name=mnt baseurl=file:///mnt gpgcheck=0 enabled=1
[root@Nginx1 yum.repos.d]# mount /dev/cdrom /mnt/
[root@Nginx1 yum.repos.d]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 19G 8.5G 11G 46% /
devtmpfs devtmpfs 947M 0 947M 0% /dev
tmpfs tmpfs 957M 8.2k 957M 1% /dev/shm
tmpfs tmpfs 957M 102M 856M 11% /run
tmpfs tmpfs 957M 0 957M 0% /sys/fs/cgroup
/dev/sda1 xfs 521M 136M 386M 27% /boot
tmpfs tmpfs 192M 17k 192M 1% /run/user/0
/dev/sr0 iso9660 4.4G 4.4G 0 100% /mnt
2、阿里云yum源:
centos6.0:
wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-6.repo
centos7.0:
wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo
[base] name=CentOS-$releasever-Base-mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #releasedupdates [updates] name=CentOS-$releasever-Updates-mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additionalpackagesthatmaybeuseful [extras] name=CentOS-$releasever-Extras-mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additionalpackagesthatextendfunctionalityofexistingpackages [centosplus] name=CentOS-$releasever-Plus-mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib-packagesbyCentosUsers [contrib] name=CentOS-$releasever-Contrib-mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
运行生成缓存:yum makecache
3、搭建yum服务器
createrepo是yum源维护的工具。
在yum server服务器上面:
yum-yinstallcreaterepo
[root@Nginx1yum.repos.d]#yum-yinstallhttpd [root@Nginx1yum.repos.d]#systemctlrestarthttpd [root@Nginx1yum.repos.d]#mkdir-p/var/www/html/centos7.2/x86_64 [root@Nginx1yum.repos.d]#mount/dev/cdrom/mnt/ [root@Nginx1yum.repos.d]#cp-ar/mnt/*/var/www/html/centos7.2/x86_64 [root@Nginx1yum.repos.d]#cd/var/www/html/ [root@Nginx1html]#createrepo-p-d-ocentos7.2/x86_64/centos7.2/x86_64/
在client客户端上面:
[root@host3yum.repos.d]#cattest.repo [test] name=test baseurl=http://172.25.254.130/centos7.2/x86_64 gpgcheck=0 [root@host3yum.repos.d]# [root@host3yum.repos.d]#yumcleanall [root@host3yum.repos.d]#yuminstall-yvirt-manager …………………………………………………………………… mesa-libEGL.x86_640:10.6.5-3.20150824.el7mesa-libGL.x86_640:10. mesa-libgbm.x86_640:10.6.5-3.20150824.el7mesa-libglapi.x86_64 nmap-ncat.x86_642:6.40-7.el7pango.x86_640:1.36.8 pixman.x86_640:0.32.6-3.el7pulseaudio-libs.x86_6 pulseaudio-libs-glib2.x86_640:6.0-7.el7pycairo.x86_640:1.8. pygobject3.x86_640:3.14.0-3.el7python-ipaddr.noarch rest.x86_640:0.7.92-3.el7spice-glib.x86_640:0 spice-gtk3.x86_640:0.26-5.el7unbound-libs.x86_640 usbredir.x86_640:0.6-7.el7virt-manager-common.n vte-profile.x86_640:0.38.3-2.el7vte3.x86_640:0.36.4- Complete!原文链接:https://www.f2er.com/bash/390950.html