The "local Yum source" in this article includes three types: one is to use the CentOS disc directly as a local Yum source, the advantage is simple and convenient, the disadvantage is that the CD package may be incomplete (CentOS 7 Everything A total of 6.57G) The second is synchronized CentOS official source to the local (equivalent to creating a common mirror), the advantage is the most reliable, the disadvantage is the space charge traffic; third, create a fully customizable local source, the advantage is the most flexible, the disadvantage is only as a supplement to other sources.
First, use CentOS CD-ROM as a local Yum source
(1) on the physical machine directly into the CD-ROM
(2) VMware Workstation virtual machine: virtual machine--> removable device-->cd/dvd--> connection
| The code is as follows |
Copy Code |
|
Mkdir/mnt/cdrom #创建目录
Mount/dev/cdrom/mnt/cdrom #挂载
Umount/mnt/cdrom #卸载 |
If you do not want to put the disc every time, then copy the CD file to the local hard drive bar
Cp-avf/mnt/cdrom/yum #-A: This option preserves links, file attributes, and recursively copies the directory
2. Create repo files
| 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 not even Createrepo software is installed?
The role of Createrepo is to create an index file (located in the Repodata folder), which even has gpg-key.
Ii. How to create a public mirror for CentOS
For more information, see Official Chinese documents:
Http://wiki.centos.org/zh/HowTos/CreatePublicMirrors
Provides a shell script, and then Cron runs automatically ~ ~
The script is slightly modified to replace the USTC mirror source. Available Mirrors list 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
Todo
For base in $baselist
Todo
For the arch in $archlist
Todo
remote= $mirror/$ver/$base/$arch/
MKDIR-PV $localpath/$ver/$base/$arch/
$rsync $remote $localpath/$ver/$base/$arch/
Done
Done
Done |
Third, create a fully customized local source
The usual collection of some RPM packages in a directory, become a custom source, you can use Yum to manage, flexibility is quite large.
Official tutorials: How to setup your own package repository
1. Create local Yum Warehouse
| The code is as follows |
Copy Code |
|
Mkdir-p/yum/local #可以有N级目录
CP ... #复制RPM包到上述目录 |
2. Create repo files
| 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. Installation Createrepo
| The code is as follows |
Copy Code |
|
Yum Install Createrepo #使用yum安装createrepo
RPM-IVH http://mirror.centos.org/centos/7/os/x86_64/Packages/createrepo-0.9.9-23.el7.noarch.rpm |
4. CREATE index
| The code is as follows |
Copy Code |
|
Createrepo/yum
Yum Makecache #更新缓存 |