Có nhiều cách khác nhau để nâng cấp các ứng dụng và cơ sở dữ liệu dựa trên CentOS 7 của bạn lên CentOS 8. Ở đây, chúng tôi đang thực hiện nâng cấp tại chỗ máy chủ CentOS 7 hiện có với các ứng dụng và cơ sở dữ liệu đã cài đặt lên phiên bản mới nhất do máy chủ CentOS 8 cung cấp.
Vì bạn đang nâng cấp môi trường của mình từ CentOS 7 lên CentOS 8, do đó, bạn cũng nên nâng cấp bản thân và các tài nguyên kỹ thuật.
Với mục đích này, chúng tôi đặc biệt khuyên bạn nên đọc Hướng dẫn chứng nhận Red Hat RHCSA 8: EX200 (Hướng dẫn chứng nhận) của Chứng nhận CNTT Pearson.
Chúng tôi đang sử dụng một máy ảo được cấu hình là máy chủ CentOS 7 LAMP.
CPU - 3,4 Ghz (2 lõi)
Bộ nhớ - 2 GB
Lưu trữ - 20 GB
Hệ điều hành - CentOS 7.7
Tên máy chủ - centos-7-server.sysadminlabs.com
Địa chỉ IP - 192.168.116.215 / 24
Thu thập thông tin hệ thống của CentOS 7:
Kết nối với centos-7-server.sysadminlabs.com với tư cách là người dùng root bằng cách sử dụng công cụ ssh như PuTTY.
Bắt đầu thực hiện chúng ta phải vào và sửa file config /etc/ssh/sshd_config
cài đặt nano : root@centos-7-server ~]# sudo yum install nano
Sau đó tiến hành sửa file config
root@centos-7-server ~]# sudo nano /etc/ssh/sshd_config
PermitRootLogin yes
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no
Đối với centos7 tên người dùng là centos
Đối với Amazon Linux, tên người dùng là ec2-user.
Đối với RHEL 5, tên người dùng là root hoặc ec2-user.
Đối với Ubuntu, tên người dùng là ubfox.
Đối với SUSE Linux, tên người dùng là người dùng root hoặc ec2.
Kiểm tra phiên bản hiện tại của Linux Kernel.
root@centos-7-server ~]# uname -r
3.10.0-1062.7.1.el7.x86_64
Cài đặt kho lưu trữ EPEL yum trên CentOS 7:
Chúng tôi được yêu cầu một số gói có sẵn trong kho lưu trữ yum EPEL (Gói bổ sung cho Enterprise Linux).
Do đó, chúng tôi đang cài đặt gói phát hành epel để kích hoạt kho lưu trữ EPEL yum.
[root@centos-7-server ~]# yum install -y epel-release.noarch
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.ges.net.pk * extras: mirrors.ges.net.pk * updates: repo.isra.edu.pk Resolving Dependencies -- Running transaction check --- Package epel-release.noarch 0:7-11 will be installed -- Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: epel-release noarch 7-11 extras 15 k Transaction Summary ================================================================================ Install 1 Package Total download size: 15 k Installed size: 24 k Downloading packages: epel-release-7-11.noarch.rpm | 15 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : epel-release-7-11.noarch 1/1 Verifying : epel-release-7-11.noarch 1/1 Installed: epel-release.noarch 0:7-11 Complete!
Build cache for EPEL yum repository.
[root@centos-7-server ~]# yum makecache fast
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile epel/x86_64/metalink | 9.2 kB 00:00 * base: mirrors.ges.net.pk * epel: my.fedora.ipserverone.com * extras: mirrors.ges.net.pk * updates: repo.isra.edu.pk base | 3.6 kB 00:00 epel | 5.3 kB 00:00 extras | 2.9 kB 00:00 updates | 2.9 kB 00:00 (1/3): epel/x86_64/group_gz | 90 kB 00:00 (2/3): epel/x86_64/updateinfo | 1.0 MB 00:02 (3/3): epel/x86_64/primary_db | 6.9 MB 00:09 Metadata Cache Created
Kho lưu trữ EPEL yum cho CentOS 7 đã được cài đặt.
Cài đặt các gói cần thiết trên CentOS 7:
Thực hiện lệnh sau để cài đặt các gói cần thiết.
[root@centos-7-server ~]# yum install -y yum-utils rpmconf
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.ges.net.pk * epel: epel.dionipe.id * extras: mirrors.ges.net.pk * updates: repo.isra.edu.pk Package yum-utils-1.1.31-52.el7.noarch already installed and latest version Resolving Dependencies -- Running transaction check --- Package rpmconf.noarch 0:0.3.4-1.el7 will be installed -- Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: rpmconf noarch 0.3.4-1.el7 epel 21 k Transaction Summary ================================================================================ Install 1 Package Total download size: 21 k Installed size: 45 k Downloading packages: warning: /var/cache/yum/x86_64/7/epel/packages/rpmconf-0.3.4-1.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY Public key for rpmconf-0.3.4-1.el7.noarch.rpm is not installed rpmconf-0.3.4-1.el7.noarch.rpm | 21 kB 00:06 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 Importing GPG key 0x352C64E5: Userid : "Fedora EPEL (7) epel@fedoraproject.org" Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5 Package : epel-release-7-11.noarch (@extras) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : rpmconf-0.3.4-1.el7.noarch 1/1 Verifying : rpmconf-0.3.4-1.el7.noarch 1/1 Installed: rpmconf.noarch 0:0.3.4-1.el7 Complete!
Loại bỏ các gói và cấu hình trùng lặp / không sử dụng:
Định vị và xóa các tệp cấu hình xung đột (.rpmnew, .rpmsave và .rpmorigfiles) đã được tạo trong quá trình cài đặt các phiên bản mới của các gói tương ứng.
[root@centos-7-server ~]# rpmconf -a
Configuration file `/etc/nsswitch.conf' -rw-r--r--. 1 root root 1746 Dec 22 2018 /etc/nsswitch.conf -rw-r--r--. 1 root root 1938 Aug 7 04:00 /etc/nsswitch.conf.rpmnew == Package distributor has shipped an updated version. What would you like to do about it ? Your options are: Y or I : install the package maintainer's version N or O : keep your currently-installed version D : show the differences between the versions M : merge configuration files Z : background this process to examine the situation S : skip this file The default action is to keep your current version. *** aliases (Y/I/N/O/D/Z/S) [default=N] ? Your choice:
List down packages that are not relied upon by any other installed package.
[root@centos-7-server ~]# package-cleanup --leaves
Loaded plugins: fastestmirror bind-libs-lite-9.11.4-9.P2.el7.x86_64 libsysfs-2.1.0-16.el7.x86_64
List down older or duplicate packages that are not available in currently configured yum repositories.
[root@centos-7-server ~]# package-cleanup --orphans
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.ges.net.pk * epel: my.fedora.ipserverone.com * extras: mirrors.ges.net.pk * updates: repo.isra.edu.pk kernel-3.10.0-957.el7.x86_64
Uninstall the packages that are listed by the package-cleanup command.
[root@centos-7-server ~]# yum remove -y \
bind-libs-lite-9.11.4-9.P2.el7.x86_64 \
libsysfs-2.1.0-16.el7.x86_64 \
kernel-3.10.0-957.el7.x86_64
Loaded plugins: fastestmirror Resolving Dependencies -- Running transaction check --- Package bind-libs-lite.x86_64 32:9.11.4-9.P2.el7 will be erased --- Package kernel.x86_64 0:3.10.0-957.el7 will be erased --- Package libsysfs.x86_64 0:2.1.0-16.el7 will be erased -- Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Removing: bind-libs-lite x86_64 32:9.11.4-9.P2.el7 @base 2.9 M kernel x86_64 3.10.0-957.el7 @anaconda 63 M libsysfs x86_64 2.1.0-16.el7 @anaconda 146 k Transaction Summary ================================================================================ Remove 3 Packages Installed size: 66 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : kernel-3.10.0-957.el7.x86_64 1/3 Erasing : libsysfs-2.1.0-16.el7.x86_64 2/3 Erasing : 32:bind-libs-lite-9.11.4-9.P2.el7.x86_64 3/3 Verifying : 32:bind-libs-lite-9.11.4-9.P2.el7.x86_64 1/3 Verifying : kernel-3.10.0-957.el7.x86_64 2/3 Verifying : libsysfs-2.1.0-16.el7.x86_64 3/3 Removed: bind-libs-lite.x86_64 32:9.11.4-9.P2.el7 kernel.x86_64 0:3.10.0-957.el7 libsysfs.x86_64 0:2.1.0-16.el7 Complete!
Switch the Package Manager from YUM to DNF:
In CentOS 8, the default package manager yum has been replaced by the dnf (Dandified Yum).
Therefore, we have to switch to the dnf package manager before upgrading our CentOS 7 server.
Install dnf package manager using yum command.
[root@centos-7-server ~]# yum install -y dnf
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.ges.net.pk * epel: my.fedora.ipserverone.com * extras: mirrors.ges.net.pk * updates: repo.isra.edu.pk Resolving Dependencies -- Running transaction check --- Package dnf.noarch 0:4.0.9.2-1.el7_6 will be installed -- Processing Dependency: python2-dnf = 4.0.9.2-1.el7_6 for package: dnf-4.0.9.2-1.el7_6.noarch -- Running transaction check --- Package python2-dnf.noarch 0:4.0.9.2-1.el7_6 will be installed -- Processing Dependency: dnf-data = 4.0.9.2-1.el7_6 for package: python2-dnf-4.0.9.2-1.el7_6.noarch -- Processing Dependency: python2-libdnf = 0.22.5 for package: python2-dnf-4.0.9.2-1.el7_6.noarch -- Processing Dependency: python2-libcomps = 0.1.8 for package: python2-dnf-4.0.9.2-1.el7_6.noarch -- Processing Dependency: python2-hawkey = 0.22.5 for package: python2-dnf-4.0.9.2-1.el7_6.noarch -- Processing Dependency: libmodulemd = 1.4.0 for package: python2-dnf-4.0.9.2-1.el7_6.noarch -- Processing Dependency: python2-libdnf for package: python2-dnf-4.0.9.2-1.el7_6.noarch -- Processing Dependency: python-enum34 for package: python2-dnf-4.0.9.2-1.el7_6.noarch -- Processing Dependency: deltarpm for package: python2-dnf-4.0.9.2-1.el7_6.noarch -- Running transaction check --- Package deltarpm.x86_64 0:3.6-3.el7 will be installed --- Package dnf-data.noarch 0:4.0.9.2-1.el7_6 will be installed -- Processing Dependency: libreport-filesystem for package: dnf-data-4.0.9.2-1.el7_6.noarch --- Package libmodulemd.x86_64 0:1.6.3-1.el7 will be installed -- Processing Dependency: libyaml-0.so.2()(64bit) for package: libmodulemd-1.6.3-1.el7.x86_64 --- Package python-enum34.noarch 0:1.0.4-1.el7 will be installed --- Package python2-hawkey.x86_64 0:0.22.5-1.el7_6 will be installed -- Processing Dependency: libdnf(x86-64) = 0.22.5-
[root@centos-7-server ~]# dnf remove -y yum yum-metadata-parser
Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Removing: yum noarch 3.4.3-163.el7.centos @System 5.6 M yum-metadata-parser x86_64 1.1.4-10.el7 @System 57 k Removing dependent packages: yum-plugin-fastestmirror noarch 1.1.31-52.el7 @System 53 k yum-utils noarch 1.1.31-52.el7 @System 337 k Transaction Summary ================================================================================ Remove 4 Packages Freed space: 6.0 M Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Erasing : yum-utils-1.1.31-52.el7.noarch 1/4 Erasing : yum-plugin-fastestmirror-1.1.31-52.el7.noarch 2/4 Erasing : yum-3.4.3-163.el7.centos.noarch 3/4 Erasing : yum-metadata-parser-1.1.4-10.el7.x86_64 4/4 Verifying : yum-3.4.3-163.el7.centos.noarch 1/4 Verifying : yum-metadata-parser-1.1.4-10.el7.x86_64 2/4 Verifying : yum-plugin-fastestmirror-1.1.31-52.el7.noarch 3/4 Verifying : yum-utils-1.1.31-52.el7.noarch 4/4 Removed: yum-3.4.3-163.el7.centos.noarch yum-metadata-parser-1.1.4-10.el7.x86_64 yum-plugin-fastestmirror-1.1.31-52.el7.noarch yum-utils-1.1.31-52.el7.noarch Complete!
Remove any left behind yum configurations.
[root@centos-7-server ~]# rm -Rf /etc/yum
Build cache for dnf yum repositories.
[root@centos-7-server ~]# dnf makecache Extra Packages for Enterprise Linux 7 - x86_64 54 kB/s | 16 MB 05:08 CentOS-7 - Base 991 kB/s | 10 MB 00:10 CentOS-7 - Updates 1.2 MB/s | 7.0 MB 00:05 CentOS-7 - Extras 1.5 MB/s | 251 kB 00:00 Metadata cache created.
Nâng cấp máy chủ CentOS 7 lên Phiên bản ổn định mới nhất:
Máy chủ của chúng tôi hiện đã sẵn sàng để nâng cấp lên CentOS 8.
Thực hiện lệnh sau để cập nhật các gói hệ thống lên các phiên bản CentOS 7 mới nhất.
[root @ centos-7-server ~] #dnf upgrade -y
Last metadata expiration check: 0:06:17 ago on Fri 17 Jan 2020 09:26:37 PM PKT. Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Upgrading: epel-release noarch 7-12 epel 15 k kernel-tools x86_64 3.10.0-_7.x86_64 nss-tools-3.44.0-7.el7_7.x86_64 nss-util-3.44.0-4.el7_7.x86_64 open-vm-tools-10.3.0-2.el7_7.1.x86_64 python-perf-3.10.0-1062.9.1.el7.x86_64 Installed: kernel-3.10.0-1062.9.1.el7.x86_64 Complete!
Upgrading Yum Repositories from CentOS 7 to CentOS 8:
To upgrade our yum repositories, we have to upgrade centos-release package from CentOS 7 to CentOS 8.
[root@centos-7-server ~]#dnf upgrade -y http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-release-8.1-1.1911.0.8.el8.x86_64.rpm,centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm,centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm}
Last metadata expiration check: 0:11:02 ago on Fri 17 Jan 2020 09:44:30 PM PKT. centos-release-8.1-1.1911.0.8.el8.x86_64.rpm 43 kB/s | 21 kB 00:00 centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm 4.7 kB/s | 11 kB 00:02 centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm 24 kB/s | 12 kB 00:00 Package centos-gpg-keys not installed, cannot update it. No match for argument: /var/cache/dnf/commandline-5fda33494c9fb882/packages/centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm Package centos-repos not installed, cannot update it. No match for argument: 1.1911.0.8.el8.x86_64 3/4 Verifying : centos-release-7-7.1908.0.el7.centos.x86_64 4/4 Upgraded: centos-release-8.1-1.1911.0.8.el8.x86_64 Installed: centos-gpg-keys-8.1-1.1911.0.8.el8.noarch centos-repos-8.1-1.1911.0.8.el8.x86_64 Complete!
Upgrade EPEL yum repository from EL 7 to EL 8.
[root@centos-7-server ~]# dnf upgrade -y epel-release
Last metadata expiration check: 0:09:31 ago on Fri 17 Jan 2020 10:01:25 PM PKT. Dependencies resolved. ===================================================================successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Upgrading : epel-release-8-5.el8.noarch 1/2 Cleanup : epel-release-7-12.noarch 2/2 Verifying : epel-release-8-5.el8.noarch 1/2 Verifying : epel-release-7-12.noarch 2/2 Upgraded: epel-release-8-5.el8.noarch Complete!
Build cache for all yum repositories.
[root@centos-7-server ~]# dnf makecache
Extra Packages for Enterprise Linux 8 - x86_64 30 kB/s | 5.2 MB 02:57 CentOS-8 - Base 0.0 B/s | 0 B 00:00 CentOS-8 - AppStream 0.0 B/s | 0 B 00:00 CentOS-8 - Extras 0.0 B/s | 0 B 00:00 Metadata cache created.
All of our yum repositories has been upgraded from CentOS 7 to CentOS 8.
Upgrading CentOS 7 to CentOS 8 Server:
Remove all installed kernels using following command.
[root@centos-7-server ~]# rpm -e `rpm -q kernel`
Removing conflicting packages.
[root@centos-7-server ~]# rpm -e --nodeps sysvinit-tools
Start system upgrade by using following command.
[root@centos-7-server ~]# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
python-linux-procfs-0.4.11-4.el7.noarch python-schedutils-0.4-6.el7.x86_64 python-slip-0.4.0-4.el7.noarch python-slip-dbus-0.4.0-4.el7.noarch python-urlgrabber-3.10-9.el7.noarch python2-dnf-4.0.9.2-1.el7_6.noarch python2-hawkey-0.22.5-1.el7_6.x86_64 python2-libcomps-0.1.8-12.el7.x86_64 python2-libdnf-0.22.5-1.el7_6.x86_64 pyxattr-0.5.1-5.el7.x86_64 rpm-python-4.11.3-40.el7.x86_64 systemd-sysv-219-67.el7_7.2.x86_64 Complete!
Install new CentOS 8 kernel core.
[root@centos-7-server ~]# dnf install -y kernel-core
Extra Packages for Enterprise Linux Modular 8 - 2.5 kB/s | 10 kB 00:04 Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: kernel-core x86_64 4.18.0-147.3.1.el8_1 BaseOS 25 M Transaction
Install Minimal and Core package groups on the server.
[root@centos-7-server ~]# dnf -y groupupdate "Core" "Minimal Install"
... Installed: dnf-plugin-spacewalk-2.8.5-11.module_el8.1.0+211+ad6c0bc7.noarch dnf-plugins-core-4.0.8-3.el8.noarch libsysfs-2.1.0-24.el8.x86_64 prefixdevname-0.1.0-6.el8.x86_64 rng-tools-6.6-2.el8.x86_64 sssd-common-2.2.0-19.el8.x86_64 sssd-kcm-2.2.0-19.el8.x86_64 yum-4.2.7-7.el8_1.noarch libsss_autofs-2.2.0-19.el8.x86_64 libsss_sudo-2.2.0-19.el8.x86_64 sssd-nfs-idmap-2.2.0-19.el8.x86_64 python3-dnf-plugin-spacewalk-2.8.5-11.module_el8.1.0+211+ad6c0bc7.noarch python3-hwdata-2.3.6-3.el8.noarch python3-netifaces-0.10.6-4.el8.x86_64 python3-newt-0.52.20-9.el8.x86_64 python3-pyOpenSSL-18.0.0-1.el8.noarch python3-rhn-client-tools-2.8.16-14.el8.noarch sssd-client-2.2.0-19.el8.x86_64 Complete!
Reboot server to load new Linux Kernel.
[root@centos-7-server ~]# systemctl reboot
Xác minh phiên bản phần mềm sau khi nâng cấp lên CentOS 8:
After reboot, check version of installed Linux Kernel.
[root@centos-7-server ~]# uname -r
4.18.0-147.3.1.el8_1.x86_64
Chúng tôi đã nâng cấp thành công máy chủ CentOS 7 của mình lên CentOS 8 cùng với tất cả các cơ sở dữ liệu và ứng dụng đã cài đặt.
Chúc các bạn thành công, comment bên dưới nhé
Đây là phiên bản tôi settup thành công nhất