• Skip to secondary menu
  • Skip to main content
  • Skip to primary sidebar
  • Home
  • Projects
  • Products
  • Themes
  • Tools
  • Request for Quote

Vengala Vinay

Having 12+ Years of Experience in Software Development

  • Home
  • WordPress
  • PHP
    • Codeigniter
  • Django
  • Magento
  • Selenium
  • Server
Home » Upgrading Rocky Linux 8 to Rocky Linux 9: Safely Migrating Legacy C++ REST Daemon Environments

Upgrading Rocky Linux 8 to Rocky Linux 9: Safely Migrating Legacy C++ REST Daemon Environments

Pre-Upgrade Assessment and Preparation

Before embarking on the upgrade from Rocky Linux 8 to Rocky Linux 9, a thorough assessment of the existing environment is paramount. This is particularly critical for legacy C++ REST daemon environments, which may rely on specific library versions, compiler flags, or system configurations that are not directly compatible with the newer distribution. The primary goal is to identify potential friction points and mitigate them proactively.

Begin by cataloging all installed packages, especially those directly related to your C++ daemon’s build and runtime dependencies. This includes compilers (GCC, Clang), build tools (CMake, Make), libraries (OpenSSL, Boost, specific database connectors), and any custom-compiled binaries. Understanding the exact versions and their dependencies is key.

Next, analyze the daemon’s build process. Document all compiler flags, linker options, and preprocessor definitions used. Rocky Linux 9, being based on RHEL 9, will likely have updated versions of core development tools. For instance, GCC 11 is the default in Rocky Linux 9, compared to GCC 8 in Rocky Linux 8. This version jump can introduce subtle changes in language standard support, warning levels, and optimization behaviors.

Runtime dependencies are equally important. Identify all shared libraries the daemon links against. Tools like ldd can be invaluable here. Pay close attention to libraries that might have undergone significant API changes or deprecations between the versions shipped with Rocky Linux 8 and Rocky Linux 9. For example, changes in OpenSSL versions (1.1.1 in RL8 vs. 3.0 in RL9) can necessitate code modifications if specific APIs are used directly.

Configuration files for the daemon, its service manager (systemd), and any associated infrastructure (e.g., Nginx, HAProxy for load balancing, SELinux policies) must also be documented. Rocky Linux 9 introduces updated default configurations and potentially new security features that might impact existing setups.

In-Place Upgrade Strategy: The `dnf` Approach

Rocky Linux provides an in-place upgrade path using the dnf package manager. This is generally the most straightforward method, but it requires careful execution to minimize downtime and data loss.

Step 1: Backup Everything

Before initiating any upgrade process, a comprehensive backup of the entire system, including application data, configuration files, and critical system files, is non-negotiable. This can be achieved through various methods, such as filesystem snapshots, full disk imaging, or targeted backups of application directories and databases.

Step 2: Update Rocky Linux 8 to the Latest

Ensure your current Rocky Linux 8 system is fully up-to-date. This minimizes the number of changes the upgrade process needs to handle and reduces the risk of encountering known bugs in older packages.

sudo dnf update -y
sudo dnf upgrade -y

Step 3: Install the Distribution Synchronization Tool

The dnf-utils package provides the necessary tools for distribution synchronization.

sudo dnf install -y dnf-utils

Step 4: Perform the Distribution Upgrade

The dnf distro-sync command, when used with the appropriate repository configuration, will perform the in-place upgrade. First, you need to point dnf to the Rocky Linux 9 repositories. This is typically done by replacing the Rocky Linux 8 release files with their Rocky Linux 9 counterparts.

A common and robust method is to use the rocky-release-upgrade utility, which automates the repository switching and the subsequent upgrade process. If this utility is not present, manual repository file manipulation is required.

Method A: Using rocky-release-upgrade (Recommended)

sudo dnf install -y https://dl.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/rocky-release-upgrade-1.0-1.el9.noarch.rpm
sudo rocky-release-upgrade

This command will guide you through the process, prompting for confirmation and handling repository changes. It will then execute dnf distro-sync.

Method B: Manual Repository Switching (Advanced/Fallback)

If rocky-release-upgrade is not available or fails, you can manually switch repositories. This involves removing the Rocky 8 release package and installing the Rocky 9 release package.

sudo dnf remove -y rocky-release
sudo dnf install -y https://dl.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/rocky-release-9.x-x.el9.noarch.rpm
sudo dnf distro-sync -y

The distro-sync command will resolve dependencies and upgrade all packages to their Rocky Linux 9 equivalents. This is the most critical and potentially disruptive step.

Step 5: Reboot and Verify

After the upgrade process completes, a system reboot is essential to load the new kernel and system services.

sudo reboot

Upon reboot, verify the operating system version:

cat /etc/redhat-release

And check the kernel version:

uname -r

Post-Upgrade C++ Daemon Environment Validation

