Como Migrar CentOS 7 para Oracle Linux 7

Todos sabemos das mudanças ocorridas com o CentOS, visando alternativas de migração, optei por migrar para Oracle Linux, além das funcionalidades implementadas pelo Oracle e a compatibilidade que o OL tem em relação ao CentOS/RHE, tenho utilizado OL por muitos anos como padrão em servidores Linux, segue abaixo uma forma simples de migrar de CentOS para OL.

Lembre-se de aprovar o processo em ambientes de teste ou tirar um instantâneo da máquina virtual antes da migração.

1- Verifique no mínimo 5GB de espaço em disco em /var/cache:

[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   45G  3.6G   42G   8% /
devtmpfs                 895M     0  895M   0% /dev
tmpfs                    911M     0  911M   0% /dev/shm
tmpfs                    911M   10M  901M   2% /run
tmpfs                    911M     0  911M   0% /sys/fs/cgroup
/dev/sda1               1014M  170M  845M  17% /boot
tmpfs                    183M     0  183M   0% /run/user/0
[root@localhost ~]#
ShellScript

2 – Check current kernel and version:

[root@localhost ~]# cat /etc/*-release | grep PRETTY
PRETTY_NAME="CentOS Linux 7 (Core)"
 
[root@localhost ~]# uname -r
3.10.0-1160.42.2.el7.x86_64
ShellScript

3 – List repositories and status:

[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determining fastest mirrors
 * base: mirror.globo.com
 * extras: mirror.turbozoneinternet.net.br
 * updates: mirror.turbozoneinternet.net.br
ShellScript

4 – All automatic updates, e.g. via yum-cron should be disabled:

[root@localhost ~]# systemctl status yum-cro
yum-cron.service - Run automatic yum updates as a cron job
   Loaded: loaded (/usr/lib/systemd/system/yum-cron.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sun 2021-03-07 14:35:54 -03; 8s ago
  Process: 1936 ExecStart=/bin/touch /var/lock/subsys/yum-cron (code=exited, status=0/SUCCESS)
 Main PID: 1936 (code=exited, status=0/SUCCESS)
 
Mar 07 14:35:54 localhost.localdomain systemd[1]: Starting Run automatic yum updates as a cron job...
Mar 07 14:35:54 localhost.localdomain systemd[1]: Started Run automatic yum updates as a cron job.
 
[root@localhost ~]# systemctl stop yum-cron.service
[root@localhost ~]# systemctl status yum-cron
yum-cron.service - Run automatic yum updates as a cron job
   Loaded: loaded (/usr/lib/systemd/system/yum-cron.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Sun 2021-03-07 14:36:43 -03; 21s ago
  Process: 1953 ExecStop=/bin/rm -f /var/lock/subsys/yum-cron (code=exited, status=0/SUCCESS)
  Process: 1936 ExecStart=/bin/touch /var/lock/subsys/yum-cron (code=exited, status=0/SUCCESS)
 Main PID: 1936 (code=exited, status=0/SUCCESS)
 
Mar 07 14:35:54 localhost.localdomain systemd[1]: Starting Run automatic yum updates as a cron job...
Mar 07 14:35:54 localhost.localdomain systemd[1]: Started Run automatic yum updates as a cron job.
Mar 07 14:36:43 localhost.localdomain systemd[1]: Stopping Run automatic yum updates as a cron job...
Mar 07 14:36:43 localhost.localdomain systemd[1]: Stopped Run automatic yum updates as a cron job.
 
 
[root@localhost ~]# systemctl disable yum-cron.service
Removed symlink /etc/systemd/system/multi-user.target.wants/yum-cron.service.
[root@localhost ~]#
ShellScript

5 – Clear cache yum:

[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
ShellScript

6 – Disable the repository permanently:

yum-config-manager --disable openlogic
ShellScript

7 – Currently installed kernel:

[root@localhost ~]# grubby --info=ALL | grep ^kernel
kernel=/boot/vmlinuz-3.10.0-862.el7.x86_64
kernel=/boot/vmlinuz-0-rescue-f55da80029b04c21acdb1b9cffba6d48
 
[root@localhost ~]# uname -r
5.4.17-2136.300.7.el7uek.x86_64
ShellScript

8 – Download/create script centos2ol.sh:

[root@localhost ~]# vi centos2ol.sh
[root@localhost ~]# chmod 775 centos2ol.sh
ShellScript

9 – Options for using the migration script:

Usage options
-r Reinstalls all CentOS RPMs with Oracle Linux RPMs
If a system is swiched to Oracle Linux and there is no newer Oracle Linux version of a package already installed then the CentOS version remains. This option proceeds to reinstall any CentOS RPM with an identical version from Oracle Linux. This is not necessary for support and has no impact to a systems functionality but is offered so a user can remove CentOS GPG keys from the truststore. A list of all non-Oracle RPMs will be displayed after the reinstall process.
-k Do not install the UEK kernel and disable UEK repos
This option will not install the UEK kernel and will disable all UEK yum repositories.
-V Verify RPM information before and after the switch
This option creates four output files in /var/tmp/:
 
${hostname}-rpms-list-[before|after].log: a sorted list of installed packages before and after the switch to Oracle Linux.
${hostname}-rpms-verified-[before|after].log: the RPM verification results for all installed packages before and after the switch to Oracle Linux.
ShellScript

10 – Running the migration script:

[root@localhost ~]# ./centos2ol.sh -r -V
Checking for required packages...
Checking your distribution...
Creating a list of RPMs installed before the switch
Verifying RPMs installed before the switch against RPM database
package epel-release is not installed
Checking for yum lock...
Checking for required python packages...
Finding your repository directory...
Learning which repositories are enabled...
Repositories enabled before update include:
base
extras
updates
ShellScript

11 – Final summary after the update:

Installed:
  kernel-uek.x86_64 0:5.4.17-2036.103.3.1.el7uek
 
Complete!
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.17-2036.103.3.1.el7uek.x86_64
Found initrd image: /boot/initramfs-5.4.17-2036.103.3.1.el7uek.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.15.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.15.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-862.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-f55da80029b04c21acdb1b9cffba6d48
Found initrd image: /boot/initramfs-0-rescue-f55da80029b04c21acdb1b9cffba6d48.img
done
Removing yum cache
Creating a list of RPMs installed after the switch
Verifying RPMs installed after the switch against RPM database
Review the output of following files:
/var/tmp/localhost.localdomain-rpms-list-before.log
/var/tmp/localhost.localdomain-rpms-verified-before.log
/var/tmp/localhost.localdomain-rpms-list-after.log
/var/tmp/localhost.localdomain-rpms-verified-after.log
Switch complete. Oracle recommends rebooting this system.
ShellScript

12 – Restart the server and validate the migration, kernel installed after the change:

[root@localhost ~]#  init 6
[root@localhost ~]# grubby --info=ALL | grep ^kernel
kernel=/boot/vmlinuz-5.4.17-2036.103.3.1.el7uek.x86_64
kernel=/boot/vmlinuz-3.10.0-1160.15.2.el7.x86_64
kernel=/boot/vmlinuz-3.10.0-862.el7.x86_64
kernel=/boot/vmlinuz-0-rescue-f55da80029b04c21acdb1b9cffba6d48 
ShellScript

13 – Next, use grubby to verify that UEK is currently the default boot option:

[root@localhost ~]# grubby --default-kernel
/boot/vmlinuz-5.4.17-2036.103.3.1.el7uek.x86_64
[root@localhost ~]#
ShellScript

14 – To replace the default kernel, you need to specify either the path to its vmlinuz file or its index. Use grubby to get that information for the replacement:

[root@localhost ~]# grubby --info /boot/vmlinuz-5.4.17-2036.103.3.1.el7uek.x86_64
index=0
kernel=/boot/vmlinuz-5.4.17-2036.103.3.1.el7uek.x86_64
args="ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
root=/dev/mapper/centos-root
initrd=/boot/initramfs-5.4.17-2036.103.3.1.el7uek.x86_64.img
title=Oracle Linux Server 7.9, with Unbreakable Enterprise Kernel 5.4.17-2036.103.3.1.el7uek.x86_64
ShellScript

15 – Final OS version:

[root@localhost ~]# cat /etc/*-release | grep PRETTY
PRETTY_NAME="Oracle Linux Server 7.9"
ShellScript

16 -After migration confirm that the default kernel is UEK, if not install the Oracle UEK kernel:

[root@localhost ~]# uname -r
3.10.0-1160.42.2.el7.x86_64
 
[root@localhost ~]# yum install kernel-uek -y
[root@localhost ~]# init 6
 
# Kernel UEK
[root@localhost ~]# uname -r
5.4.17-2136.300.7.el7uek.x86_64
ShellScript

17 – Disable non-Oracle Linux repositories:

[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * epel: d2lzkl7pfhq30w.cloudfront.net
repo id                                                                               repo name                                                                                                                                   status
epel/x86_64                                                                           Extra Packages for Enterprise Linux 7 - x86_64                                                                                              13,683
ol7_UEKR6/x86_64                                                                      Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 7Server (x86_64)                                                               456
ol7_latest/x86_64                                                                     Oracle Linux 7Server Latest (x86_64)                                                                                                        23,278
ol7_optional_latest/x86_64                                                            Oracle Linux 7Server Optional Latest (x86_64)                                                                                               16,543
repolist: 53,960
 
[root@localhost ~]# yum-config-manager --disable epel
 
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id                                                                               repo name                                                                                                                                   status
ol7_UEKR6/x86_64                                                                      Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 7Server (x86_64)                                                               456
ol7_latest/x86_64                                                                     Oracle Linux 7Server Latest (x86_64)                                                                                                        23,278
ol7_optional_latest/x86_64                                                            Oracle Linux 7Server Optional Latest (x86_64)                                                                                               16,543
repolist: 40,277
ShellScript

18 – Update the Operating System:

[root@localhost ~]# yum update
ShellScript

19 – Links:

https://www.oracle.com/br/linux/
https://blogs.oracle.com/scoter/switch-from-centos-to-oracle-linux-example
https://linux.oracle.com/switch/centos/
https://github.com/oracle/centos2ol
https://github.com/oracle/centos2ol/blob/main/centos2ol.sh
ShellScript

Leave a Reply

Your email address will not be published. Required fields are marked *

search previous next tag category expand menu location phone mail time cart zoom edit close