Build an intranet yum repository using CentOS

Source: Internet
Author: User
Tags ftp protocol

Recently, I was working on an internal knowledge base system, requiring that it can only be used in an Intranet environment. I virtualized a server on a physical server. After installing the CentOS6.4 system, during environment deployment, it is found that the system is installed with minimal installation. Many Development Kits are not installed. However, the server cannot access the Internet and cannot use the Internet yum source to install the software package. As a result, I set up a yum source on the Intranet and sorted out the steps. I have done this before, but I have been very lazy and have not sorted it out. I want to sort it out today. The steps I have written are relatively detailed, so it looks long, but it is suitable for beginners.

(To facilitate the deployment of other servers of the same version in the same Intranet in the future, I use ftp as the yum source on the local machine, in the future, other servers in the Intranet can directly use the yum source using ftp .)

(1) mount the ISO image file to/media/cdrom.
Mount the downloaded CentOS-6.4-x86_64-bin-DVD1.iso image file to a directory in the following way, usually mounted to/media/cdrom:
Mount-t iso9660-o loop/root/CentOS-6.4-x86_64-bin-DVD1.iso/media/cdrom/
 
(2) install and start the vsftpd service.
The vsftpd service is not installed by default because the installation of my server is minimized. Enter the mounted directory here. Use rpm-ivh to install the vsftpd service.
[Root@centos6centos6.4] # cd/media/cdrom/
[Root @ centos6cdrom] # ll
Total usage 676
-R -- 2 root root14 March 6 2013 CentOS_BuildTag
Dr-xr-xr-x3 root root2048 March 5 2013 EFI
-R -- 2 root root212 August March 3 2013 EULA
-R -- 2 root root18009 March 3 2013 GPL
Dr-xr-xr-x3 root root2048 March 5 2013 images
Dr-xr-xr-x2 root root2048 March 5 2013 isolinux
Dr-xr-xr-x2 root 649216 March 6 Packages
-R -- 2 root root1354 March 3 2013 RELEASE-NOTES-en-US.html
Dr-xr-xr-x2 root root4096 March 6 2013 repodata
-R -- 2 root root1706 March 3 2013 RPM-GPG-KEY-CentOS-6
-R -- 2 root root1730 March 3 2013 RPM-GPG-KEY-CentOS-Debug-6
-R -- 2 root root1730 March 3 2013 RPM-GPG-KEY-CentOS-Security-6
-R -- 2 root root1734 March 3 2013 RPM-GPG-KEY-CentOS-Testing-6
-R -- 1 root root3380 March 6 2013 TRANS. TBL
[Root @ centos6cdrom] # rpm-ivh Packages/vsftpd-2.2.2-11.el6_3.1.x86_64.rpm
After the installation is complete, start the vsftpd service:
[Root @ centos6 cdrom] # service vsftpd restart
[Root @ centos6 cdrom] # chkconfig vsftpd on # Set vsftpd service to self-start
[Root @ centos6cdrom] # chkconfig -- list | grep vsftpd
Vsftpd0: Disable 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: Disable
 
(3) create a yum repository directory
After vsftpd is installed, the/var/ftp/pub/directory is automatically created by default. We create the yum repository directory under this directory and name it centos6.4, as shown below:
[Root @ centos6 cdrom] # mkdir-p/var/ftp/pub/centos6.4/
[Root @ centos6 cdrom] # cp-rf/media/cdrom/*/var/ftp/pub/centos6.4/# copy all files in the CD image to the yum repository directory
This is the directory structure after the copy is completed:
[Root @ centos6 cdrom] # cd/var/ftp/pub/centos6.4
[Root@centos6centos6.4] # ll
Total usage 328
-R -- 1 root root14 November 6 15:03 CentOS_BuildTag
Dr-xr-xr-x3 root root4096 November 6 15:03 EFI
-R -- 1 root root212 November 6 15:03 EULA
-R -- 1 root root18009 November 6 15:03 GPL
Dr-xr-xr-x3 root root4096 November 6 15:03 images
Dr-xr-xr-x2 root root4096 November 6 15:03 isolinux
Dr-xr-xr-x2 root 266240 November 6 15:06 Packages
-R -- 1 root root1354 November 6 15:06 RELEASE-NOTES-en-US.html
Drwxr-xr-x2 root root4096 November 6 16:04 repodata
-R -- 1 root root1706 November 6 15:06 RPM-GPG-KEY-CentOS-6
-R -- 1 root root1730 November 6 15:06 RPM-GPG-KEY-CentOS-Debug-6
-R -- 1 root root1730 November 6 15:06 RPM-GPG-KEY-CentOS-Security-6
-R -- 1 root root1734 November 6 15:06 RPM-GPG-KEY-CentOS-Testing-6
-R -- 1 root root3380 November 6 15:06 TRANS. TBL
 
