Redhat6 -- yum

Source: Internet
Author: User

I,YumWhat is
Yum = yellow dog Updater, modified
The main function is to conveniently Add/delete/update RPM packages.
It automatically solves the dependency problem of the package.
It is convenientManagementA large number of system updates

Ii. Yum features
* Multiple resource libraries can be configured simultaneously)
* Simple configuration file (files under/etc/yum. conf,/etc/yum. Repos. d)
* Automatically solves the dependency problem when RPM packages are added or deleted.
* Easy to use
* Maintain consistency with the RPM Database

Iii. YumInstall
Centos/RHEL
1. # rpm-IVH yum-2.4.3-4.el4.centos.noarch.rpm

Iv. Yum Configuration
Yum configuration file
All configuration information of yum is stored in a configuration file named Yum. conf, which is usually located in the/etc directory. This is the top priority of the entire Yum system, so it is necessary to introduce it in detail. The following is a yum. Con file obtained from the Internet. Let's take this as an example to describe it.

[Main]
Cachedir =/var/Cache/yum
Debuglevel = 2
Logfile =/var/log/yum. Log
Pkgpolicy = newest
Distroverpkg = RedHat-release
Tolerant = 1
Exactarch = 1
Retries = 1

[base]
name = Fedora Core $ releasever-$ basearch-base
baseurl = http://download.atrpms.net/mirrors/fedoracore/?releasever/?basearch/ OS
volumes
http://developer.clarkson.edu/pub/dist..er/javasbasearch/ OS

[Updates-released]
Name = Fedora Core $ releasever-$ basearch-released updates
Baseurl = http://download.atrpms.net/mirrors/fedoracore/updates/?releasever/?basearch
Http://redhat.linux.ee/pub/fedora/l..sever/?basearch
Http://fr2.rpmfind.net/linux/fedora..sever/?basearch

[Fedora. Us]
Name = fedora. US-$ basearch-extras
Baseurl = Signature

[Dag wieers]
Name = Dag RPM repository for Fedora Core
Baseurl = http://apt.sw.be/fedora/?releasever/en/?basearch/dag

[Livna]
Name = livna rpm, Fedora Core $ releasever-$ basearch
Baseurl = http://rpm.livna.org/fedora/?releasever/?basearch/rpms.stable

[Freshrpms]
Name = freshrpms
Baseurl = http://ayo.freshrpms.net/fedora/linux/?releasever/?basearch/freshrpms/
Http://ftp.us2.freshrpms.net/linux/...arch/freshrpms/

 

Part 1(This is the global setting of yum. You do not need to change it by default .)

[Main]
Cachedir: directory of the yum cache. Yum stores the downloaded RPM package andDatabase, Usually/var/Cache/yum.
Debuglevel: the debugging level. The value ranges from 0 to 10. The default value is 2.
Logfile: YumLogsFile. The default value is/var/log/yum. log.
Pkgpolicy: the package policy. There are two options: Newest and last. This is used if you set multiple repository, and the sameSoftwareIn different repository files, which one should Yum install? If it is newest, yum will install the latest version. If it is last, yum sorts the server IDs in alphabetical order and selects the lastServerOnSoftwareInstall. Generally, select newest.
Distroverpkg: Specifies a software package. Yum determines your release version based on this package. The default value is RedHat-release, or any installed RPM package for your own release.
Exactarch has two options: 1 and 0, indicating whether to upgrade only the same package as the CPU system of your installation package. If it is set to 1, if you have installed an i386 rpm, yum will not be upgraded with a 1686 package.
Retries,NetworkNumber of Retries after a connection error occurs. If it is set to 0, it will retry infinitely.
Tolerent also has 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.

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

Exclude =, excluding some software from the upgrade list, you can use wildcards to separate each item in the list with spaces. This is especially useful for users who have installed Chinese patches such as beautification packages.
Gpgchkeck = there are two options: 1 and 0, which respectively indicate whether or not to perform GPG verification. If this option is not selected, it is also checked by default.

Part 2:

Configuring the repository server is the most exciting thing. With a good repository, just like opening a big store at the door, you just need something to run a little errands. By the way, this is a free big store.
All server settings should follow the following format:

1. [serverid]
2. Name = some name for thisServer
3. baseurl = URL: // path/to/Repository/

