Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The basic usage of yum package Manager under CentOS

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "the basic use of yum package manager under CentOS". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

What is 1.yum?

Yum: Yellow dog Updater, Modified

The main function is to make it easier to add / delete / update RPM packages.

It can automatically solve the problem of packet dependence.

It is easy to manage a large number of system update problems.

Characteristics of yum

Multiple repositories can be configured simultaneously (Repository)

Concise configuration file (/ etc/yum.conf

Automatically resolve dependency issues encountered when adding or deleting rpm packages

Easy to use

Maintain consistency with RPM database

Yum installation

The RHEL3, and RHEL4 series can be installed using the yum RPM package provided by CentOS.

RHEL5 installs YUM by default, which can be used directly

CentOS installs YUM by default, which can be used directly

Fedora installs YUM by default, which can be used directly

two。 Install and update and uninstall

Installation

The code is as follows:

Yum install PACKAGE_NAME...

-y: the automatic answer is yes

If you need to install the specified version of the program:

The code is as follows:

Yum install PACKAGE-VERSION...

Reinstall the specified package:

The code is as follows:

Yum reinstall PACKAGE_NAME...

For example:

The code is as follows:

[root@localhost ~] # yum-y install creatrepo

Upgrade

The code is as follows:

Yum update PACKAGE_NAME

If more than one version of the upgrade package is available and you only expect to upgrade to the specified version:

The code is as follows:

Yum update PACKAGE-VERSION

Downgrade:

The code is as follows:

Yum downgrade PACKAGE_NAME

Check for available upgrades:

The code is as follows:

Yum check-update

For example:

The code is as follows:

[root@localhost ~] # yum update createrepo

Unloading

The code is as follows:

Yum erase | remove PACKAGE_NAME

Note: other packages that depend on the specified package will be uninstalled as well.

For example:

The code is as follows:

[root@localhost ~] # yum remove createrepo

3. Detailed explanation on the use of Yum common instructions

When you update the yum or yum repository for the first time, yum will automatically download all the required package index files and place them in the / var/cache/yum directory, which may take a long time.

Update related instructions for rpm package

Check for updatable rpm packages

The code is as follows:

# yum check-update

Update all rpm packages

The code is as follows:

# yum update

Update specified rpm packages, such as kernel and kernel source

The code is as follows:

# yum update kernel kernel-source

Large-scale version upgrades, unlike yum update, even old obsolete packages are upgraded.

The code is as follows:

# yum upgrade

Instructions for installing and removing rpm packages

Install rpm packages, such as xmms-mp3

The code is as follows:

# yum install xmms-mp3

Delete the rpm package, including packages that are dependent on the package

The code is as follows:

# yum remove xmms-mp3

Or

The code is as follows:

Yum erase xmms-mp3

(high version)

Parameters related to yum cache (/ var/cache/yum/)

Clear the rpm package file in the cache

The code is as follows:

# yum clean packages

Clear rpm header files in the cache

The code is as follows:

# yum clearn headers

Clear all relevant information in the cache

The code is as follows:

# yum clearn all

Rpm package information and list query related instructions

List all rpm packages in the repository that can be installed or updated

The code is as follows:

# yum list

List the specific rpm packages in the repository that can be installed or updated, as well as which packages have been installed

The code is as follows:

# yum list glibc

# yum list glibc*

List all updatable rpm packages in the repository

The code is as follows:

# yum list updates

List all installed rpm packages

The code is as follows:

# yum list installed

List rpm packages that have been installed but are not included in the repository (download installed rpm packages from other websites)

The code is as follows:

# yum list extras

Lists information about all rpm packages in the repository that can be installed or updated

The code is as follows:

# yum info

Lists specific information in the repository that can be installed or updated, as well as the rpm packages that have been installed

The code is as follows:

# yum info glibc

# yum info glibc*

Lists information about all updatable rpm packages in the repository

The code is as follows:

# yum info updates

List the information of all installed rpm packages

The code is as follows:

# yum info installed

List information about rpm packages that have been installed but are not included in the repository (information about installed rpm packages downloaded from other websites)

The code is as follows:

# yum info extras

Search for instructions related to rpm packages

Search for rpm packages that match specific characters (search in rpm package name, package description, etc.)

The code is as follows:

# yum search glibc

Search package list file for packages containing realplay

The code is as follows:

# yum provides realplay

The yum command can also install local rpm package files

The code is as follows:

Yum localinstall / path/to/rpm_package_file...

Install the local rpm package

Options:

-- enablerepo= enables a yum warehouse

-- disablerepo= disables a yum repository

Note: priority is higher than attributes defined in / etc/yum.repos.d/*.repo configuration file

-y: the automatic answer is yes

-- nogpgcheck: do not verify the source and integrity of the package

For example:

The code is as follows:

[root@localhost] # yum-y localinstall / tmp/repos/glibc-common-2.6.32-358.el6.i386.rpm

Construction method of 4.Yum Software Warehouse

If you manage a large number of servers, the installation and update of rpm packages will require access to the connection Internet, which will result in slow installation of packages and a waste of bandwidth. In order to avoid the disadvantages of the above situation, we can quickly install and update the software package by creating a local repository (repository).

Created on the server side of the warehouse to copy all data from the DVD or CD distribution to the server (take centos 5 as an example)

Create a warehouse catalog

The code is as follows:

Mkdir / yum

Mount the installation media disk

The code is as follows:

Mount-o loop / download/centos5.iso / mnt

Copy the contents of the CD to the / yum directory

The code is as follows:

Cp / mnt/* / yum

Create the index file of the software package for repository (need to install the createrepo package)

The code is as follows:

Cd / yum

Createrepo-g repodata/comps.xml.

(. Represents the current directory)

Configure the apache server, point the DocumentRoot to the / yum directory, and list the contents of the directory (sample configuration).

The code is as follows:

DocumentRoot "/ yum"

Options Indexes FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

Start apache, test access is normal, server-side settings are complete

Client settings, modify yum configuration file (assuming server ip = 192.168.0.1)

Modify the contents of the configuration file / etc/yum.repos.d/centos-server.repo as follows

The code is as follows:

# cat / etc/yum.repos.d/centos-server.repo

[main]

Cachedir=/var/cache/yum

Debuglevel=2

Logfile=/var/log/yum.log

Pkgpolicy=newest

Distroverpkg=redhat-release

Tolerant=1

Exactarch=1

Retries=20

Obsoletes=1

Gpgcheck=0

[centos5]

Name=centos5-Base

Baseurl= http://192.168.0.1/

Gpgcheck=0

Delete other .repo files in the / etc/yum.repos.d/ directory (do not use other software repositories)

After the above configuration, you can use the self-established warehouse to install and update the software package. If you need to build repositories of many distributions, you can divide them into different directories. Refer to the following directory structure.

The code is as follows:

/ yum

|-- rh45-x86-32

| |-- headers |

| | `--repodata |

|-- rh46-x86-32

| |-- headers |

| | `--repodata |

|-rh46-x86-64

| |-- headers |

| | `--repodata |

|-- rh48-x86-32

| |-- headers |

| | `--repodata |

|-rh48-x86-64

| |-- headers |

| | `--repodata |

|-- rh49-x86-32

| |-- headers |

| | `--repodata |

|-- rh52-x86-32

| | `--repodata |

|-- rh53-x86-32

| | `--repodata |

|-- rh54-x86-32

| | `--repodata |

|-rh54-x86-64

| | `--repodata |

|-rh55-x86-64

|-- rh56-x86-32

| | `--repodata |

|-rh56-x86-64

| | `--repodata |

|-rh57-x86-64

| | `--repodata |

|-- rh58-x86-32

| | `--repodata |

|-rh58-x86-64

| | `--repodata |

|-- rh60-x86-32

| | `--repodata |

|-rh60-x86-64

| | `--repodata |

|-- rh62-x86-32

| | `--repodata |

|-rh62-x86-64

| | `--repodata |

|-- rh63-x86-32

| | `--repodata |

|-rh63-x86-64

| | `--repodata |

|-rh64-x86-64

| | `--repodata |

`--update

|-- rhel3-x86-32

| |-- headers |

| | `--repodata |

|-rhel3-x86-64

| |-- headers |

| | `--repodata |

|-- rhel4-x86-32

| | `--repodata |

|-rhel4-x86-64

| | `--repodata |

|-- rhel5-x86-32

| | `--repodata |

|-rhel5-x86-64

`--repodata

Then, as needed, set up the client's yum configuration file, and you can use different distribution software repositories!

This is the end of the content of "basic usage of yum package Manager under CentOS". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 300

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report