Fix for CentOS 7 Repo Due to End of Life (EOL) Mirrorlist Error

If you’re managing CentOS 7 servers, you might have encountered a frustrating issue recently: repository failures due to the server reaching its End of Life (EOL) stage. This commonly manifests with errors like:

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Name or service not known"

This error indicates that the default CentOS 7 repositories are no longer accessible due to the distribution’s EOL status. Fortunately, there’s a straightforward fix to get your servers back on track.

Step-by-Step Fix

Follow these steps to resolve the CentOS 7 repository issue:

  1. Comment out Mirrorlist and Update Base URL:Open a terminal session on your CentOS 7 server and run the following commands:
    sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
    sed -i 's|#\s*baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
    

    These commands will comment out the mirrorlist URLs and update the base URLs to point to the vault.centos.org repository, which hosts CentOS archives after EOL.

  2. Run the Fix Script:Now, execute the fix script provided by Systron to automate the base repository update:
    curl -s -L https://systron.net/blog/wp-content/uploads/2024/07/centos7-repo-fix.sh | bash
    

    This script will automatically adjust the base repository URLs to use the vault.centos.org archive, ensuring that your CentOS 7 server can fetch packages and updates without encountering the mirrorlist error.

Why Vault.CentOS.org?

The vault.centos.org repository serves as an archive for older versions of CentOS after they reach EOL. It’s maintained by the CentOS community and provides a reliable source for accessing packages and updates for unsupported versions like CentOS 7.

Conclusion

By following these steps, you can effectively resolve the mirrorlist error on CentOS 7 servers affected by the EOL repository issue. This fix ensures that your systems remain secure and operational by redirecting package requests to the appropriate archive repository.

For ongoing management of CentOS servers, staying proactive about EOL dates and transitioning to supported distributions like CentOS Stream or alternatives such as CentOS 8 or AlmaLinux is recommended. You can order a Dedicated server or VPS with AlmaLinux with us.

Stay tuned for more updates and solutions to common server management issues at Systron Micronix. If you have any questions or feedback, feel free to leave a comment below. Happy server administration!

Note: Always ensure the integrity and security of scripts downloaded from the internet before executing them on your system.

How to migrate from CentOS to the latest AlmaLinux version?

Converting from CentOS 8.0 to AlmaLinux is a straightforward process thanks to the AlmaLinux Foundation’s provided tools. Below is a step-by-step guide to help you through the conversion:

Prerequisites:

  1. Backup your data: Ensure that you have backups of all important data and configurations.
  2. Update your system: Make sure your CentOS system is up-to-date.

Steps to Convert CentOS 8.x to AlmaLinux

  1. Update CentOS:
    sudo yum update -y
    sudo reboot
    
  2. Install ELevate Tool:
    The ELevate project by AlmaLinux provides tools to migrate between different RHEL-based distributions.

    sudo yum install -y https://repo.almalinux.org/almalinux/almalinux-release-latest.x86_64.rpm
    sudo yum install -y almalinux-deploy
    
    sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpm
  3. Run the Conversion Tool:
    Execute the conversion tool to switch your CentOS system to AlmaLinux.

    sudo almalinux-deploy
    

    This script will:

    • Update the repository configuration files to point to AlmaLinux repositories.
    • Replace CentOS-specific packages with their AlmaLinux equivalents.
    • Clean up the package manager’s cache and database.
  4. Reboot Your System:
    After the script completes, reboot your system to boot into AlmaLinux.

    sudo reboot
    
  5. Verify the Conversion:
    Once the system has rebooted, verify that the conversion was successful by checking the OS release information.

    cat /etc/redhat-release
    

    This should output something similar to:

    AlmaLinux release 8.x (Arctic Sphynx)
    
  6. Update AlmaLinux:
    Finally, update your new AlmaLinux system to ensure all packages are the latest versions.

    sudo yum update -y
    sudo reboot
    

Post-Conversion Tasks

  • Check Services: Ensure that all critical services are running correctly after the conversion.
  • Review Configuration Files: Some configuration files might need minor adjustments.
  • Test Applications: Verify that all your applications are functioning as expected on AlmaLinux.

