Your location:Tech News>News>Script>Yum configuration used in the source Detailed CentOS

Latest News

Yum configuration used in the source Detailed CentOS

Author:fsadmin

Views:

  A, yum Profile

  yum, is the Yellow dog Updater, Modified for short, is Duke University to improve the installation of RPM packages developed a software package manager.At first this is a yellow dog releases developer Terra Soft R & D, written in python, then still called yup (yellow dog updater), after improved by Duke University''s Linux @ Duke team, we had this name.yum aim is to automate the upgrade, install / remove rpm package, collect information about the rpm package, checks the dependencies and automatically prompts the user to solve.The key point is to have a reliable yum repository, the name suggests, this is software repository, it can be http or ftp site, the software can also be a local pool, but must include the header rpm, header includes a variety rpm package information, including description, function, a file provided, and dependence.It is these header collected and analyzed in order to complete the remaining tasks automation.

  yum idea is to use a central warehouse (repository) and even part of a distribution management application interrelationships, for the upgrade of software based on the calculated dependencies, install, delete, etc. operations, reducing dependencies Linux users have a headache problem.This is the same as yum and apt.Originally apt debian deb type of management software to use, but now also be able to rpm RedHat under the door of the.

  yum main function is more convenient to add / delete / update the RPM package, automatically solve the problem of dependent package, easy to manage a large number of system update problem.

  yum You can configure multiple resource library (Repository), simple configuration file (/ etc / yum.conf), automatically solve dependency problems encountered when to add or remove rpm package, to maintain consistency with the RPM database.

  Two, yum install

  CentOS yum has been installed by default, no need to install, here for experimental purposes, first uninstall and then reinstall yum.

  1. Check the default installation of yum

  # Rpm -qa | grep yum

  

  2, unloading yum

  # Rpm -e yum-fastestmirror-1.1.16-14.el5.centos.1 yum-metadata-parser-1.1.2-3.el5.centos yum-3.2.22-33.el5.centos

  

  3, re-install yum

  Here you can download via wget package installation from the Internet, you can also mount the installation CD to install, here choose to mount the installation CD to install the system.

  # Mount / dev / cdrom / mnt / cdrom /

  # Rpm -ivh yum-3.2.22-33.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm

  # Yum -v

  yum foundation installation package includes:

  yum // RPM installer / updater

  yum-fastestmirror // Yum plugin which chooses fastest repository from a mirrorlist

  yum-metadata-parser // A fast metadata parser for yum

  Other installation package according to their needs to be installed.

  

  Three, yum configuration

  yum configuration file is divided into two sections: main and repository

  main section defines the global configuration options, the entire yum configuration file should have only one main.Often located in / etc / yum.conf in.

  section defines each source repository / server specific configuration, there may be one or more.Often located in / etc / yum.repo.Each file in the directory d.

  yum.conf files are typically located in the / etc directory, which typically contains only part of the main configuration options.

  # Cat / etc / yum.conf

  [Main]

  cachedir = / var / cache / yum

  // yum cache directory, yum in this store downloaded rpm package and database, the default setting is / var / cache / yum

  keepcache = 0

  // whether to keep the package after the installation is complete, 0 is not retained (default is 0), 1 reserved

  debuglevel = 2

  // Debug information output level, in the range of 0-10, the default is 2

  logfile = / var / log / yum.log

  // yum log file location.A user can / var / log / yum.log file to query the update done in the past.

  pkgpolicy = newest

  // package of policies.There are two options, newest and last, this role is if you set up multiple repository, and the same software at the same time there is in a different repository, yum should be installed which, if it is newest, then yum will install the latest version of the.If last, then yum server id will be in alphabetical order, and finally select the software that is installed on the server.Are generally selected newest.

  distroverpkg = redhat-release

  // Specify a package, yum will judge you according to release this package, the default is redhat-release, can be any rpm package installed for their own release.

  tolerant = 1

  // There are two options 1 and 0, indicating whether yum tolerate errors associated with the command-line package occur, for example, you want to install three packages 1, 2, and 3 of which had been installed, if you set 1 , the error message does not appear yum.The default is 0.

  exactarch = 1

  // There are two options 1 and 0, set to 1, only the package installation and system architecture matched the yum, for example, yum package will not be installed in a suitable i686 i386 systems.The default is 1.

  retries = 6

  The number of retries after an error // network connection, if set to 0, the infinite retries.The default value is 6.

  obsoletes = 1

  // This is an update of parameters, please refer to the specific yum (8), simply put, is equivalent to the upgrade, it allows updating the old RPM package.

  plugins = 1

  // whether to enable plug-ins to allow default 1, 0 if not allowed.We usually use this plugin yum-fastestmirror.

  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 does not honor this.

  metadata_expire = 1h

  installonly_limit = 5

  # PUT YOUR REPOS HERE OR IN separate files named file.repo

  # In / etc / yum.repos.d

  In addition to these, there are some options that can be added, such as:

  exclude = selinux * // exclude certain software upgrades in addition to the list, you can use wildcards, list the items to use separated by a space, the installation such as for landscaping, Chinese friends is particularly useful patch.

  gpgcheck = 1 // 0 and 1 have two options, whether representing whether gpg (GNU Private Guard) check to determine the source rpm package is effective and safe.If this option is set in the [main] section is effective for everyone repository.The default value is 0.

  Fourth, the local yum configuration source

  1, system installation CD mount

  # Mount / dev / cdrom / mnt / cdrom /

  2, to configure the local source yum

  # Cd / etc / yum.repos.d /

  # Ls

  You will see four repo file

  

  CentOS-Base.yum repo is the source of network configuration files

  CentOS-Media.yum repo is a local source profile

  Modify CentOS-Media.repo

  # Cat CentOS-Media.repo

  # 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 - Media

  baseurl = file: /// media / CentOS /

  file: /// mnt / cdrom /

  file: /// media / cdrecorder /

  gpgcheck = 1

  enabled = 1

  gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-5

  Modify the second path baseurl for / mnt / cdrom (ie disc mount point)

  The enabled = 0 to 1

  3, disable the default network source yum

  The network source profile yum renamed CentOS-Base.repo.bak, otherwise it will first look for a suitable package in a network source, read directly from a local source renamed after.

  4, execute the command yum

  # Yum install postgresql

  

  

  About repo file format

  All repository server settings should follow the following format:

  [Serverid]

  name = Some name for this server

  baseurl = url: // path / to / repository /

  serverid different for each repository distinction must have a unique name;

  name is a description of repository to support such variables as $ releasever $ basearch;

  baseurl server setup is the most important part, only the settings are correct, in order to obtain software from above.Its format is:

  baseurl = url: // server1 / path / to / repository /

  url: // server2 / path / to / repository /

  url: // server3 / path / to / repository /

  Supported protocols which have url http: // ftp: // file: // three kinds.After baseurl can with multiple url, you can change yourself the faster mirror sites, but baseurl only one, that can not be like the following format:

  baseurl = url: // server1 / path / to / repository /

  baseurl = url: // server2 / path / to / repository /

  baseurl = url: // server3 / path / to / repository /

  Where the url points to a directory must be on the repository header directory, it also supports the variable $ releasever $ basearch.

  After url plurality of options can be added, such as gpgcheck, exclude, failovermethod the like, such as:

  [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 / linux / core / updates / $ releasever / $ basearch

  http: // fr2.rpmfind.net / linux / fedora / core / updates / $ releasever / $ basearch

  gpgcheck = 1

  exclude = gaim

  failovermethod = priority

  Wherein the same gpgcheck, exclude the meaning and [main] section, but this only works server, failovermethode priority and there are two options roundrobin, are meant to choose when multiple url, yum order selection, random roundrobin Alternatively, if the connection fails then the next, followed by cycle, priority according to the order starting from the first of the url.If not specified, the default is roundrobin.

  Fifth, configure yum domestic source

  Yum source system default speed is often unsatisfactory, in order to achieve rapid installation, modification here yum source for domestic source.

  Shanghai Jiaotong University yum source

  a. Modify / etc / yum.repos.d / CentOS-Base.repo as:

  # CentOS-Base.repo

  #

  # The mirror system uses the connecting IP address of the client and the

  # Update status of each mirror to pick mirrors that are updated to and

  # Geographically close to the client. You should use this for CentOS updates

  # Unless you are manually picking other mirrors.

  #

  # If the mirrorlist = does not work for you, as a fall back you can try the

  # Remarked out baseurl = line instead.

  #

  #

  [Base]

  name = CentOS- $ releasever - Base

  # Mirrorlist = http: // mirrorlist.centos.org /?release = $ releasever & arch = $ basearch & repo = os

  baseurl = http: // ftp.sjtu.edu.cn / centos / $ releasever / os / $ basearch /

  gpgcheck = 1

  gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-5

  #released updates

  [Updates]

  name = CentOS- $ releasever - Updates

  # Mirrorlist = http: // mirrorlist.centos.org /?release = $ releasever & arch = $ basearch & repo = updates

  baseurl = http: // ftp.sjtu.edu.cn / centos / $ releasever / updates / $ basearch /

  gpgcheck = 1

  gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-5

  #additional packages that may be useful

  [Extras]

  name = CentOS- $ releasever - Extras

  # Mirrorlist = http: // mirrorlist.centos.org /?release = $ releasever & arch = $ basearch & repo = extras

  baseurl = http: // ftp.sjtu.edu.cn / centos / $ releasever / extras / $ basearch /

  gpgcheck = 1

  gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-5

  #additional packages that extend functionality of existing packages

  [Centosplus]

  name = CentOS- $ releasever - Plus

  # Mirrorlist = http: // mirrorlist.centos.org /?release = $ releasever & arch = $ basearch & repo = centosplus

  baseurl = http: // ftp.sjtu.edu.cn / centos / $ releasever / centosplus / $ basearch /

  gpgcheck = 1

  enabled = 0

  gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-5

  #contrib - packages by Centos Users

  [Contrib]

  name = CentOS- $ releasever - Contrib

  # Mirrorlist = http: // mirrorlist.centos.org /?release = $ releasever & arch = $ basearch & repo = contrib

  baseurl = http: // ftp.sjtu.edu.cn / centos / $ releasever / contrib / $ basearch /

  gpgcheck = 1

  enabled = 0

  gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-5

  About variables

  $ Releasever: represents the release version, part of distroverpkg obtained from the [main], and if not, to judge according to the redhat-release package.

  $ Arch: cpu system, such as i686, athlon, etc.

  $ Basearch: cpu system basic group, such as athlon belong to the i386 and i686, alpha and alpha belong alphaev6.

  b. Import GPG KEY

  yum package can use gpg to verify and ensure the integrity of the download package, so we need to find each repository site gpg key, usually on the front page of eye-catching position, some names such as RPM-GPG-KEY-CentOS-5 a plain text file or the like, to download them, and then rpm --import RPM-GPG-kEY-CentOS-5 command to import the key.

  c. Yum command execution

  

  Yum other domestic sources listed below:

  1. Enterprise contributions:

  Sohu open mirror sites: http: // mirrors.sohu.com /

  Netease open mirror sites: http: // mirrors.163.com /

  2. University Teaching:

  Beijing Institute of Technology:

  http: // mirror.bit.edu.cn (IPv4 only)

  http: // mirror.bit6.edu.cn (IPv6 only)

  Beijing Jiaotong University:

  http: // mirror.bjtu.edu.cn (IPv4 only)

  http: // mirror6.bjtu.edu.cn (IPv6 only)

  http: // debian.bjtu.edu.cn (IPv4 + IPv6)

  Lanzhou University: http: // mirror.lzu.edu.cn /

  Xiamen University: http: // mirrors.xmu.edu.cn /

  Tsinghua University:

  http: // mirrors.tuna.tsinghua.edu.cn / (IPv4 + IPv6)

  http: // mirrors.6.tuna.tsinghua.edu.cn / (IPv6 only)

  http: // mirrors.4.tuna.tsinghua.edu.cn / (IPv4 only)

  Tianjin University: http: // mirror.tju.edu.cn /

  University of Science and Technology of China:

  http: // mirrors.ustc.edu.cn / (IPv4 + IPv6)

  http: // mirrors4.ustc.edu.cn /

  http: // mirrors6.ustc.edu.cn /

  Northeastern University:

  http: // mirror.neu.edu.cn / (IPv4 only)

  http: // mirror.neu6.edu.cn / (IPv6 only)

  University of Electronic Science and Technology: http: // ubuntu.uestc.edu.cn /

  Sixth, the use of third-party software libraries

  Centos / RHEL default yum repositories are very limited, confined to update releases that few conventional disk inside the package and some packages, the use of RpmForge, can add a lot of third-party software packages rpm.RpmForge library now has more than 10,000 kinds of packages for CentOS, CentOS community is considered to be the safest and most stable of a third-party software library.

  1, install yum-priorities plugin

  This plug-in is used to set the order when calling yum software source.Because official source software, are more stable and are recommended.Therefore, the order is higher than the official source of the order of a third-party source.How to ensure this order, you need to install yum-priorities this plugin.

  # Yum -y install yum-priorities

  

  2, needs to be set / etc / yum After installing yum-priorities plugin.repos.Under d / directory.repo relevant documents (such as CentOS-Base.the repo), is inserted in these documents sequence of instructions: priority = N (N is a positive integer of 1 to 99, the smaller the priority value)

  General Configuration [Base], [addons], [updates], [extras] The priority = 1, [CentOSplus], [contrib] The priority = 2, the third software other source: priority = N (Recommended N> 10 )

  To CentOS-Base.repo example:

  [base]

  name = CentOS- $ releasever - Base

  # Mirrorlist = http: // mirrorlist.centos.org /?release = $ releasever & arch = $ basearch & repo = os

  baseurl = http: // ftp.sjtu.edu.cn / centos / $ releasever / os / $ basearch /

  gpgcheck = 1

  gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-CentOS-5

  priority = 1

  3, download and install the appropriate rpm package rpmforge

  # Wget http: // pkgs.repoforge.org / rpmforge-release / rpmforge-release-0.5.2-2.el5.rf.i386.rpm

  4, the installation of PGP Key DAG

  # Rpm --import http: // apt.sw.be / RPM-GPG-KEY.dag.TXT

  5, verify the rpm package rpmforge

  # Rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm

  6, install the rpm package rpmforge

  # Rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm

  

  7, a / etc / yum.repos.d / rpmforge.repo file in the source level

  [Root @ TS-DEV yum.repos.d] # cat rpmforge.repo

  ### Name: RPMforge RPM Repository for RHEL 5 - dag

  ### URL: http: // rpmforge.net /

  [Rpmforge]

  name = RHEL $ releasever - RPMforge.net - dag

  baseurl = http: // apt.sw.be / redhat / el5 / en / $ basearch / rpmforge

  mirrorlist = http: // apt.sw.be / redhat / el5 / en / mirrors-rpmforge

  # Mirrorlist = file: /// etc / yum.repos.d / mirrors-rpmforge

  enabled = 1

  protect = 0

  gpgkey = file: /// etc / pki / rpm-gpg / RPM-GPG-KEY-rpmforge-dag

  gpgcheck = 1

  priority = 12

  8, the test installation

  # Yum install htop

  

  Other third-party software libraries such as EPEL (Extra Packages for Enterprise Linux) and installation and use RPMFusion and RPMForge similar, you can find information on their own installation.

  That''s all for this article, I want to be helpful to learn, I hope you will support script Home.

  You may also be interested in the article: the method of installing CentOS 5 CentOS yum-yum update if you change the source Detailed CentOS7 Ali cloud yum source uses detailed Detailed remedies centos7 configure the local yum yum in centos source method command to restore deleted Introduction

Recommend article

Relate article