(4) create a yum source and update the software package dependency.
Manually create a repository dependency file. To create a yum source, you must install the createrepo software package. The installation of this software package depends on the following two packages:
Python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
Deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
Install these three packages together, as shown below:
[Root @ centos6cdrom] # rpm-ivh Packages/createrepo-0.9.9-17.el6.noarch.rpm Packages/python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm Packages/deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
 
[Root @ centos6 cdrom] # rm-rf/var/ftp/pub/centos6.4/repodata/# Delete the original dependency file and regenerate it.
[Root @ centos6 cdrom] # createrepo-v/var/ftp/pub/centos6.4/# recreate the dependency library file and regenerate the repodata directory
Next, modify the configuration file of the yum source address.
[Root @ centos6 ~] # Cd/etc/yum. repos. d/
[Root @ centos6 yum. repos. d] # for I in 'ls. /'; domv $ I-bak; done ;## put/etc/yum. repos. d/The files in the directory are renamed and backed up.
[Root @ centos6 yum. repos. d] # cp CentOS-Media.repo-bak CentOS-Media.repo
[Root @ centos6 centos6.4] # vi/etc/yum. repos. d/CentOS-Media.repo # use this file only, modify the following bold part of the content. You can change the directory according to your actual directory.
As follows:
 
C6-media
Name = CentOS-$ releasever-Media
# Baseurl = file: // media/CentOS/
File: // media/cdrom/
File: // media/cdrecorder/
Baseurl = ftp: // 192.168.0.109/pub/centos6.4/
Gpgcheck = 1
Enabled = 1
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 
Note:
Name = CentOS-$ releasever-Media custom description
Baseurl = file: // yum/Server specifies the protocol used and the location of the yum Source
Enabled = 1 whether to enable the yum repository, 1 for use, 0 for not use
Gpgcheck = 0 indicates whether the gpg key of the process is checked. 1 indicates check, and 0 indicates no check.
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release specify the location of the gpg KEY
 
Note:
Baseurl = specifies the yum source to use.
File indicates that the local yum source is used, in the format of file: // Source Path
Ftp means to use the ftp protocol to obtain the yum source, in the format of ftp: // sourceIP/repository directory
Http indicates that the Yum source is obtained using the http protocol in the format of http: // sourceIP/repository directory.
 
Gpgcheck = indicates whether to check the key. If you need to check the key, you can manually import it.
# Rpm -- import/etc/pki/rpm-gpg/gpg key file name
 
In the/etc/yum. repo. d/directory, it is best to have only one file with the suffix "repo", and rename other files to prevent interference.
 
 
[Root @ centos6 centos6.4] # yum clean all # Clear the yum cache. Otherwise, an error may occur during yum installation.
Loadedplugins: fastestmirror, security
Cleaningrepos: c6-media
Cleaningup Everything
Cleaningup list of fastest mirrors
 
Use yum to install the screen software package. The test is normal. As follows:
[Root @ centos6 centos6.4] # yum install screen-y # use the-y parameter, which means you do not need to confirm the installation directly.
Loadedplugins: fastestmirror, security
Determiningfastest mirrors
C6-media | 2.9 kB00: 00
C6-media/primary_db | 3.3 MB00: 00
Settingup Install Process
ResolvingDependencies
--> Running transaction check
---> Package screen. x86_64. 0.3-16. el6 will be installed
--> Finished Dependency Resolution
DependenciesResolved
========================================================== ========================================================== ========================================================== ==========================================
PackageArchVersionRepositorySize
========================================================== ========================================================== ========================================================== ==========================================
Installing:
Screenx86_644.0.3-16.el6c6-media494 k
TransactionSummary
========================================================== ========================================================== ========================================================== ==========================================
Install1 Package (s)
Totaldownload size: 494 k
Installedsize: 795 k
DownloadingPackages:
Screen-4.0.3-16.el6.x86_64.rpm | 494 kB00: 00
Warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrievingkey from file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
ImportingGPG key 0xC105B9DE:
Userid: CentOS-6 Key (CentOS 6 OfficialSigning Key) <centos-6-key@centos.org>
Package: centos-release-6-4.el6.centos.10.x86_64 (@ anaconda-CentOS-201303020151.x86_64/6.4)
From:/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Runningrpm_check_debug
RunningTransaction Test
TransactionTest Succeeded
RunningTransaction
Warning: RPMDB altered outside of yum.
Installing: screen-4.0.3-16.el6.x86_641/1
Verifying: A screen-4.0.3-16.el6.x86_641/1
 
Installed:
Screen. x86_64. 0.3-16. el6
 
Complete!

Recommended reading:

RedHat Linux local yum source configuration

RedHat 6.2 modify yum source in Linux use CentOS source for free

Configure the epel yum Source

Redhat local yum source configuration

Description of yum configuration file

Install yum in RedHat 6.1)

YUM installation and cleaning

Related Article

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.