Additional Resources

  • AlmaLinux Documentation: The official AlmaLinux documentation provides comprehensive guides and troubleshooting tips. Refer to the Almalinux migration guide here.
  • Community Support: Join the AlmaLinux community forums and mailing lists for support from other users and developers.

By following these steps, you should be able to convert your CentOS 8.x system to AlmaLinux smoothly. Enjoy,

Converting from CentOS 7 to AlmaLinux 8 involves a bit more work than converting between CentOS 8 and AlmaLinux 8 because it includes an upgrade across major versions (from 7 to 8). AlmaLinux provides the ELevate project for this purpose, which can migrate between different RHEL-based distributions and major versions.

Here’s a step-by-step guide to help you through the conversion:

Prerequisites

  1. Backup your data: Ensure that you have backups of all important data and configurations.
  2. Update your system: Make sure your CentOS 7 system is up-to-date.

Steps to Convert CentOS 7 to AlmaLinux 8

  1. Update CentOS:
    sudo yum update -y
    sudo reboot
    
  2. Install the ELevate Tool:
    The ELevate project provides tools to migrate between different RHEL-based distributions.

    sudo yum install -y https://repo.almalinux.org/almalinux/almalinux-release-latest.el7.x86_64.rpm
    sudo yum install -y elevate-release
    
  3. Install Leapp Utility:
    Leapp is the utility used by the ELevate project for upgrading between major versions.

    sudo yum install -y leapp-upgrade leapp-data-almalinux
    
  4. Review and Customize the Pre-Upgrade Report:
    Generate a pre-upgrade report to identify potential issues.

    sudo leapp preupgrade
    

    The report will be available at /var/log/leapp/leapp-report.json. Review this report and address any issues that are flagged. You might need to install additional packages or remove conflicting ones.

  5. Perform the Upgrade:
    Once the pre-upgrade issues are resolved, start the upgrade process.

    sudo leapp upgrade
    

    This process will download the necessary packages and prepare the system for the upgrade. You may need to confirm or intervene during the process, so monitor the upgrade closely.

  6. Reboot the System:
    After the upgrade preparation is complete, reboot the system to complete the upgrade process.

    sudo reboot
    

    The system will boot into the Leapp environment to perform the upgrade. This can take some time, so be patient.

  7. Post-Upgrade Steps:
    Once the upgrade is complete, your system should boot into AlmaLinux 8. Verify the upgrade by checking the OS release information.

    cat /etc/redhat-release
    

    This should output something like:

    AlmaLinux release 8.x (Arctic Sphynx)
    
  8. Update AlmaLinux:
    Finally, update your new AlmaLinux system to ensure all packages are the latest versions.

    sudo dnf update -y
    sudo reboot
    

Post-Conversion Tasks

  • Check Services: Ensure that all critical services are running correctly after the conversion.
  • Review Configuration Files: Some configuration files might need minor adjustments.
  • Test Applications: Verify that all your applications are functioning as expected on AlmaLinux.

Additional Resources

  • AlmaLinux Documentation: The official AlmaLinux documentation provides comprehensive guides and troubleshooting tips.
  • ELevate Project: Detailed information on the ELevate project can be found on the AlmaLinux website.
  • Community Support: Join the AlmaLinux community forums and mailing lists for support from other users and developers.

By following these steps, you should be able to upgrade your CentOS 7 system to AlmaLinux 8 successfully.

When you need a powerful dedicated server or vps server always consider Systron Micronix, Into the cloud and hosting space since over two decades.

Dedicated Server Versus Virtual Private Server

A dedicated server is a physical server that is leased or owned by an individual or organization and used for hosting websites or other applications. A dedicated server is typically used when a website or application requires a significant amount of resources or when the website or application is expected to receive a high level of traffic.

A virtual private server (VPS) is a virtual machine that is created on a physical server. Each VPS is isolated from the others, with its own operating system, resources, and software, and is generally used to host websites or applications that require fewer resources than a dedicated server.

There are several key differences between dedicated servers and virtual private servers :

Cost : Dedicated servers tend to be more expensive than VPSs because they offer more resources and greater control over the server.