Serverid is used to distinguish different repository. It must have a unique name.
Name, which is a description of repository and supports variables such as $ releasever $ basearch;
Baseurl is the most important part in server settings. You can obtain software from it only when the settings are correct. The format is:

1. baseurl = URL: // server1/path/to/Repository/
2. url: // server2/path/to/Repository/
3. url: // server3/path/to/Repository/

The URL supports three protocols: http: // ftp: // file. After baseurl, it can be followed by multiple URLs. You can change it to an image site with a high speed, but there can only be one baseurl, that is, it cannot be in the following format:

1. baseurl = URL: // server1/path/to/Repository/
2. baseurl = URL: // server2/path/to/Repository/
3. baseurl = URL: // server3/path/to/Repository/

The directory to which the URL points must be the upper level of the Repository header directory. It also supports variables such as $ releasever $ basearch.
You can add multiple options after the URL, such as gpgcheck, exclude, and failovermethod. For example:

1. [updates-released]
2. Name = Fedora Core $ releasever-$ basearch-released updates
3. baseurl = http://download.atrpms.net/mirrors/fedoracore/updates/?releasever/?basearch
4. http://redhat.linux.ee/pub/fedora/linux/core/updates/?releasever/?basearch
5. http://fr2.rpmfind.net/linux/fedora/core/updates/?releasever/?basearch
6. gpgcheck = 1
7. Exclude = Gaim
8. failovermethod = Priority

The meaning of gpgcheck and exclude is the same as that of [main], but it only works for this server. failovermethode has two options: roundrobin and priority, meaning that multiple URLs are available, in the order of Yum selection, roundrobin is a random selection. If the connection fails, use the next one, which loops in sequence, and priority starts from the first one according to the URL order. If not specified, the default value is roundrobin.

Several Variables

$ Releasever, The version of the release, which is obtained from distroverpkg in the [main] section. If not, the RedHat-release package is used for determination.
$ Arch, CPU system, such as i686, athlon, etc.
$ Basearch, CPU basic system group, such as i686 and athlon belong to i386, Alpha and alphaev6 belong to the same Alpha.

After setting yum. conf, we can enjoy the convenience of yum.

V. RHEL/centos Yum Source
1. modify the configuration file
2. Import the GPG key

Import the GPG key of each reposity. As mentioned earlier, yum can use GPG to verify the package to ensure the integrity of the downloaded package. Therefore, we need to find the GPG key at each repository site first, usually on the home page eye-catching location, some names such as RPM-GPG-KEY.txt plain text files, download them, and then use rpm -- import xxx.txt command to import them, it is best to bring the release version of The GPG-KEY is also imported. Rpm -- import/usr/share/doc/RedHat-release-*/on the RPM-GPG-KEY official software upgrade.

6. Expand your RPM package
1. rpmforge
The default Yum software repository for centos/RHEL is very limited. It is only limited to the regular packages and updates of some software packages in the released versions. Using rpmforge, many third-party RPM software packages can be added.

Obtain
Http://dag.wieers.com/rpm/packages/rpmforge-release/
Find the rpmforge package that matches the system platform architecture and install it. After installation, two files, mirrors-rpmforge and rpmforge. Repo, will be added under/etc/yum. Repos. d/of the system by default.

Install
# Rpm-IVH rpmforge-release-0.3.6-1.el4.rf.i386.rpm
# Rpm -- import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

2. Accelerate the yum update speed
Installing the fast mirror plug-in of Yum can speed up centos/RHEL Yum and improve stability with remarkable results.
Centos5
# Yum-y install Yum-fastestmirror
Centos4
Yum-y install Yum-plugin-fastestmirror

 

VII. Use yum
Note: When the yum or yum resource library is updated for the first time, yum will automatically download all the required headers and place them in the/var/Cache/Yum Directory, which may take a long time.

System update (update all RPM packages that can be upgraded, including kernel)
# Yum-y update

 

Perform system updates on a regular basis every day
# Chkconfig Yum on
# Service Yum start

 

* Update the RPM package and check the updatable RPM package
# Yum check-Update

 

Update all RPM packages
# Yum update

 

Update the specified RPM package, such as updating the kernel and kernel source
# Yum update kernel-Source

 

For large-scale version upgrades, unlike Yum update, the old obsolete package is also upgraded.
# Yum upgrade

 

