Upgrade / Elevate CentOS 7 to AlmaLinux 8

Posted on

Upgrade / Elevate CentOS 7 to AlmaLinux 8

Upgrade / Elevate CentOS 7 to AlmaLinux 8

As CentOS 7 approaches its end of life (EOL), migrating to a new, stable Linux distribution becomes increasingly important. AlmaLinux, a community-driven open-source fork of Red Hat Enterprise Linux (RHEL), is a popular replacement, offering long-term support and seamless compatibility with CentOS. In this tutorial, we will walk you through the steps to upgrade CentOS 7 to AlmaLinux 8 using the ELevate tool, ensuring a smooth transition and continued security updates for your system.

Introduction: Why Upgrade to AlmaLinux 8?

CentOS 7’s end of life in June 2024 signals the end of regular updates, patches, and security fixes. Without these, your system becomes vulnerable to security risks and incompatibilities. AlmaLinux 8, as a direct replacement, provides continued support, security updates, and long-term viability.

Alma Linux is binary-compatible with RHEL, which means that you can continue using the same tools, applications, and workflows without any major changes after migrating. AlmaLinux 8 provides support until at least 2029, making it a great choice for enterprises and individual users alike. The need to Upgrade / Elevate CentOS 7 to AlmaLinux 8 is paramount for continued security.

Key considerations before upgrading

Before starting the upgrade process from CentOS 7 to AlmaLinux 8, there are some critical preparatory steps you should follow to ensure the process is smooth and successful.

Backup your data

Upgrading an operating system always carries some level of risk, including potential data loss. Therefore, it’s crucial to create a complete backup of your system, including databases, application data, and configuration files. Tools such as rsync, tar, or Bacula can be used for backups, or you can use cloud backup solutions like Rclone.

Review installed packages

Some packages installed on CentOS 7 may not have direct equivalents in AlmaLinux 8. You should review the currently installed packages and identify which ones might be affected by the upgrade.

List all installed packages using the command:

$ sudo rpm -qa

This will allow you to identify software that may need updates or alternative versions in AlmaLinux 8.

System Requirements

Ensure your system meets the basic hardware requirements for AlmaLinux 8:

  • Minimum RAM: 2GB
  • Minimum CPU: 2 Core
  • Minimum Disk Space: 20GB

Step-by-Step Guide: How to upgrade CentOS 7 to AlmaLinux 8

AlmaLinux provides the ELevate tool to handle the migration from CentOS 7 to AlmaLinux 8. This tool simplifies the migration process, allowing for in-place upgrades without needing to reinstall your system.

Step 1: Update Your CentOS 7 System

Before migrating, it’s important to update CentOS 7 to the latest available versions of packages. However, since CentOS 7 repositories are no longer active, you will need to swap to the CentOS vault, or use AlmaLinux’s mirror.

To switch to the AlmaLinux CentOS 7 mirror, run:

$ sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://el7.repo.almalinux.org/centos/CentOS-Base.repo
$  sudo curl https://repo.almalinux.org/elevate/el7/elevate.repo -o /etc/yum.repos.d/elevate.repo

Now, upgrade the system with the latest updates:

$ sudo yum upgrade -y
$ sudo reboot

Step 2: Install the ELevate Tool

After updating CentOS 7, the next step is to install the ELevate tool, which facilitates the migration process. This tool handles the transition between CentOS and AlmaLinux without needing to perform a fresh install.

First, install the elevate-release package, which contains the repository and GPG key for ELevate:

$ sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpm

Now, install the necessary leapp packages, which are used to manage the upgrade and handle AlmaLinux as the target OS:

$ sudo yum install -y leapp-upgrade leapp-data-almalinux

Step 3: Perform a Pre-Upgrade Check

The pre-upgrade check allows you to identify potential issues that could block the upgrade process. The leapp utility performs this check and generates a detailed report of any problems, including potential blockers. No packages are installed at this stage, ensuring that your system remains unchanged until you address the issues.

Run the pre-upgrade check using the following command:

$ sudo leapp preupgrade

The leapp utility will generate a report located at /var/log/leapp/leapp-report.txt. It’s essential to review this report thoroughly. The report contains a summary of potential issues along with recommended solutions.