The in-place upgrade is only the first phase. The true test lies in validating the functionality and performance of your legacy C++ REST daemon in the new Rocky Linux 9 environment. This phase requires meticulous testing and potential remediation.

Step 1: Rebuild and Test the C++ Daemon

The most robust approach is to rebuild your C++ daemon from source on the upgraded system. This ensures that it’s compiled against the new system libraries and toolchain. If you have a CI/CD pipeline, this is the ideal time to run it.

Example Build Process (using CMake):

# Navigate to your project's source directory
cd /path/to/your/cpp/daemon/source

# Clean previous build artifacts if any
rm -rf build

# Create a new build directory
mkdir build
cd build

# Configure the build. Adjust paths and options as necessary.
# Pay close attention to compiler flags and library paths.
cmake .. -DCMAKE_BUILD_TYPE=Release \
         -DCMAKE_INSTALL_PREFIX=/opt/your_daemon \
         -DBOOST_ROOT=/usr/lib64/boost \
         -DOPENSSL_ROOT_DIR=/usr/lib64/openssl

# Compile the daemon
make -j$(nproc)

# Install the daemon (if applicable)
sudo make install

During the build process, watch for any compilation errors or warnings. These are strong indicators of API incompatibilities or deprecated features in the new libraries or compiler. Address these errors by updating your C++ code.

Step 2: Dependency Verification and Resolution

After a successful build, verify that the installed daemon links against the correct libraries in the Rocky Linux 9 environment.

ldd /opt/your_daemon/bin/your_daemon_executable

Compare the output with the ldd output from the Rocky Linux 8 system. Ensure that the paths to shared libraries are consistent with the new system’s library locations (e.g., /usr/lib64/). If you encounter missing libraries or incorrect paths, you may need to:

  • Install missing development packages (e.g., sudo dnf install openssl-devel boost-devel ...).
  • Adjust linker paths in your build system (e.g., CMAKE_INSTALL_RPATH in CMake).
  • Update your C++ code to use newer, compatible APIs.

Step 3: Systemd Service File Review

Systemd service files might need adjustments due to changes in default paths, user/group management, or security contexts. Review your daemon’s .service file located in /etc/systemd/system/ or /usr/lib/systemd/system/.

[Unit]
Description=My C++ REST Daemon
After=network.target

[Service]
Type=simple
User=your_daemon_user
Group=your_daemon_group
WorkingDirectory=/opt/your_daemon/
ExecStart=/opt/your_daemon/bin/your_daemon_executable --config /etc/your_daemon/config.conf
Restart=on-failure
# Consider adding new security directives if applicable
# e.g., CapabilityBoundingSet, AmbientCapabilities, etc.

[Install]
WantedBy=multi-user.target

Ensure that User, Group, WorkingDirectory, and ExecStart paths are correct for the new installation. Reload systemd after any changes:

sudo systemctl daemon-reload

Step 4: Configuration File Validation

Your daemon’s configuration files (e.g., /etc/your_daemon/config.conf) might reference paths or settings that are no longer valid or have changed defaults in Rocky Linux 9. Carefully review these files for any hardcoded paths, library locations, or specific system calls that might be affected by the OS upgrade.

Step 5: Network and Firewall Configuration

Verify that network interfaces are configured correctly and that the firewall (firewalld) allows traffic to your daemon’s listening ports. Rocky Linux 9 may have updated default firewall rules or zones.

# Check active zones and rules
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-all --zone=public # Or your relevant zone

# If your daemon listens on port 8080
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --reload

Step 6: SELinux Contexts and Policies

SELinux is a critical security component. If SELinux was enforcing on Rocky Linux 8, it will be on Rocky Linux 9. The upgrade process generally preserves existing contexts, but it’s prudent to check, especially if you encounter permission denied errors.

Check the SELinux context of your daemon’s executable and its data directories:

ls -Z /opt/your_daemon/bin/your_daemon_executable
ls -Zd /opt/your_daemon/data

If you encounter SELinux-related denials, use audit2allow to generate custom policies or use chcon to temporarily set correct contexts for testing. For persistent changes, consider using semanage fcontext.

# Example: If your daemon needs to write to /var/log/your_daemon
# Check current context
ls -Zd /var/log/your_daemon

# If incorrect, generate a policy or use semanage
# sudo audit2allow -a -M mydaemon_log_policy
# sudo semodule -i mydaemon_log_policy.pp

# Or using semanage for persistent context
# sudo semanage fcontext -a -t your_daemon_log_t "/var/log/your_daemon(/.*)?"
# sudo restorecon -Rv /var/log/your_daemon

Step 7: Performance and Load Testing

Once the daemon is running and appears functional, conduct thorough performance and load testing. Compare metrics against baseline performance on Rocky Linux 8. Pay attention to CPU usage, memory consumption, network latency, and response times under various load conditions. Newer library versions or compiler optimizations might subtly alter performance characteristics.

Rollback Strategy and Considerations

Despite meticulous planning, an in-place upgrade can sometimes lead to unforeseen issues. A well-defined rollback strategy is crucial for minimizing business impact.