* Installation and deletion of RPM packages
Install RPM packages like xmms-mp3
# Yum install xmms-mp3

 

Delete an RPM package, including packages that depend on the package
# Yum remove licq
Note: You will also be prompted to delete licq-gnome, licq-QT, and licq-text.

 

* Parameters related to Yum temporary storage (/var/Cache/Yum /)
Clear temporary RPM package files
# Yum clean packages

 

Clear temporary RPM header files
# Yum clean Headers

 

Clear the existing RPM header file
# Yum clean oldheaders

 

Clear existing RPM header files and package files
# Yum clean or # Yum clean all
Note: equivalent to Yum clean packages + Yum clean oldheaders

 

* RPM package list
List all RPM packages that can be installed or updated in the resource library
# Yum list

 

List specific rpm packages that can be installed, updated, and installed in the resource library
# Yum list Mozilla
# Yum list Mozilla *
Note: Match characters can be used in RPM package names, for example, to list all RPM packages starting with Mozilla

 

List all updates to the RPM package in the resource library
# Yum list updates

 

List all installed RPM packages
# Yum List Installed

 

List RPM packages installed but not included in the resource library
# Yum list extras
Note: download and install the RPM package from other websites
* RPM package information display (the info parameter is the same as the list)

 

Lists information about all RPM packages that can be installed or updated in the resource library.
# Yum info

 

Lists the specific information of RPM packages that can be installed or updated and installed in the resource library.
# Yum info Mozilla
# Yum info Mozilla *
Note: Match characters can be used in RPM package names, such as listing all RPM packages starting with Mozilla

 

Lists information about all the RPM packages that can be updated in the resource library.
# Yum info updates

 

Lists information about all installed RPM packages.
# Yum info installed

 

Lists the installed RPM packages that are not included in the resource library.
# Yum info extras
Note: Download the installed RPM package information from other websites.

 

* Search for an RPM package
Search for RPM packages matching specific characters
# Yum search Mozilla
Note: Search for RPM package names and package descriptions

 

Search for RPM packages with specific file names
# Yum provides realplay

 

VIII. Yum Common Problems
1. If the network speed is slow, you can increase the yum timeout time so that it will not always exit because of timeout.
# Vi/etc/yum. conf
# Add this sentence
Timeout = 120

 

2. Yum existing lock error Solution
If Yum existing lock/var/run/yum. PID: Another copy is running as PID 3380. Aborting occurs when the system is started, you can use the following solution:
Method 1
Etc/init. d/Yum-updatesd stop

Method 2
# Rm-F/var/run/yum. PID
The main reason is that Yum is automatically updated. You only need to turn it off.

 

First install fastestmirror to automatically select the fastest image when the system is yum:

# Yum install Yum-fastestmirror-y

Next, let's talk about rpmforge.

Rpmforge is a secure, stable, and timely software repository. By installing rpmforge, you can choose one more option for centos during Yum update. Sometimes it is even the only option, for example, if you want to upgrade rsync to version 3.0.x, you have to rely on rpmforge if you are too reluctant to compile and install it yourself.

1. Install the yum plug-in priority first. This plug-in is used to set the priority of the software repository when installing the software. Generally, it is installed from the official base or image by default, and then fromCommunityThe user contribute software is installed, and then installed from a third-party software warehouse.
# Yum install Yum-Priorities

2. manually edit the file suffixed with. repos in the/etc/yum. Repos. d/directory to set the software repository priority.
Priority = N(N is an integer ranging from 1 to 99. A smaller number indicates a higher priority)

The officially recommended configuration is
[Base], [Addons], [updates], [extras] Priority = 1
[Centosplus], [contrib] Priority = 2
Third party repos such as rpmforge... Priority = N (where N is> 10 and based on your preference)

3. Install rpmforge software warehouse now
First download the rpmforge installation package
I386WgetHttp://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

X86_64WgetHttp://apt.sw.be/redhat/el5/en/x86_64/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

Install

Rpm-I rpmforge-release-0.3.6-1.el5.rf. *. rpm

Change the/etc/yum. Repos. d/rpmforge. Repo configuration file and add
Priority = 1(Or 2.3.4 ....)

Now you can use the rpmforge software repository. For example, yum update rsync and hey, we have successfully upgraded to 3.0.5.

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.