Step 4: Address Pre-Upgrade Issues

In many cases, the pre-upgrade check will highlight issues that must be addressed before proceeding. These are often related to hardware drivers, configuration settings, or unsupported packages.

Some of the most common fixes for CentOS 7 include:

  • Removing problematic kernel modules:
$ sudo rmmod pata_acpi
  • Enabling Root Login in SSH:
$ echo PermitRootLogin yes | sudo tee -a /etc/ssh/sshd_config
  • Confirm removal of pam_pkcs11 module:
$ sudo leapp answer --section remove_pam_pkcs11_module_check.confirm=True

For more common issues, refer to the ELevate Frequent Issues page, which contains guidance on solving frequent problems.

Step 5: Start the Upgrade Process

Once the pre-upgrade issues are resolved, you can start the actual upgrade process. This step involves downloading and installing the necessary packages to upgrade CentOS 7 to AlmaLinux 8.

Run the following command to start the upgrade:

$ sudo leapp upgrade

The leapp utility will begin downloading the necessary AlmaLinux 8 packages and initiate the upgrade process. This may take some time, depending on your system’s performance and internet speed.

Step 6: Reboot into ELevate-Upgrade-Initramfs

Once the upgrade process completes, you will be prompted to reboot the system. Upon rebooting, the system will automatically boot into a new entry in GRUB called ELevate-Upgrade-Initramfs.

Reboot the system using:

$ sudo reboot

During this phase, the system will apply the upgrade changes. You can monitor the progress directly in the console. Your system will reboot automatically after the upgrade is complete.

Step 7: Verify the Upgrade

Once the system reboots after the upgrade, it’s essential to verify that the system is now running AlmaLinux 8. Use the following commands to check the OS version:

$ cat /etc/redhat-release
$ cat /etc/os-release

You should see output confirming that the system is running AlmaLinux 8.

Additionally, check the list of packages that were left from CentOS 7 by running:

$ rpm -qa | grep el7

You can also check the log files for any issues during the upgrade:

$ cat /var/log/leapp/leapp-report.txt
$ cat /var/log/leapp/leapp-upgrade.log

If there are any remaining CentOS 7 packages or configurations, you can remove or update them manually.

Post-Migration Steps

After upgrading to AlmaLinux 8, there are several post-migration steps to ensure that your system continues running smoothly.

Reinstall and Reconfigure Applications

Some applications may require reinstallation or reconfiguration after upgrading to AlmaLinux 8. Use dnf, the package manager for AlmaLinux 8, to install and manage packages. For example, to reinstall a package, use:

$ sudo dnf install <package_name>

Apply Regular System Updates

It’s crucial to keep your system updated with the latest security patches and package updates. Use the following command to update your AlmaLinux 8 system regularly:

$ sudo dnf update -y

Review Security Settings

After any major system upgrade, review your security configurations. Ensure that SELinux is enabled and configured correctly:

$ sestatus

Additionally, review your firewall settings and verify that services like firewalld or iptables are running as expected.

Performance Monitoring

Use performance monitoring tools like top, htop, or nmon to monitor system performance and resource usage. This will help you ensure that your upgraded system is running efficiently and can handle its workload.


Conclusion

Upgrading from CentOS 7 to AlmaLinux 8 is a necessary step for anyone looking to maintain a secure and stable server environment beyond CentOS 7’s end of life. Using the ELevate tool simplifies the process, allowing for an in-place upgrade without the need to reinstall your system or lose data. By following the steps outlined in this guide, you can ensure a smooth transition and enjoy continued support and updates from AlmaLinux. The process to Upgrade / Elevate CentOS 7 to AlmaLinux 8 requires careful planning and execution.

Alternative Solutions for Migrating from CentOS 7

While the ELevate tool offers a convenient in-place upgrade path, other options exist for migrating from CentOS 7. These alternatives might be more suitable depending on your specific needs, infrastructure, and risk tolerance.

1. Fresh Installation and Data Migration

This method involves installing AlmaLinux 8 on a new server or virtual machine and then migrating your data and configurations. This approach is generally considered safer than an in-place upgrade, as it minimizes the risk of encountering unexpected issues during the upgrade process.

