Manually create your own YUM repository in CentOS 7
I. Introduction
In the form of source code, the program must be compiled into a binary form before it can run and use. This form is compatible and controllable, but it is more troublesome to use, there are a lot of Dependencies to be solved; 2. RPM installation package, by compiling the source code based on a specific platform system into an executable file, and saving the dependency, the installation of open source software is simplified, however, manual dependency still needs to be solved. 3. YUM software management, YUM is designed to automatically resolve the RPM dependency, group the RPM, and introduce the repository (repo) concept and supports multiple repositories, which is easy to configure.
YUM uses the repository to save and manage the RPM software package. The repository configuration file is saved in the/etc/yum. repos. d/directory. the built-in configuration file of CentOS is as follows:
[root
@localhost
~]
#cd/etc/yum.repos.d/
[root
@localhost
yum.repos.d]
#ll
total24
-rw
-r--r--.1rootroot1664Mar3115:27CentOS-Base.repo
-rw
-r--r--.1rootroot1309Mar3115:27CentOS-CR.repo
-rw
-r--r--.1rootroot649Mar3115:27CentOS-Debuginfo.repo
-rw
-r--r--.1rootroot290Mar3115:27CentOS-fasttrack.repo
-rw
-r--r--.1rootroot1331Mar3115:27CentOS-Sources.repo
-rw
-r--r--.1rootroot1002Mar3115:27CentOS-Vault.repo
Delete these files. rm-rf CentOS * or the mv CentOS */yum folder is removed.
2. manually configure the YUM Repository
1. Copy all rpm software packages to a folder. Here we use the rpm software package that comes with CentOS 7, which can be used when the VMware physical machine cannot connect to the Internet. Mount the CentOS7 installation image to CentOS. The default file path is/run/media/centostest/, and CentOS6 is saved to/media/. Here, centostest is your username, the rpm package is saved in the Packages folder of the image file.
Create a folder and copy it. The copy time will be relatively long, and the virtual disc will be faster.
[root
@localhost
~]
#cd/
[root
@localhost
/]
#mkdiryum-packages
[root
@localhost
/]
#cp-rv/run/media/centostest/CentOS\7\x86_64/Packages/*/yum-packages/
2. Run the rpm command to install the createrepo software. The createrepo software package is included in the previously copied rpm file.
Install the createrepo software. The software name can be automatically supplemented by the Tab key.
[root
@localhost
/]
#cdyum-packages/
[root
@localhost
yum-packages]
#rpm-ivhcreaterepo-0.9.9-23.el7.noarch.rpm
warning:createrepo-0.9.9-23.el7.noarch.rpm:HeaderV3RSA/SHA256Signature,keyIDf4a80eb5:NOKEY
Preparing...
#################################[100%]
packagecreaterepo-0.9.9-23.el7.noarchisalreadyinstalled
3. Run the createrepo command to create an index.
createrepo/yum-packages/
A repodata folder is created under the yum-packages folder to save the index information.
4. Add a configuration file
Add a configuration file in the/etc/yum. repos. d/folder.
[root
@localhost
yum-packages]
#cd/etc/yum.repos.d/
[root
@localhost
yum.repos.d]
#vimownyum.repo
[root
@localhost
yum.repos.d]
#catownyum.repo
[centos]
name=centosyum
baseurl=file:///yum-packages/
[root
@localhost
yum.repos.d]
#
The simplest configuration is made here. [centos] And name can be obtained by any name. enabled and gpgcheck can be configured or not.
5. Clear YUM Cache
Run the yum clean all command to clear and run the yum list command to view the yum library.
[root
@localhost
yum.repos.d]
#yumcleanall
Loadedplugins:fastestmirror,langpacks
Cleaningrepos:centos
Cleaningupeverything
Cleaninguplistoffastestmirrors
[root
@localhost
yum.repos.d]
#yumlist
You can see your own yum repository information.
xorg-x11-xbitmaps.noarch1.1.1-6.el7centos
xpp3.noarch1.1.3.8-11.el7centos
xrestop.x86_640.4-14.el7centos
xsane-common.x86_640.999-9.el7centos
xsane-gimp.x86_640.999-9.el7centos
xsettings-kde.x86_640.12.3-7.el7centos
xsom.noarch0-10.20110809svn.el7centos
xterm.x86_64295-3.el7centos
xulrunner.x86_6431.4.0-1.el7.centoscentos
xz-devel.x86_645.1.2-9alpha.el7centos
yp-tools.x86_642.14-3.el7centos
ypbind.x86_643:1.37.1-7.el7centos
ypserv.x86_642.31-8.el7centos
yum-plugin-aliases.noarch1.1.31-29.el7centos
yum-plugin-changelog.noarch1.1.31-29.el7centos
yum-plugin-tmprepo.noarch1.1.31-29.el7centos
yum-plugin-verify.noarch1.1.31-29.el7centos
yum-plugin-versionlock.noarch1.1.31-29.el7centos
zlib-devel.x86_641.2.7-13.el7centos
zsh.x86_645.0.2-7.el7centos
zziplib.x86_640.13.62-5.el7centos
Here, centos is the name in [centos.