15
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

サポート切れの CentOS5 で yum を使えるようにする

Posted at

概要

CentOS5 は 2017/03/31 にサポートが切れてしまったため yum update などのコマンドを実行しても以下のように URL 利用不可のエラーとなってしまいます。

# yum update
Loaded plugins: fastestmirror, security
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

既にサポート切れの OS のため、利用する機会は少ないかと思いますが検証用として一時的に yum を使いたいケースなどもあるかと思います。

本記事では CentOS5 で yum を使えるようにする手順について紹介したいと思います。

手順

1. CentOS バージョンの確認

まずは CentOS のバージョンの確認を行います。

# cat /etc/redhat-release
CentOS release 5.10 (Final)

2. リポジトリファイルの更新

以下のリポジトリファイルを開きます。

# vi /etc/yum.repos.d/CentOS-Base.repo

既に指定されている baseurl の行はすべてコメントアウトして各セクションへ以下の行を追加します。

  • [base]
    • baseurl=http://archive.kernel.org/centos-vault/5.10/os/$basearch/
  • [updates]
    • baseurl=http://archive.kernel.org/centos-vault/5.10/updates/$basearch/
  • [extras]
    • baseurl=http://archive.kernel.org/centos-vault/5.10/extras/$basearch/
  • [centosplus]
    • baseurl=http://archive.kernel.org/centos-vault/5.10/centosplus/$basearch/
  • [contrib]
    • baseurl=http://archive.kernel.org/centos-vault/5.10/contrib/$basearch/

※ここではバージョンを 5.10 としていますが、手順1で確認した CentOS のバージョンを指定してください。

# 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://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
baseurl=http://archive.kernel.org/centos-vault/5.10/os/$basearch/

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
baseurl=http://archive.kernel.org/centos-vault/5.10/updates/$basearch/

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
baseurl=http://archive.kernel.org/centos-vault/5.10/extras/$basearch/

#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://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
baseurl=http://archive.kernel.org/centos-vault/5.10/centosplus/$basearch/

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
baseurl=http://archive.kernel.org/centos-vault/5.10/contrib/$basearch/

リポジトリファイルの更新が完了したら上書き保存します。

3. yum コマンドの実行

CentOS5 で yum update コマンドが使えるようになっています。

# yum update
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/repo/arch combination/
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/repo/arch combination/
base                                                                                             | 1.1 kB     00:00
extras                                                                                           | 2.1 kB     00:00
extras/primary_db                                                                                | 173 kB     00:01
updates                                                                                          | 1.9 kB     00:00
updates/primary_db                                                                               | 630 kB     00:01
Skipping security plugin, no data
Setting up Update Process
Resolving Dependencies
Skipping security plugin, no data
--> Running transaction check

...(略)...

15
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?