Performance : Dedicated servers generally offer better performance than VPSs because they are not sharing resources with other virtual machines.

Scalability : It is generally easier to scale a VPS than a dedicated server, as it is easier to add additional virtual machines to a physical server than it is to purchase and set up a new dedicated server.

Control : With a dedicated server, you have complete control over the hardware and software, whereas with a VPS, you are limited to the resources and options provided by the hosting provider.

Ultimately, the choice between a dedicated server and a VPS will depend on the specific needs and resources of the individual or organization.

What is Git?

Git is an open-source, widely-used version control system for code repositories. Git used to safely make changes to their codebases, track those changes across time, and combine or even undo changes made If required.

Git is a version control system that allows you to track changes made to files while working on a project, either independently or in collaboration with others. It provides a way to save many different components of a project in progress, including the source code, but also the figures and data that the code produces. The importance of understanding and using Git lies in its ability to maintain an organized record of a project, also referred to as a repository or repo.

Github is where just about every developer out there stores his or her portfolio and it’s where your next job is likely to host their code as well.

  • Add/Commit All

One of the most common things you will do when working with Git is adding and committing a bunch of files at once. The standard way to do this is usually running an add command followed by a commit.

git add .
git commit -m “Message”

This works fine, but you can actually combine this into one command.

git commit -a -m “Message”

By using the -a flag when committing you are telling Git to add all files that have been modified and then commit them. This runs into issues with new files, though. Since the -a flag only adds modified files it will not add new files or deleted files. Unfortunately, you cannot use commit to add these types of files, but you can use the -A flag with add to add them all.

git add -A
git commit -m “Message”

By using this command you can now add all files even if they are new or deleted. You will also notice this command is very similar to the first git add . command. The only difference is that using -A will add all files within the repository while using the . will only add all files in the current folder your terminal is open to. This is why I always recommend using -A if you want to add all files in the repository.

  • Aliases

In the previous section we talked about how you can add and commit all files, but it requires two commands and is bulky to write out especially considering it is something you will be doing all the time. That is where Git aliases come in. With aliases you can write your own Git commands that do anything you want. Let’s take a look at how you would write an alias for the above add/commit command.

git config –global alias.ac ‘!git add -A && git commit -m’

With this simple line we are modifying our global Git config and adding an alias called ac which will run the command git add -A && git commit -m. The code looks a bit confusing, but the result is that I can now run git ac “Message” and it will do the full add and commit for me.

Now lets breakdown how this works. The first part of the command is git config –global. This just says we are modifying our global Git config since we want this alias to be available in any Git repository.

The next part is alias.ac. This says we want to create an alias called ac.

Finally, the last part is the full command !git add – A && git commit -m. This is just our normal Git command, but we have prefixed the command with an exclamation point. The reason for this is that a Git alias by default assumes that you will be calling one single git command, but we want to run a command that is more complex than a single Git command. By prefixing our command with an exclamation point Git will not assume we are running one simple command. To explain this further here is an example of creating an alias for git commit -a -m “Message”

git config –global alias.ac “commit -a -m”

As you can see we are just calling a single simple Git command so we can leave out the word git and since we have no exclamation point at the start of our command Git will assume that we are trying to call a single Git command and will add the git for us.

  • Revert

The last two commands have been pretty complex so let’s look at a really simple command. The revert command simply allows us to undo any commit on the current branch.

git revert 486bdb2

All you need to do is pass the commit you want to revert to the command and it will undo all changes from that commit. One important thing to note, though, is that this only undoes changes from that exact commit. If you do a revert on a commit from a month ago it will not undo all changes made since that commit. It will only undo the changes in that exact commit.

Another important thing to note is that using revert does not actually remove the old commit. Instead it creates a new commit that undoes all the changes from the old commit. This is good since it will preserve the history of your repository.

One common trick is to revert the most recent commit which can be done with the following command

git revert HEAD

  • Reflog

Another simple, but useful command is reflog. This command lets you easily see the recent commits, pulls, resets, pushes, etc on your local machine. This is a great way to track down any issues that may have come up to see what you did to cause those issues.

