Manually create your own YUM repository in CentOS 7

Source: Internet
Author: User

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@localhostyum.repos.d]#lltotal24-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@localhostyum-packages]#rpm-ivhcreaterepo-0.9.9-23.el7.noarch.rpmwarning:createrepo-0.9.9-23.el7.noarch.rpm:HeaderV3RSA/SHA256Signature,keyIDf4a80eb5:NOKEYPreparing...#################################[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@localhostyum-packages]#cd/etc/yum.repos.d/[root@localhostyum.repos.d]#vimownyum.repo[root@localhostyum.repos.d]#catownyum.repo[centos]name=centosyumbaseurl=file:///yum-packages/[root@localhostyum.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@localhostyum.repos.d]#yumcleanallLoadedplugins:fastestmirror,langpacksCleaningrepos:centosCleaningupeverythingCleaninguplistoffastestmirrors[root@localhostyum.repos.d]#yumlist

You can see your own yum repository information.

xorg-x11-xbitmaps.noarch1.1.1-6.el7centosxpp3.noarch1.1.3.8-11.el7centosxrestop.x86_640.4-14.el7centosxsane-common.x86_640.999-9.el7centosxsane-gimp.x86_640.999-9.el7centosxsettings-kde.x86_640.12.3-7.el7centosxsom.noarch0-10.20110809svn.el7centosxterm.x86_64295-3.el7centosxulrunner.x86_6431.4.0-1.el7.centoscentosxz-devel.x86_645.1.2-9alpha.el7centosyp-tools.x86_642.14-3.el7centosypbind.x86_643:1.37.1-7.el7centosypserv.x86_642.31-8.el7centosyum-plugin-aliases.noarch1.1.31-29.el7centosyum-plugin-changelog.noarch1.1.31-29.el7centosyum-plugin-tmprepo.noarch1.1.31-29.el7centosyum-plugin-verify.noarch1.1.31-29.el7centosyum-plugin-versionlock.noarch1.1.31-29.el7centoszlib-devel.x86_641.2.7-13.el7centoszsh.x86_645.0.2-7.el7centoszziplib.x86_640.13.62-5.el7centos

Here, centos is the name in [centos.

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.