Three methods for creating local YUM source in CentOS7
This article mainly introduces three methods to create a local YUM source in CentOS7, this article describes how to use a CentOS CD as a local yum source, how to create a public image for CentOS, and how to create a fully customized local source. For more information, see
The "Local YUM source" in this article includes three types: one is to directly use the CentOS CD as the local yum source, the advantage is simple and convenient, the disadvantage is that the CD software package may be incomplete (centos 7 Everything 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 disadvantage is that it is only used as a supplement to other sources.
1. Use the CentOS CD as the local yum Source
(1) Put the disc directly on the Physical Machine
(2) VMware Workstation Virtual Machine: Virtual Machine --> Removable device --> CD/DVD --> connection
Copy the Code as follows:
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.
[Code]
Cp-avf/mnt/cdrom/yum #-a: This option retains links and file attributes, and Recursively copies directories.
2. Create a repo File
Copy the Code as follows:
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.
Ii. How to create a public image for CentOS
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. Available image list see: http://www.centos.org/download/mirrors/
Copy the Code as follows:
Localpath = "/mirrors/CentOS"
Mirror = "mirrors.hustunique.com: centos"
Rsync = "rsync-avzH -- delete" </p> <p> verlist = "7"
Baselist = "centosplus extras fasttrack OS updates"
Archlist = "x86_64" </p> <p> 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 </p> <p>
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
Copy the Code as follows:
Mkdir-p/yum/local # There can be N-level Directories
Cp... # copy the RPM package to the above directory
2. Create a repo File
Copy the Code as follows:
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
Copy the Code as follows:
Yum install createrepo # Use yum to install createrepo
Rpm-ivh <a href = "http://mirror.centos.org/centos/7/ OS /x86_64/Packages/createrepo-0.9.9-23.el7.noarch.rpm"> http://mirror.centos.org/centos/7/ OS /x86_64/Packages/createrepo-0.9.9-23.el7.noarch.rpm </a>
4. Create an index
Copy the Code as follows:
Createrepo/yum
Yum makecache # update Cache