CentOS7.0 create local YUM Source
The "Local YUM source" in this article includes three types: one is to directly useAs the local yum source, the CentOS disc has the advantages of being simple and convenient. The disadvantage is that the CD package may be incomplete (Centos7 Everything: 6.5 in total7 GB); 2. SynchronizationCentOS official source to local (equivalent to creating a public image), the advantage is the most reliable, the disadvantage is to occupy the space traffic; the third is to create a completely custom local source, the advantage is the maximum flexibility. The disadvantage is that it is only used as a supplement to other sources.
I. UseCentOS disc 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: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:
Cat>/etc/yum. repos. d/CentOS-Local.repo
[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. HowCreate a public image using 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. For the list of available images, see:
Http: // www.Centos.org/download/mirrors/
The Code is as follows: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: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:
Cat>/etc/yum. repos. d/CentOS-Local.repo
[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: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:Createrepo/yum
Yum makecache # update Cache