How to update Yum source using centos

Source: Internet
Author: User
Tags ftp site gpg


1. Download the stable Yum source in China. Here I will download the 163 source.

At the same time I am using centos6.2 x86_64 version, so download is CentOS6-Base-163.repo

Follow these steps to verify your system version:

[[Email protected] ~] # Lsb_release-
LSB version: core-4.0-amd64: core-4.0-noarch: graphics-4.0-amd64: graphics-4.0-noarch: printing-4.0-amd64: printing-4.0-noarch:
Distributor ID: centos
Description: centos Release 6.2 (final)
Release: 6.2
Codename: Final
[[Email protected] ~] # Cat/etc/is
Iscsi/issue issue.net
[[Email protected] ~] # Cat/etc/issue
Centos Release 6.2 (final)
Kernel \ r on an \ m

[[Email protected] ~] # Rpm-Q centos-release
Centos-release-6-2.el6.centos.7.x86_64

Download the CentOS6-Base-163.repo to the/etc/yum. Repos. d/directory. This is the yum source configuration directory.

[[Email protected] yum. Repos. d] # wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

-- 18:46:41 -- http://mirrors.163.com/.help/CentOS6-Base-163.repo

Parsing host mirrors.163.com... 123.58.173.106

Connecting mirrors.163.com | 123.58.173.106 |: 80... already connected.

An HTTP request has been sent and is waiting for response... 200 OK

Length: 2006 (2.0 k) [application/octet-stream]

Saving to: CentOS6-Base-163.repo"


100% [============================================== >] 2,006 --. -K/S in 0 s


18:46:41 (37.1 Mb/s)-saved "CentOS6-Base-163.repo" [2006/2006])


2. Back up the original Yum source configuration file and install 163 Source


[[Email protected] yum. Repos. d] # mv CentOS-Base.repo. Bak

Rename the downloaded CentOS6-Base-163.repo to a CentOS-Base.repo

[[Email protected] yum. Repos. d] # ls

CentOS6-Base-163.repo CentOS-Base.repo.bak CentOS-Media.repo

CentOS-Base.repo CentOS-Debuginfo.repo

[[Email protected] yum. Repos. d] # Music CentOS6-Base-163.repo CentOS-Base.repo

MV: overwrite CentOS-Base.repo "? Yes

Clear Yum Cache

[[Email protected] yum. Repos. d] # Yum clean all

Loaded plugins: fastestmirror, refresh-packagekit, security

Cleaning repos: Base extras updates

Cleaning up everything

Cleaning up list of fastest mirrors

Update Yum Source

[[Email protected] yum. Repos. d] # Yum makecache

Loaded plugins: fastestmirror, refresh-packagekit, security

Determining fastest mirrors

Base | 3.7 KB

Base/group_gz | 220 KB

Base/filelists_db | 5.9 MB

Base/primary_db | 4.4 MB

Base/other_db | 2.8 mb

Extras | 3.4 kb: 00

Extras/filelists_db | 11 KB: 00

Extras/prestodelta | 907 B 00: 00

Extras/primary_db | 19 KB: 00

Extras/other_db | 5.8 KB: 00

Updates | 3.4 kb: 00

Updates/filelists_db | 2.2 MB: 00

Updates/prestodelta | 342 KB: 00

Updates/primary_db | 3.7 MB: 00

Updates/other_db | 31 MB

Metadata cache created

[[Email protected] yum. Repos. d] #

Now Yum source modification is complete


3. Other knowledge extensions


For instructions on the yum directory and local Yum source configuration, refer to the following article.

Http://www.cnblogs.com/mchina/archive/2013/01/04/2842275.html


1. Introduction to yum

Yum, short for Yellow Dog Updater and modified, is a software package manager developed by Duke University to improve the installation of RPM software packages. It was initially developed by Terra soft, a developer of the Yellow Dog release and written in Python. It was also called Yup (Yellow Dog Updater ), this name is also available after being improved by the [email protected] development team of Duke University. Yum is designed to automatically upgrade, install/remove RPM packages, collect RPM package information, check dependencies, and automatically prompt users to solve the problem. The key to Yum is to have a reliable repository. As the name suggests, this is the software repository. It can be an HTTP or FTP site, or a local software pool, but it must contain the RPM header, the header contains various RPM package information, including descriptions, functions, provided files, dependencies, and so on. Only by collecting and analyzing these headers can we automate the remaining tasks.

Yum uses a repository to manage the relationship between some or even a distribution application, and upgrades, installs, deletes, and so on based on the calculated software dependency, this reduces the dependencies problem that Linux users have always suffered. At this point, yum and APT are the same. APT is originally used by Deb software management of Debian, but now it can also use RPM under RedHat.

Yum is mainly used to conveniently add, delete, and update RPM packages. It automatically solves the dependency problem of packages and facilitates management of a large number of system updates.

Yum can be used to configure multiple resource libraries (repository) and a simple configuration file (/etc/yum. conf) automatically solves the dependency problem when the RPM package is added or deleted, and maintains consistency with the RPM database.


2. Configure the network source


The configuration file of yum is divided into two parts: Main and repository

  • The main section defines global configuration options. The entire Yum configuration file should have only one main. It is usually located in/etc/yum. conf.

  • The repository section defines the specific configurations of each source/server. There can be one or more configurations. It is usually located in the files in the/etc/yum. Repo. d directory.

