Offline Yum source mount and Yum Server Setup

Source: Internet
Author: User
Tags gz file centos server

In the current network environment, in most cases, CentOS or redhat (for example, CentOS) server is isolated from the public network, so need to find a server to mount their own Yum source.

First, the offline Yum source package production

Offline yum source can download image files from the official website directly (how to use the following will be introduced), you can also download the RPM package yourself after the production.

1. Download image files from official website

Since it is the production of Yum Source, of course, it is hoped that the image file contains the better package, so download from the official website, as far as possible to download the "Everything ISO", the other "DVD ISO" is a general version, the package is not complete, there is a "Minimal ISO" not to mention, is the CentOS minimal installation (equivalent to a pure Windows system). Centos
The 7 version of the "Everything ISO" image is as follows (self-selecting the mirror server and the downloaded system version):
Http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Everything-1511.iso
Example of downloaded file name: Centos-7-x86_64-everything-1511.iso

2, self-download RPM package production

If you have already downloaded the RPM package, you can make a Yum source (yum repository) yourself. Upload the downloaded RPM package to the CentOS server (such as the/data/rpm directory), then go to the directory where the RPM package is stored and execute the following command:

# createrepo .

In this way, the contents of the RPM package can be used as the Yum source directory (how to use it later), you can package this directory and put it in other places to use.
As in the previous example package: CD/DATA;TAR-ZCVF rpm.tar.gz rpm/
Note: If you are prompted not to find the Createrepo command, you can install the program using Yum install Createrepo. If you cannot install on the Internet, you need to download the RPM package installation on your own, especially if you want to download some dependent packages, for example, the Createrepo-0.9.9-23.el7.noarch version relies on the following packages:

[[email protected] test]# yum Deplist createrepo-0.9.9-23.el7.noarchLoaded plugins:fastestmirrorloading mirror speeds from cached Hostfile * base:mirrors. 163. com* Epel:mirror01. IDC. Hinet. NET* Extras:mirrors. Btte. NET* Updates:mirrors. 163. comPackage :Createrepo. Noarch 0.9. 9-.El7 dependency:/bin/sh Provider:bash. x86_644.2.-.El7 dependency:/usr/bin/python Provider:python. x86_642.7. 5-.El7 dependency:deltarpm provider:deltarpm. x86_643.6-3.El7 Dependency:libxml2-python Provider:libxml2-python. x86_642.9. 1-6.El7_2. 2Dependency:pyliblzma Provider:pyliblzma. x86_640.5. 3-One by one .El7 Dependency:python >=2.1Provider:python. x86_642.7. 5-.El7 Dependency:python (ABI) =2.7Provider:python. x86_642.7. 5-.El7 dependency:python-deltarpm provider:python-deltarpm. x86_643.6-3.El7 dependency:rpm >=4.1. 1provider:rpm. x86_644.11. 3-.El7 Dependency:rpm-python Provider:rpm-python. x86_644.11. 3-.El7 Dependency:yum >=3.4. 3-4Provider:yum. Noarch 3.4. 3-.El7. CentOS. 0. 1Dependency:yum-metadata-parser Provider:yum-metadata-parser. x86_641.1. 4-.El7
Second, the offline yum source configuration

As in the example above, after downloading a good ISO image, or a package that creates a good rpm (as in the example above, rpm.tar.gz), it is how to use these packages to create an offline Yum source (that is, an offline yum repository).

1. System ISO image file

Use the ISO file to create a Yum source that needs to be mounted before it can be used.
1, upload the ISO file (assuming upload to the/data directory);
2. Create mount Directory:

# mkdir -p /data/iso

3. Mount the ISO file:

# cd /data# mount -o loop -t iso9660 CentOS-7-x86_64-Everything-1511.iso /data/iso

4. Configuring Yum

# cd /etc/yum.repos.d/# mkdir bak# mv *repo bak/# vim local.repo

The contents of the Local.repo file are as follows:

[ISO]
Name=centos-7-x86_64-everything-iso
Baseurl=file:///data/iso
Gpgcheck=0
Enabled=1

5. Then verify that you can:

# yum clean all# yum makecache

See if there are any errors.

2. Self-made Yum Warehouse

As the above example, if the rpm.tar.gz file is self-produced, directly decompression after the configuration can be.
1, Upload rpm.tar.gz file (assuming upload to/data);
2. Decompression

# cd /data# tar -zxvf rpm.tar.gz -C /data/rpm

3. Configuring Yum

# cd /etc/yum.repos.d/# mkdir bak# mv *repo bak/# vim local_rpm.repo

The contents of the Local_rpm.repo file are as follows:

[RPM]
Name=rpm_package
baseurl=file:///data/rpm
Gpgcheck=0
Enabled=1

4. Then verify that you can:

# yum clean all# yum makecache

See if there are any errors.

Third, Yum Server Setup

The above steps and configuration can only be used locally on the offline Yum repository, if you want other servers (such as 10.1.245.102) You can also use the offline Yum repository for this server (for example, 10.1.245.105), and you'll need to share the Yum repository on that server via HTTP service or FTP service, which is provided in HTTP mode.
Note: The HTTP method provided here requires 80 ports, and no other server can filter out this port firewall.
1, build the HTTP server (as in the example 10.1.245.105, if it is set up, you can continue the next step)

# yum install -y httpd# systemctl enable httpd# systemctl start httpd

Note: If you cannot install via yum, download the following package (centos7.0 system for example) in turn:

# rpm -ivh apr-1.4.8-3.el7.x86_64.rpm# rpm -ivh apr-util-1.5.2-6.el7.x86_64.rpm# rpm -ivh httpd-tools-2.4.6-31.el7.x86_64.rpm# rpm -ivh mailcap-2.1.41-2.el7.noarch.rpm# rpm -ivh httpd-2.4.6-31.el7.x86_64.rpm# systemctl enable httpd# systemctl start httpd

2, according to the HTTPD service started as above, occupy port 80, the default access path is/var/www/html/, so you need to create the above example/data/rpm,/data/iso directory to do a soft connection to this directory:

# mkdir -p /var/www/html/# ln -s /data/rpm /var/www/html/rpm# ln -s /data/iso /var/www/html/iso

3. Configure the Yum source on other servers (as in the example above, 10.1.245.102):

# cd /etc/yum.repos.d/# mkdir bak# mv *repo bak/# vim http.repo

The contents of the Http.repo file are as follows:

[Http_iso]
name=iso_105
Baseurl=http://10.1.245.105/iso
Gpgcheck=0
Enabled=1

[HTTP_RPM]
name=rpm_105
baseurl=http://10.1.245.105/rpm
Gpgcheck=0
Enabled=1

4. Then verify that you can:

# yum clean all# yum makecache

See if there are any errors.

Offline Yum source mount and Yum Server Setup

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.