Explanation:

  • Clean Slate: A fresh installation provides a clean environment, eliminating potential conflicts arising from legacy configurations or outdated packages.
  • Controlled Migration: You have complete control over which data and configurations are migrated, allowing you to optimize the new system and discard unnecessary elements.
  • Reduced Downtime: By setting up the new system in parallel, you can minimize downtime by switching over once the migration is complete and thoroughly tested.

Steps:

  1. Provision a New Server/VM: Create a new instance with AlmaLinux 8 installed. Ensure it meets the necessary system requirements.
  2. Install Required Software: Install the applications and services needed on the new server (e.g., web server, database server).
  3. Migrate Data: Use tools like rsync, scp, or tar to transfer your data from the CentOS 7 server to the AlmaLinux 8 server. For databases, use appropriate database migration tools (e.g., mysqldump for MySQL).
  4. Configure Applications: Reconfigure your applications to use the new server’s IP address, database credentials, and other settings.
  5. Test Thoroughly: Test all applications and services to ensure they function correctly on the new AlmaLinux 8 server.
  6. Switch Over: Update DNS records or load balancer configurations to point to the new server.
  7. Decommission CentOS 7 Server: Once you’re confident that the new server is working correctly, decommission the old CentOS 7 server.

Example (Data Migration using rsync):

# On the AlmaLinux 8 server:
sudo rsync -avz --progress user@centos7_server:/path/to/data /local/path/on/almalinux8

Considerations:

  • This method requires more manual effort compared to the ELevate tool.
  • You need sufficient resources to run both the old and new servers in parallel during the migration process.
  • Careful planning is essential to ensure a smooth and efficient data migration.

2. Containerization (Docker)

Another approach is to containerize your applications using Docker. This allows you to encapsulate your applications and their dependencies into portable containers, which can then be easily deployed on AlmaLinux 8.

Explanation:

  • Application Isolation: Docker containers isolate applications from the underlying operating system, reducing the risk of conflicts and ensuring consistent behavior across different environments.
  • Portability: Containers can be easily moved between different servers or cloud platforms without requiring significant modifications.
  • Simplified Deployment: Docker simplifies the deployment process by providing a standardized way to package and run applications.

Steps:

  1. Install Docker on CentOS 7: Follow the Docker documentation to install Docker on your CentOS 7 server.
  2. Create Docker Images: Create Docker images for your applications, specifying the necessary dependencies and configurations. This involves creating Dockerfiles.
  3. Test Docker Images on CentOS 7: Ensure that the created Docker images work correctly on the CentOS 7 server.
  4. Install Docker on AlmaLinux 8: Install Docker on the new AlmaLinux 8 server.
  5. Deploy Docker Containers: Deploy the Docker containers on the AlmaLinux 8 server using docker run.
  6. Configure Networking and Storage: Configure networking and storage for the containers as needed.
  7. Test Thoroughly: Test all applications and services running in the containers to ensure they function correctly on the AlmaLinux 8 server.
  8. Decommission CentOS 7 Server: Once you’re confident that the containers are working correctly, decommission the old CentOS 7 server.

Example (Dockerfile):

FROM centos:7

# Install necessary dependencies
RUN yum update -y && 
    yum install -y httpd php php-mysql mysql-server

# Copy application files
COPY . /var/www/html/

# Configure Apache
RUN echo "ServerName localhost" >> /etc/httpd/conf/httpd.conf

# Start Apache and MySQL
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]

Building and running the docker image:

docker build -t my-app .
docker run -d -p 80:80 my-app

Considerations:

  • This method requires familiarity with Docker and containerization concepts.
  • You may need to adjust your application architecture to be container-friendly.
  • Containerization can add overhead, so it’s important to optimize your Docker images for performance.

Choosing the right migration strategy depends on your specific requirements, technical expertise, and risk tolerance. Evaluate each option carefully to determine the best approach for your environment. Upgrade / Elevate CentOS 7 to AlmaLinux 8 can be achieved via these methods. Finally, remember to always backup your data before undertaking any major system changes.