The yum. conf file is generally located in the/etc directory, which generally only contains the configuration options of the main part.

# Cat/etc/yum. conf

650) This. width = 650; "src ="/e/u261/themes/default/images/spacer.gif "alt =" Copy code "style =" Background: URL ("/e/u261/lang/ZH-CN/images/localimage.png") No-repeat center; Border: 1px solid # DDD; "/>

[Main] cachedir =/var/Cache/Yum // Yum cache directory, where Yum stores the downloaded RPM package and database, the default value is/var/Cache/yumkeepcache = 0. // whether the software package is retained after the installation is complete. If the value is 0, the software package is not retained (the default value is 0 ), 1 indicates the output level of the retained debuglevel = 2 // debug information. The value range is 0-10. The default value is 2 logfile =/var/log/yum. log // Yum log file location. You can query previous updates in the/var/log/yum. log file. Pkgpolicy = newest // package policy. There are two options: Newest and last. If you set multiple repository and the same software exists in different repository, which one should Yum install, if it is newest, yum will install the latest version. If it is last, yum will sort the server IDs in alphabetical order and select the software installation on the last server. Generally, select newest. Distroverpkg = RedHat-release // specify a software package. Yum determines your release version based on this package. The default value is RedHat-release, you can also install any RPM packages for your own release. Tolerant = 1 // there are two options: 1 and 0, indicating whether Yum can tolerate errors related to software packages in command lines. For example, you need to install packages 1, 2, and 3, 3 of them have been installed before. If you set it to 1, yum will not have an error message. The default value is 0. Exactarch = 1 // there are two options: 1 and 0. If this parameter is set to 1, yum only installs software packages that match the system architecture. For example, yum will not install the i686 software package in a system suitable for i386. The default value is 1. Retries = 6 // Number of Retries after a network connection error occurs. If it is set to 0, the retries are unlimited. The default value is 6. obsoletes = 1 // This is an update parameter. For more information, see Yum (8). In short, this parameter is equivalent to upgrade, which allows you to update outdated RPM packages. Plugins = 1 // whether to enable the plug-in. The default value is 1. 0 indicates no. We usually use the Yum-fastestmirror plug-in. Bugtracker_url = http://bugs.centos.org/set_project.php? Project_id = 16 & ref = http://bugs.centos.org/bug_report_page.php? Category = Yum # Note: Yum-RHN-plugin doesn't honor this. metadata_expire = 1hinstallonly_limit = 5 # Put your repos here or in separate files named file. repo # in/etc/yum. repos. d

650) This. width = 650; "src ="/e/u261/themes/default/images/spacer.gif "alt =" Copy code "style =" Background: URL ("/e/u261/lang/ZH-CN/images/localimage.png") No-repeat center; Border: 1px solid # DDD; "/>

In addition to the above, there are some options that can be added, such:

Exclude = SELinux * // exclude some software from the upgrade list. You can use wildcards to separate each item in the list with spaces. This installation includes beautification packages, chinese patching is particularly useful.
Gpgcheck = 1 // there are two options: 1 and 0, which respectively indicate whether or not GPG (GNU private guard) verification is performed to determine whether the RPM package source is valid and safe. This option is valid for each repository if it is set in [main. The default value is 0.

3. Configure local source


Mount the system installation disc

# Mount/dev/CDROM/mnt/CDROM/

Configure local Yum Source

# Cd/etc/yum. Repos. d/

# Ls

Four repo files are displayed.

650) This. width = 650; "src ="/e/u261/themes/default/images/spacer.gif "style =" Background: URL ("/e/u261/lang/ZH-CN/images/localimage.png") No-repeat center; Border: 1px solid # DDD; "alt =" spacer.gif "/>

The CentOS-Base.repo is the configuration file for the yum network source

The CentOS-Media.repo is the configuration file of the yum local source

Modify CentOS-Media.repo

# Cat CentOS-Media.repo

650) This. width = 650; "src ="/e/u261/themes/default/images/spacer.gif "alt =" Copy code "style =" Background: URL ("/e/u261/lang/ZH-CN/images/localimage.png") No-repeat center; Border: 1px solid # DDD; "/>

# CentOS-Media.repo## This repo is used to mount the default locations for a CDROM / DVD on#  CentOS-5.  You can use this repo and yum to install items directly off the#  DVD ISO that we release.## To use this repo, put in your DVD and use it with the other repos too:#  yum --enablerepo=c5-media [command]#  # or for ONLY the media repo, do this:##  yum --disablerepo=\* --enablerepo=c5-media [command] [c5-media]name=CentOS-$releasever - Mediabaseurl=file:///media/CentOS/        file:///mnt/cdrom/        file:///media/cdrecorder/gpgcheck=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

650) This. width = 650; "src ="/e/u261/themes/default/images/spacer.gif "alt =" Copy code "style =" Background: URL ("/e/u261/lang/ZH-CN/images/localimage.png") No-repeat center; Border: 1px solid # DDD; "/>

In baseurl, change the 2nd paths to/mnt/CDROM (that is, the disk mount point)

Change enabled = 0 to 1

Disable the default Yum network source

Rename the yum network source configuration file to the CentOS-Base.repo.bak, otherwise it will first find the appropriate package in the network source, renamed and directly read from the local source


This article from the "Flying Pig" blog, please be sure to keep this source http://thinkpig007.blog.51cto.com/971471/1431959

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.