1. Pre-Upgrade Snapshots

The most effective rollback mechanism relies on having reliable, tested backups or snapshots taken immediately before the upgrade process begins. This includes:

  • Full filesystem snapshots (e.g., using LVM, ZFS, or cloud provider snapshots).
  • Database backups.
  • Application configuration backups.

2. Reverting Repository Changes

If the upgrade process itself is the issue (e.g., dnf distro-sync fails catastrophically), the immediate rollback would involve reverting the repository configurations back to Rocky Linux 8 and attempting to downgrade packages. This is a complex and often error-prone process.

# This is a highly simplified and potentially dangerous operation.
# It's generally safer to restore from backup.

# Attempt to revert to RL8 repositories (requires manual intervention or specific scripts)
# Then attempt to downgrade packages:
# sudo dnf downgrade $(rpm -qa --qf '%{NAME}\n' | grep -v 'rocky-release-upgrade')
# sudo dnf distro-sync -y # This might be needed to reconcile versions

Recommendation: Instead of attempting a package downgrade, restoring from a pre-upgrade snapshot is the preferred and safer method for a full system rollback.

3. Application-Level Rollback

If the OS upgrade is successful but the C++ daemon fails to run correctly, and rebuilding/fixing the daemon is proving difficult, you might consider rolling back only the application. This involves:

  • Stopping the faulty daemon instance on Rocky Linux 9.
  • Restoring the daemon’s executable and configuration files from backup.
  • Potentially reverting the system back to Rocky Linux 8 if the application cannot be made compatible with Rocky Linux 9.

4. Downtime Considerations

The rollback process, especially a full system restore, will incur significant downtime. Factor this into your maintenance window planning. For critical services, consider a blue-green deployment strategy or a phased rollout to minimize the impact of a failed upgrade.

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

A little about the Author

Having 12+ Years of Experience in Software Development, Vinay is a principal software architect, senior systems engineer, and elite technical consultant. He specializes in bespoke PHP/WordPress development, high-performance Magento 2 & Shopify architectures, custom plugin/theme development from scratch, and legacy code modernization (including VB6, VB.NET, PyQt, and Crystal Reports). Known for solving complex database bottlenecks, speed optimization (Core Web Vitals), and advanced security code auditing, Vinay engineers production-ready systems designed to scale under heavy concurrent load conditions.



Chat on WhatsApp

Recent Posts

  • Debugging Guide: Diagnosing PHP-FPM child process pool exhaustion in multi-site network environments with modern tools
  • Debugging and Resolving complex namespace class loading collisions issues during heavy concurrent database traffic
  • Step-by-Step Guide: Offloading high-frequency customer support tickets metadata writes to a Redis KV store
  • How to refactor legacy event ticket registers queries using modern WP_Query and custom Transient caching
  • Step-by-Step Guide: Offloading high-frequency member profile directories metadata writes to a Redis KV store

Categories

  • apache (1)
  • Business & Monetization (390)
  • Centos (4)
  • Comparisons & Decision Making (55)
  • Debian (2)
  • Debugging & Troubleshooting (662)
  • Desktop Applications (14)
  • DevOps (7)
  • DevOps & Cloud Scaling (962)
  • Django (1)
  • Laravel (4)
  • Migration & Architecture (192)
  • Mobile Applications (24)
  • MySQL (1)
  • Performance & Optimization (873)
  • PHP (5)
  • PHP Development (49)
  • Plugins & Themes (244)
  • Programming Languages (9)
  • Python (20)
  • Ruby on Rails (1)
  • Security & Compliance (647)
  • SEO & Growth (492)
  • Server (118)
  • Ubuntu (9)
  • VB6 & VB.NET (8)
  • Web Applications & Frontend (19)
  • Web Assembly (Wasm) (2)
  • WordPress (22)
  • WordPress Plugin Development (726)
  • WordPress Theme Development (357)

Recent Posts

  • Debugging Guide: Diagnosing PHP-FPM child process pool exhaustion in multi-site network environments with modern tools
  • Debugging and Resolving complex namespace class loading collisions issues during heavy concurrent database traffic
  • Step-by-Step Guide: Offloading high-frequency customer support tickets metadata writes to a Redis KV store

Top Categories

  • DevOps & Cloud Scaling (962)
  • Performance & Optimization (873)
  • WordPress Plugin Development (726)
  • Debugging & Troubleshooting (662)
  • Security & Compliance (647)
  • SEO & Growth (492)

Our Products

  • ERP & LMS Systems (4)
  • Directories & Marketplaces (4)
  • Healthcare Portals (3)
  • Point of Sale (POS) (2)
  • E-Commerce Engines (2)

Our Services

  • E-Commerce Development (10)
  • WordPress Development (8)
  • Python & Desktop GUI (7)
  • General Consulting (7)
  • Legacy Modernization (5)
  • Mobile App Development (4)

Copyright © 2026 · Vinay Vengala