[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

Enable yum to be used on EOL CentOS 6 [Repository change]

Hello everyone.
He is a member of the System Solutions Department and hopes that the default network connection speed will be 1Gbps or higher.

Migration of old environments such as CentOS 6 environments is strongly recommended, but due to various reasons some may remain.

In such an environment, it is easy to encounter a situation where "yum" that you try to use to update or add cannot be used (an error will occur if you use it).

This time, I will explain and explain the steps to "enable yum to be used on CentOS 6 (change repository)" to resolve this situation.

Preface

  • We do not recommend operating on CentOS 6.
    This is an emergency response to CentOS 6, which exists for unavoidable reasons
  • The purpose is not to use the Base repository, but to make "yum" usable.
  • These steps are due to the fact that it is the default repository.

Execution environment

■ Windows environment
OS: Windows 11 Pro (version: 23H2)
Language setting: Changed to Japanese

■ Verification CentOS 6 environment (Vagrant + VirtualBox)
OS: CentOS 6.9 (bento/centos-6.9)
Vagrant: 2.4.1
VirtualBox: 7.0.18 r162988 (Qt5.15.2)
IP: 192.168.33.15
Host name: targetnode
User name: vagrant

Repository cause - Error: Cannot find a valid baseurl for repo: base

$ yum info Loaded plugins: fastestmirror 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/x86_64/6/base/mirrorlist.txt Error: Cannot find a valid baseurl for repo: base

When using ``yum'' ``Error: Cannot find a valid baseurl for repo: base'' is most likely to be displayed.

This is due to EOL, and all repositories registered by default have been closed (terminated).
Therefore, the error occurs because "there are no available repositories".

You need to set up another repository for CentOS 6 that can be used to resolve the issue.

Work procedure

0. Checking yum errors

Please check this just to be sure so that you don't end up working on it even though there are no problems.

$ yum info Loaded plugins: fastestmirror 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/tmp/ yum-vagrant-BcYfuY/x86_64/6/base/mirrorlist.txt Error: Cannot find a valid baseurl for repo: base

Error: Cannot find a valid baseurl for repo: base

Now that we have confirmed the error, let's get started.

1. Back up your repository

Take a dated backup before making any changes to the repository.

There is a possibility that you may end up saving the file with all the contents deleted, so be sure to save it.

$ cp -p /etc/yum.repos.d/CentOS-Base.repo /tmp/CentOS-Base.repo.`date +%Y%m%d` $ ls -l /tmp | grep CentOS-Base.repo -rw-r--r--. 1 vagrant vagrant 1991 Mar 28 2017 CentOS-Base.repo.2024xxxx

(It is created in /tmp as it is a temporary backup)

TIps: CentOS-Base.repo.`date +%Y%m%d`

Use ` (backticks) to treat the result of the command as a string.
In it, we use the data command that can display the date and time by specifying the format (year, month, day).

This is convenient because you can create a backup file with the "year, month, and day" at the end of the file name when the command was executed, without having to look at the calendar.

2. Change repository

○ 2-1. Check default status

If you leave the repository as default, it should look like this:

$ less /etc/yum.repos.d/CentOS-Base.repo ~Omitted~ [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo =os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ ~Omitted~ [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist. centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ ~Omitted~ [extras] name=CentOS- $releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$ basearch/ ~Omitted~ [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror. centos.org/centos/$releasever/centosplus/$basearch/ ~Omitted~ [contrib] name=CentOS-$releasever - Contrib mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra =$infra #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/ ~Omitted~

○ 2-2. Mirror list is not functional, so disable it (comment out)

Comment out the "mirrorlist=http://mirrorlist.centos.org" part, but editing multiple places is easy to make mistakes.

Therefore, use the sed command to replace them all at once.

$ sudo sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\/mirrorlist.centos.org/g" /etc/yum.repos.d /CentOS-Base.repo

○ 2-3. Rewrite baseurl and enable it (comment in)

Uncomment "#baseurl=" and specify to use the CentOS repository provided by IIJ.
*Repositories available as of 2024/07 are specified. In the future, if the repository in question is terminated, please specify another one.

This is also replaced at once using the sed command.

$ sudo sed -i -e "s/^#baseurl=http:\/\/mirror.centos.org\/centos\/\$releasever/baseurl=http:\/\/ftp.iij.ad.jp\ /pub\/linux\/centos-vault\/\$releasever/g" /etc/yum.repos.d/CentOS-Base.repo
If you want to rewrite it manually, please change "#baseurl=" as shown below.
#baseurl=http://mirror.centos.org/centos/$releasever ⇓ baseurl=http://ftp.iij.ad.jp/pub/linux/centos-vault/$releasever

○ 2-4. Change/Difference confirmation

Check the difference between the edited repo and the backed up repo to confirm that the changes are as intended.

$ diff /etc/yum.repos.d/CentOS-Base.repo /tmp/CentOS-Base.repo.`date +%Y%m%d` 15,16c15,16 < #mirrorlist=http://mirrorlist. centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra < baseurl=http://ftp.iij.ad.jp/pub/linux/centos-vault/$releasever/os/$basearch/ -- - > mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra > #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch / ~Omitted~

There is no problem as long as you can see the difference between after and before the change as shown above.

○ 2-5. Specify the variable “$releasever”

To fix the minor release, write the version in the "releasever" variable.

This is done by creating a variable file to fix it.
(This response is not necessary if it has already been specified/fixed)

$ ls -l /etc/yum/vars/ | grep releasever *Check that it has not been created $ sudo sh -c 'echo "6.9" > /etc/yum/vars/releasever' *Create & add * Run as root If so, echo "6.9" > /etc/yum/vars/releasever is fine. $ cat /etc/yum/vars/releasever *Check that it is written 6.9

There is no problem because the 6.9 I wrote is displayed.

3. Check yum operation and delete cache

○ 3-1. Check that yum can be used with yum info

Let's display the php package information.

$ yum info php Loaded plugins: fastestmirror Determining fastest mirrors Available Packages Name : php Arch : x86_64 Version : 5.3.3 Release : 49.el6 Size : 1.1 M Repo : base Summary : PHP scripting language for creating dynamic web sites URL : http: //www.php.net/ License : PHP Description : PHP is an HTML-embedded scripting language. PHP attempts to make it ~omitted~

If the version etc. are displayed as shown above, yum is working without any problems.

○ 3-2. Delete yum cache

Although it is not required, since we changed yum, clear the cache.

$ sudo yum clean all Loaded plugins: fastestmirror Cleaning repos: base extras updates Cleaning up Everything Cleaning up list of fastest mirrors

completion

This completes the process of changing the repository to resolve the "yum" error.

lastly

This task itself is not difficult.
However, it is easy to get stuck due to this error when you want to use "yum", so it is easier to deal with it in advance in the CentOS 6 environment.

I hope this article provides some useful knowledge and information to those who read it.
Thank you for reading this far.

Reference materials

How do I change the CentOS 6 repository address? | Alibaba Cloud
https://www.alibabacloud.com/help/en/ecs/user-guide/change-the-centos-6-source-address

8.2.3. Displaying package information | RHEL6
https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/6/html/deployment_guide/sec-displaying_package_information

If you found this article helpful , please give it a like!
3
Loading...
3 votes, average: 1.00 / 13
2,713
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author

inside

Beyond mid-career in 2022 Belongs to
the System Solutions Department
LPIC-3 I have a 304 and AWS SAA I only
have three choices for regular drinks: milk, cola, and black tea.