git reflog

Reflog Output

  • Pretty Logs

Another useful logging command in Git is the log command. This command combined with some special flags gives you the ability to print out a pretty log of your commits/branches.

git log –graph –decorate –oneline

Log Output

  • Searching Logs

You can also use the log command to search for specific changes in the code. For example you can search for the text A promise in JavaScript is very similar as follows.

git log -S “A promise in JavaScript is very similar”

This command returns to me the commit where I added the article on JavaScript promises since that is the commit where I added this text.

  • Stash

How many times have you been working on a feature when an urgent bug report comes in and you have to put all your current code on hold. It is very tempting to do a simple add/commit with a WIP message so you can switch branches to the main branch before fixing the bug, but this clogs up the commit history and is not ideal. Instead, the best thing you can do is use a stash.

git stash

This simple command will stash all your code changes, but does not actually commit them. Instead it stores them locally on your computer inside a stash which can be accessed later. Now you can go about fixing the urgent bug and once you are done with that you can pop your changes from the stash to continue working.

git stash pop

This command will take all the changes from the stash and apply them to your current branch and also remove the code from the stash. This is the ideal workflow if you need to quickly stop working on your current code to start working on something more urgent.
8. Remove Dead Branches

If you are working on any decent sized project odds are your repository has tens or hundreds of branches from previous pull requests. Most of these branches have probably been merged already and are deleted from the remote repository, but they are still on your local machine. This can get annoying when you have hundreds of dead branches on your machine which is where this command comes in.

git remote update –prune

This command will delete all the tracking information for branches that are on your local machine that are not in the remote repository, but it does not delete your local branches. In order to do that you need to run a bit of a tricky command.

git branch -vv | awk “/: gone]/{print $1}” | xargs git branch -d

This command will list out all of your branches and then search for any branches that have the remote tracking set to gone. This gone status is set from the previous command where we removed the tracking information for branches that no longer exist in the remote repository. Then we are grabbing the branch name for the deleted branch with the {print $1} command and passing that to git branch -d which will delete the branch for that name.

This is a pretty complex command which is why I recommend combining the previous two commands into one simple git alias that can do all this for you.

git config –global alias.prune ‘git remote update –prune && git branch -vv | awk “/: gone]/{print $1}” | xargs git branch -d’

  • Bisect

The bisect command in Git is incredible for finding which commits caused certain bugs. It is very common for a repository to have thousands of commits from hundreds of developers so when a bug report comes in it can be tricky to track down which changes caused this issue. With bisect, though, this problem is trivial. In order to understand why this command is so amazing let’s look at how to use it.

git bisect start
git bisect bad
git bisect good 48c86d6

To start a bisect you need to run three commands. The first command starts the bisect. The second command tells Git which commit is the bad commit with the bug. If you leave this blank, as we have, Git will just use the latest commit. The final command tells Git which commit is known to not have this bug. In our example, we know that in commit 48c86d6 there is no bug.

Now after you run these three commands Git will choose the commit in the middle of these two commits and grab all the code from that commit. You can then test to see if the bug is in this commit or not. If the bug is present you just type git bisect bad and it will select the commit that is halfway between this bad commit and the last good commit. If the bug is not present then you can type git bisect good and Git will select the commit that is halfway between this good commit and the last bad commit. You keep repeating this process of typing either good or bad until eventually, you are able to narrow it down to the exact commit that caused the bug.

This is amazing at narrowing down your bug search since some bugs can be really hard to track down without knowing what code was changed to cause it.

  • Destroy Local Changes

Sometimes you make changes and realize that you need to scrap everything you have done so far. This usually isn’t a big deal if you haven’t committed yet, but if you have made multiple commits it can be hard to exactly remove all changes. This is where the reset command comes in. By running the below command you can wipe out all changes on your local branch to exactly what is in the remote branch.

git reset –hard origin/main

The above command says to forcefully delete all local changes on your current branch and replace them with the code from the main branch in the remote. It is important to note that this will remove all local changes you have made so only do this if you really want to delete all the changes you have made and need to start fresh.

Download and install the latest version of Git.