I tried upgrading from CentOS 6.5 to CentOS 7 with the upgrade tool

background

Support for CentOS 6 series ended on November 30, 2020. I decided to upgrade the version in a running project, and there was a CentOS Upgrade Tool, so I tried it.

Note!

You can see it by transitioning from the above link. .. .. ** It says "Currently unavailable" **.

It seems that if you have CentOS 6.7 or above, some software packages may have a higher version than the same CentOS 7 package, and you may not be able to update normally.

Please be careful if you have something to try. .. ..

Of course, I think the straightforward method is to create a new server on CentOS 7 (8 ... I'll leave it), add the necessary software packages, and migrate the data. However, due to adult circumstances (?) Such as budget and schedule, we have to upgrade the server with the same server. .. .. In that case, I thought it would be good to know that there is an upgrade tool.

Upgrade flow

  1. Install the upgrade tool
  2. Run the upgrade verification tool
  3. Confirmation and response of verification results
  4. Run the upgrade tool
  5. Restart CentOS
  6. Confirmation of version upgrade

Upgrade!

Let's proceed according to the above flow! Don't forget to ** make a backup ** before you start. .. ..

1. Install the upgrade tool

Add a repository to yum.repos.d to install the upgrade tools.

# vi /etc/yum.repos.d/upgradetool.repo

(Create New)
[upg]
name=CentOS-$releasever - Upgrade Tool
baseurl=https://buildlogs.centos.org/centos/6/upg/x86_64/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Install it.

# yum install redhat-upgrade-tool preupgrade-assistant-contents
Loaded plugins: fastestmirror, presto
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

error. .. .. CentOS 6 seems to have been removed from the mirrorlist server as it was no longer supported on November 30, 2020. Comment out the mirrorlist line with the following settings and add the baseurl. (Change the [updates] and [extras] settings as needed.)

# cp -p /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bu

# vi /etc/yum.repos.d/CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os (* ← comment out)
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
baseurl=http://vault.centos.org/6.5/os/$basearch/(* ← added)

Install again.

# yum install redhat-upgrade-tool preupgrade-assistant-contents
Loaded plugins: fastestmirror, presto
Determining fastest mirrors
base                                         | 3.7 kB     00:00
Not using downloaded repomd.xml because it is older than what we have:
  Current   : Fri Oct 24 22:59:03 2014
  Downloaded: Thu Nov 28 07:08:25 2013
extras                                       | 2.9 kB     00:00
Not using downloaded repomd.xml because it is older than what we have:
  Current   : Thu May 21 00:34:00 2015
  Downloaded: Fri Nov  7 01:15:00 2014
updates                                      | 2.9 kB     00:00
Not using downloaded repomd.xml because it is older than what we have:
  Current   : Thu Jul  2 21:22:31 2015
  Downloaded: Fri Nov  7 01:20:59 2014

(Omitted in the middle ...)

Error Downloading Packages:
  libxml2-2.7.6-17.el6_6.1.x86_64: failure: Packages/libxml2-2.7.6-17.el6_6.1.x86_64.rpm from updates: [Errno 256] No more mirrors to try.
  openscap-1.0.8-1.0.1.el6.centos.1.x86_64: failure: Packages/openscap-1.0.8-1.0.1.el6.centos.1.x86_64.rpm from base: [Errno 256] No more mirrors to try.
  yum-3.2.29-60.el6.centos.noarch: failure: Packages/yum-3.2.29-60.el6.centos.noarch.rpm from base: [Errno 256] No more mirrors to try.
  libxml2-devel-2.7.6-17.el6_6.1.x86_64: failure: Packages/libxml2-devel-2.7.6-17.el6_6.1.x86_64.rpm from updates: [Errno 256] No more mirrors to try.

Also an error. .. .. It seems that the latest one downloaded when browsing the repository is said to be old.

Save the yum cache you are currently holding.

# mv /var/cache/yum/x86_64 /tmp/

Install it again.

# yum install redhat-upgrade-tool preupgrade-assistant-contents
Loaded plugins: fastestmirror, presto
Determining fastest mirrors
base                              | 3.7 kB     00:00
base/primary_db                   | 4.4 MB     00:03
extras                            | 2.9 kB     00:00
extras/primary_db                 |  19 kB     00:00
updates                           | 2.9 kB     00:00
updates/primary_db                | 5.9 MB     00:03
upg                               | 1.9 kB     00:00
upg/primary_db                    |  14 kB     00:00

(Omitted in the middle ...)

Installed:
  preupgrade-assistant-contents.noarch 0:0.5.14-1.el6.centos                                                                 redhat-upgrade-tool.noarch 1:0.7.22-3.el6.centos

Dependency Installed:
  libgcrypt-devel.x86_64 0:1.4.5-11.el6_4         libgpg-error-devel.x86_64 0:1.7-4.el6      libxml2-devel.x86_64 0:2.7.6-14.el6_5.2                    libxslt.x86_64 0:1.1.26-2.el6_3.1      libxslt-devel.x86_64 0:1.1.26-2.el6_3.1
  openscap.x86_64 0:1.0.8-1.0.1.el6.centos.1      pcre-devel.x86_64 0:7.8-6.el6              preupgrade-assistant.x86_64 0:1.0.2-36.0.1.el6.centos      zlib-devel.x86_64 0:1.2.3-29.el6

Dependency Updated:
  libxml2.x86_64 0:2.7.6-14.el6_5.2                                                                                     yum.noarch 0:3.2.29-43.el6.centos

Complete!

success! !! !!

2. Run the upgrade verification tool

Run the upgrade verification tool.

# preupg -s CentOS6_7
Preupg tool doesn't do the actual upgrade.
Please ensure you have backed up your system and/or data in the event of a failed upgrade
 that would require a full re-install of the system from installation media.
Do you want to continue? y/n
y
Gathering logs used by preupgrade assistant:

(Omitted in the middle ...)

Tarball with results is stored here /root/preupgrade-results/preupg_results-201214042319.tar.gz .
The latest assessment is stored in directory /root/preupgrade .
Summary information:
We found some potential in-place upgrade risks.
Read the file /root/preupgrade/result.html for more details.
Upload results to UI by command:
e.g. preupg -u http://127.0.0.1:8099/submit/ -r /root/preupgrade-results/preupg_results-*.tar.gz .

There was no particular problem and it ended normally!

3. Confirmation and response of verification results

The verification result is output to /root/preupgrade/result.html, and you are asked to read it, so check it.

We have detected that you are using SELinux.
There were changes in policies which require to apply custom command before upgrade process.
In order to have working SELinux on CentOS 7, you <b>HAVE TO</b> run command prior to running redhat-upgrade-tool:semodule -r sandbox

It says to run the following command before running the upgrade, so run it.

# semodule -r sandbox

4. Run the upgrade tool

At this point you are ready to upgrade. It's time to upgrade.

# redhat-upgrade-tool-cli --network 7 --cleanup-post --instrepo=http://vault.centos.org/centos/7.2.1511/os/x86_64/ --addrepo=CentOS7=http://mirror.centos.org/centos/7/os/x86_64/
setting up repos...
CentOS7                                                 | 3.6 kB     00:00
CentOS7/primary_db                                      | 6.1 MB     00:00
base                                                    | 3.7 kB     00:00
base/primary_db                                         | 4.4 MB     00:03
cmdline-instrepo                                        | 3.6 kB     00:00
cmdline-instrepo/primary_db                             | 5.3 MB     00:03
extras                                                  | 2.9 kB     00:00
extras/primary_db                                       |  19 kB     00:00
updates                                                 | 2.9 kB     00:00
updates/primary_db                                      | 5.9 MB     00:03
upg                                                     | 1.9 kB     00:00
upg/primary_db                                          |  14 kB     00:00
zabbix                                                  |  951 B     00:00
zabbix/primary                                          |  25 kB     00:00
zabbix-non-supported                                    |  951 B     00:00
zabbix-non-supported/primary                            | 3.8 kB     00:00
.treeinfo                                               | 1.1 kB     00:00
Preupgrade assistant risk check found risks for this upgrade.
You can run preupg --riskcheck --verbose to view these risks.
Addressing high risk issues is required before the in-place upgrade
and ignoring these risks may result in a broken upgrade and unsupported upgrade.
Please backup your data.

(Omitted in the middle ...)

testing upgrade transaction
rpm transaction 100% [========================================================]
rpm install 100% [========================================================]
setting up system for upgrade
Finished. Reboot to start upgrade.

success! !! !! !! !! !!

5. Restart CentOS

Reboot to apply CentOS 7. However, after rebooting, CentOS 7 will change the process startup method from service to systemctl, so sshd will not start. .. .. Set sshd to start after a reboot.

# vi /etc/rc.d/rc.local

(Added at the end)
systemctl enable sshd && systemctl start sshd.service

# chmod +x /etc/rc.d/rc.local

Restart!

# reboot

Broadcast message from hoge
	(/dev/pts/0) at 14:31 ...

The system is going down for reboot NOW!

6. Confirm upgrade

After rebooting, check the version of CentOS.

$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

It was CentOS 7 properly! !!

bonus

From here on, it's a project-specific story. If you have any related content, please.

Change time zone

By default, the time zone is set to UTC (Coordinated Universal Time), so I changed it to JST (Japan Standard Time).

# timedatectl set-timezone Asia/Tokyo
# date
Monday, December 14, 2020 14:38:04 JST

Automatic start of zabbix-agent

After the upgrade, zabbix-agent, which was automatically started, no longer starts automatically. .. .. It seems that zabbix directory is not created in / var/run / at startup. I have set the / var/run/zabbix directory to be created automatically at startup.

vi /etc/tmpfiles.d/zabbix.conf

(New addition)
#Type   Path                      Mode    UID       GID     Age  Argument
d       /var/run/zabbix           0755    zabbix    zabbix  -

NTP synchronization

After the version upgrade, the time synchronization process from the automatically started NTP service to another server is no longer possible. .. .. (It was a situation where synchronization could be achieved by manually stopping and starting the NTP service.)

Check the log when the NTP service starts.

■ At automatic startup
12 Oct 07:43:11 ntpd[332]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
12 Oct 07:43:11 ntpd[332]: Listen and drop on 1 v6wildcard :: UDP 123
12 Oct 07:43:11 ntpd[332]: Listen normally on 2 lo 127.0.0.1 UDP 123
12 Oct 07:43:11 ntpd[332]: Listen normally on 3 lo ::1 UDP 123
12 Oct 07:43:11 ntpd[332]: Listening on routing socket on fd #20 for interface updates
12 Oct 07:43:11 ntpd[332]: Deferring DNS for mta01 1
12 Oct 07:43:11 ntpd[332]: Deferring DNS for mta02 1
12 Oct 07:43:11 ntpd[332]: 0.0.0.0 c016 06 restart
12 Oct 07:43:11 ntpd[332]: 0.0.0.0 c012 02 freq_set ntpd 31.109 PPM
12 Oct 07:43:11 ntpd[338]: signal_no_reset: signal 17 had flags 4000000
12 Oct 07:43:13 ntpd[338]: host name not found: mta01
12 Oct 07:43:13 ntpd[338]: host name not found: mta02
12 Oct 07:43:17 ntpd[332]: Listen normally on 4 eth0 10.0.xxx.xxx UDP 123
12 Oct 07:43:17 ntpd[332]: Listen normally on 5 eth0 fe80::4d2:72ff:fede:783b UDP 123
12 Oct 07:43:17 ntpd[332]: new interface(s) found: waking up resolver

■ At manual startup
12 Oct 10:00:15 ntpd[2777]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
12 Oct 10:00:15 ntpd[2777]: Listen and drop on 1 v6wildcard :: UDP 123
12 Oct 10:00:15 ntpd[2777]: Listen normally on 2 lo 127.0.0.1 UDP 123
12 Oct 10:00:15 ntpd[2777]: Listen normally on 3 eth0 10.0.xxx.xxx UDP 123
12 Oct 10:00:15 ntpd[2777]: Listen normally on 4 lo ::1 UDP 123
12 Oct 10:00:15 ntpd[2777]: Listen normally on 5 eth0 fe80::4d2:72ff:fede:783b UDP 123
12 Oct 10:00:15 ntpd[2777]: Listening on routing socket on fd #22 for interface updates

Hmm. .. .. At the time of automatic startup, Deferring DNS for mta01 is output, so it seems that the server to be synchronized cannot be seen.

It seems that the recognition of eth0 is a little delayed at the time of automatic startup. Is this the cause? .. ..

Let's take a look at the settings in /usr/lib/systemd/system/ntpd.service.

# vi /usr/lib/systemd/system/ntpd.service
[Unit]
Description=Network Time Service
After=syslog.target ntpdate.service sntp.service

[Service]
Type=forking
EnvironmentFile=-/etc/sysconfig/ntpd
ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Add network.target to the After setting of [Unit].

# vi /usr/lib/systemd/system/ntpd.service
[Unit]
Description=Network Time Service
After=syslog.target network.target ntpdate.service sntp.service
↑ (Addition)

[Service]
Type=forking
EnvironmentFile=-/etc/sysconfig/ntpd
ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Reflect the changes.

# systemctl daemon-reload

The time synchronization process is now executed normally even during automatic startup.

14 Oct 18:31:40 ntpd[583]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
14 Oct 18:31:40 ntpd[583]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
14 Oct 18:31:40 ntpd[583]: Listen and drop on 1 v6wildcard :: UDP 123
14 Oct 18:31:40 ntpd[583]: Listen normally on 2 lo 127.0.0.1 UDP 123
14 Oct 18:31:40 ntpd[583]: Listen normally on 3 eth0 10.0.111.115 UDP 123
14 Oct 18:31:40 ntpd[583]: Listening on routing socket on fd #20 for interface updates

That's it.

Recommended Posts

I tried upgrading from CentOS 6.5 to CentOS 7 with the upgrade tool
[Rails] I tried to raise the Rails version from 5.0 to 5.2
I tried to get the distance from the address string to the nearest station with ruby
I tried to increase the processing speed with spiritual engineering
[JDBC] I tried to access the SQLite3 database from Java.
I tried to interact with Java
What I did in the version upgrade from Ruby 2.5.2 to 2.7.1
I tried to solve the problem of "multi-stage selection" with Ruby
I tried to build the environment of PlantUML Server with Docker
I tried to implement the image preview function with Rails / jQuery
I tried to check the operation of gRPC server with grpcurl
I tried to solve the paiza campaign problem "Challenge from Kaito 813"
I tried to summarize the methods used
I tried to get started with WebAssembly
I tried to implement the Iterator pattern
I tried to summarize the Stream API
I tried to build AdoptOpenjdk 11 on CentOS 7
I tried to build Ruby 3.0.0 from source
I tried to implement ModanShogi with Kinx
Follow from the root node to the lower node with JavaFX ~ I know the directions ~
[Ruby] I tried to diet the if statement code with the ternary operator
I tried to solve the tribonacci sequence problem in Ruby, with recursion.
I tried to visualize the access of Lambda → Athena with AWS X-Ray
I tried to measure and compare the speed of GraalVM with JMH
I tried to verify AdoptOpenJDK 11 (11.0.2) with Docker image
I tried to make Basic authentication with Java
I tried to manage struts configuration with Coggle
I tried to organize the session in Rails
I tried to develop a man-hour management tool
I want to play with Firestore from Rails
I tried to set tomcat to run the Servlet.
I tried to break a block with java (1)
I tried to compare the infrastructure technology of engineers these days with cooking.
I tried to automatically generate a class to convert from a data class to a Bundle with APT
[JDBC ③] I tried to input from the main method using placeholders and arguments.
I tried to make a program that searches for the target class from the process that is overloaded with Java
I tried what I wanted to try with Stream softly.
I tried to implement file upload with Spring MVC
I tried to organize the cases used in programming
[Java] I want to calculate the difference from the date
Tokoro I rewrote in the migration from Wicket 7 to 8
I tried to read and output CSV with Outsystems
I tried to implement TCP / IP + BIO with JAVA
[Java 11] I tried to execute Java without compiling with javac
I tried to summarize the state transition of docker
I tried to decorate the simple calendar a little
[Rails] I tried playing with the comment send button
05. I tried to stub the source of Spring Boot
I started MySQL 5.7 with docker-compose and tried to connect
I tried to reduce the capacity of Spring Boot
I tried to draw animation with Blazor + canvas API
I tried to implement the Euclidean algorithm in Java
I want to redirect sound from Ubuntu with xrdp
roman numerals (I tried to simplify it with hash)
I tried to summarize the points to consider when acquiring location information with the iOS application ③
[Beginner's point of view] I tried to solve the FizzBuzz problem "easily" with Ruby!
I called YouTube video from DB with haml and tried to embed and display it
I tried to summarize the points to consider when acquiring location information with the iOS application ①
I tried to summarize the points to consider when acquiring location information with the iOS application ②
I tried to make a product price comparison tool of Amazon around the world with Java, Amazon Product Advertising API, Currency API (2017/01/29)
I want to fetch another association of the parent model from the intermediate table with has_many