三种方式搭建yum源

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了三种方式搭建yum源相关的知识,希望对你有一定的参考价值。

三种方式搭建yum源

1、本地搭建yum源:

[[email protected] x86_64]# vim /etc/yum.repos.d/mnt.repo 

[[email protected] x86_64]# cd /etc/yum.repos.d/

[[email protected] 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

[[email protected] yum.repos.d]# pwd

/etc/yum.repos.d


[[email protected] yum.repos.d]#cat /etc/yum.repos.d/mnt.repo

[mnt]
name=mnt
baseurl=file:///mnt
gpgcheck=0
enabled=1

[[email protected] yum.repos.d]# mount /dev/cdrom /mnt/

[[email protected] 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.repo http://mirrors.aliyun.com/repo/Centos-6.repo

centos7.0:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://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

#released updates 
[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

#additional packages that may be useful
[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

#additional packages that extend functionality of existing packages
[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 - packages by Centos Users
[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 -y install createrepo
[[email protected] yum.repos.d]# yum -y install httpd
[[email protected] yum.repos.d]# systemctl restart httpd
[[email protected] yum.repos.d]# mkdir -p /var/www/html/centos7.2/x86_64
[[email protected] yum.repos.d]# mount /dev/cdrom /mnt/
[[email protected] yum.repos.d]# cp -ar /mnt/* /var/www/html/centos7.2/x86_64
[[email protected] yum.repos.d]# cd /var/www/html/
[[email protected] html]#createrepo -p -d -o centos7.2/x86_64/ centos7.2/x86_64/

  

   在client客户端上面:

[[email protected] yum.repos.d]# cat test.repo 
[test]
name=test
baseurl=http://172.25.254.130/centos7.2/x86_64
gpgcheck=0
[[email protected] yum.repos.d]# 
[[email protected] yum.repos.d]# yum clean all
[[email protected] yum.repos.d]# yum install -y virt-manager
 ……………………………………………………………………
  mesa-libEGL.x86_64 0:10.6.5-3.20150824.el7  mesa-libGL.x86_64 0:10.
  mesa-libgbm.x86_64 0:10.6.5-3.20150824.el7  mesa-libglapi.x86_64 
  nmap-ncat.x86_64 2:6.40-7.el7               pango.x86_64 0:1.36.8
  pixman.x86_64 0:0.32.6-3.el7                pulseaudio-libs.x86_6
  pulseaudio-libs-glib2.x86_64 0:6.0-7.el7    pycairo.x86_64 0:1.8.
  pygobject3.x86_64 0:3.14.0-3.el7            python-ipaddr.noarch 
  rest.x86_64 0:0.7.92-3.el7                  spice-glib.x86_64 0:0
  spice-gtk3.x86_64 0:0.26-5.el7              unbound-libs.x86_64 0
  usbredir.x86_64 0:0.6-7.el7                 virt-manager-common.n
  vte-profile.x86_64 0:0.38.3-2.el7           vte3.x86_64 0:0.36.4-

Complete!



本文出自 “跛鳖千里,贵在分享” 博客,请务必保留此出处http://chenxiaotao.blog.51cto.com/11430805/1963188

以上是关于三种方式搭建yum源的主要内容,如果未能解决你的问题,请参考以下文章

简单的YUM三种搭建方式

5周第1次课(11月13日) 安装软件包的三种方法 rpm包介绍 yum工具用法 yum搭建本地仓库

Centos 7 下yum搭建lnmp环境(yum安装方式)

rpm,yum,yum搭建本地仓库

二十安装软件包的三种方法RPM包介绍rpm工具用法yum工具用法yum搭建本地仓库

二十安装软件包的三种方法RPM包介绍rpm工具用法yum工具用法yum搭建本地仓库