CentOS7.0 create local YUM source

Source: Internet
Author: User
& Ldquo; local YUM source & rdquo; in this article, there are three types: one is to directly use CentOS as the local yum source, with the advantage of being simple and convenient, the disadvantage is that the CD software package may be incomplete (centos7Everything is only 6.57 GB in total); the second is to synchronize the CentOS official source to the local (equivalent to creating a public image), and the advantage is the most reliable, the disadvantage is that the traffic is occupied by space fees; the third is to create a fully customized local source, and the advantage is the maximum flexibility.

The "local YUM source" in this article includes three types: one is to directly useCentOSAs a local yum source, the optical disc has the advantages of being simple and convenient. The disadvantage is that the optical disc package may be incomplete (Centos 7The total number of Everything instances is only 6.5.7G); synchronizationCentOSThe official source to the local (equivalent to creating a public image), the advantage is the most reliable, the disadvantage is to occupy the space fee traffic; the third is to create a fully custom local source, the advantage is the maximum flexibility, the disadvantage is that it is only used as a supplement to other sources.
I. useCentOSCD as local yum source

(1) put the disc directly on the physical machine
(2) VMware Workstation virtual machine: Virtual Machine --> removable device --> CD/DVD --> connection

The code is as follows: Copy code

Mkdir/mnt/cdrom # Create a directory
Mount/dev/cdrom/mnt/cdrom # mount
Umount/mnt/cdrom # Uninstall

If you don't want to put the CD on each disk, copy the CD file to the local hard disk.

Cp-avf/mnt/cdrom/yum #-a: This option retains links and file attributes, and recursively copies directories.

2. create a repo file

The code is as follows: Copy code

Cat>/etc/yum. repos. d/CentOS-Local. repo <-EOF
[Local]
Name = Local Yum
Baseurl = file: // yum/
Gpgcheck = 1
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Enabled = 1

Q: Why can't I install the createrepo software?

The role of createrepo is to create an index file (in the repodata folder), with the GPG-KEY available on the disc.
2. howCentOSCreate a public image

For details, see the official Chinese document:

Http: // wiki.Centos. Org/zh/HowTos/CreatePublicMirrors

Provide a SHELL script, and then cron runs automatically ~~

The script is slightly modified and replaced with the image source of HKUST. For the list of available images, see:

Http: // www.Centos. Org/download/mirrors/

The code is as follows: Copy code

Localpath = "/mirrors/CentOS"
Mirror = "mirrors.hustunique.com ::Centos"
Rsync = "rsync-avzH -- delete"

Verlist ="7"
Baselist = "centosplus extras fasttrack OS updates"
Archlist = "x86_64"

For ver in $ verlist
Do
For base in $ baselist
Do
For arch in $ archlist
Do
Remote = $ mirror/$ ver/$ base/$ arch/
Mkdir-pv $ localpath/$ ver/$ base/$ arch/
$ Rsync $ remote $ localpath/$ ver/$ base/$ arch/
Done
Done
Done

3. create a fully customized local source

Put some RPM software packages that are commonly added to your favorites in a directory, and they will become a custom Source. you can use YUM for management, with great flexibility.

Official Tutorial: How to setup your own package repository

1. create a local yum repository

The code is as follows: Copy code

Mkdir-p/yum/local # there can be N-level directories

Cp... # Copy the RPM package to the above Directory

2. create a repo file

The code is as follows: Copy code

Cat>/etc/yum. repos. d/CentOS-Local. repo <-EOF
[Local]
Name = Local Yum
Baseurl = file: // yum/
Gpgcheck = 1
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Enabled = 1


 

3. install createrepo

The code is as follows: Copy code

Yum install createrepo # use yum to install createrepo
Rpm-ivh http: // mirror.Centos. Org/Centos/7/OS/x86_64/Packages/createrepo-0.9.9-23.el7. Noarch. rpm


4. create an index

The code is as follows: Copy code

Createrepo/yum
Yum makecache # Update cache

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.