CentOS 8 - Yum offline install
Sometimes you need to install a package in an environment where you cannot use the Internet.
Prepare another computer
First, prepare a computer with an OS installed, such as the offline computer.
In this case, use yum to install the package you want to install on another computer with Internet. Creating a virtual machine using VMWare or VirtualBox simplifies your work.
Be careful : Both computers' OS must be same. And it is recommended not to issue commands such as "yum update" because all packages should have the same versions.
Most of the offline servers have not been updated by "yum update" command because they cannot connect to the Internet. So in this case, even your virtual machine doesn't do a yum update.
Enable CentOS 8 Repo
The following yum error occurs when you do yum related task. ``` bash Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist ``` Problem Convert the existing Mirror site to Vault through the command below
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
Initially, not all repo's are active. Activate the Power Tool Repo. This repo contains a number of packages for development.
yum config-manager --set-enabled powertools
Install the package on the test server
Install the package you want to install on the test server as follows. The following example is an example of installing g++ on CentOS 8.4. CentOS 8.4 has gcc 8.4.1 installed. But g++ is not installed.
[root@localhost ~]# rpm -qa|grep gcc libgcc-8.4.1-1.el8.x86_64 gcc-8.4.1-1.el8.x86_64 [root@localhost ~]# gcc --version gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1) Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [root@localhost ~]# g++ version bash: g++: command not found... Failed to search for file: cannot update repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
Try installing without using the -y option. In the figure below, the current version of gcc-c++ is 8.5.0-4, and the update of the existing gcc will also be performed to install this package.
When installing a package offline, it is recommended not to change the version of an existing package as much as possible. If you update an existing package, there is no problem if you use yum, which can be accessed online.
[root@localhost ~]# yum install gcc-c++ Last metadata expiration check: 0:00:16 ago on Sun 17 Jul 2022 08:02:26 AM PDT. Dependencies resolved. ============================================================================================= Package Architecture Version Repository Size ============================================================================================= Installing: gcc-c++ x86_64 8.5.0-4.el8_5 appstream 12 M Upgrading: cpp x86_64 8.5.0-4.el8_5 appstream 10 M gcc x86_64 8.5.0-4.el8_5 appstream 23 M libgcc x86_64 8.5.0-4.el8_5 baseos 79 k libgomp x86_64 8.5.0-4.el8_5 baseos 206 k libstdc++ x86_64 8.5.0-4.el8_5 baseos 453 k Installing dependencies: libstdc++-devel x86_64 8.5.0-4.el8_5 appstream 2.0 M Transaction Summary ============================================================================================= Install 2 Packages Upgrade 5 Packages Total download size: 49 M Is this ok [y/N]:
Based on the information above, let's proceed with the least amount of work. Press N once to exit the installation.
Download packages that are compatible with existing packages -method 1
yum install --downloadonly --downloaddir=<directory> <package-name>
So you can easily download it along with the dependency package with the following command:
yum install --downloadonly --downloaddir=./ gcc-c++
Now, libstdc++-devel-8.4.1-1.el8.x86_64.rpm and gcc-c++-8.4.1-1.el8.x86_64.rpm files will be saved in your working directory.
Download packages that are compatible with existing packages -method 2
First of all, the upgrade item is the currently installed package, so keep this version. First, check the previous installed version again.
[root@localhost ~]# rpm -qa |grep libstdc++ libstdc++-8.4.1-1.el8.x86_64 [root@localhost ~]# rpm -qa |grep libgomp libgomp-8.4.1-1.el8.x86_64 [root@localhost ~]# rpm -qa |grep libgcc libgcc-8.4.1-1.el8.x86_64 [root@localhost ~]# rpm -qa |grep gcc libgcc-8.4.1-1.el8.x86_64 gcc-8.4.1-1.el8.x86_64 [root@localhost ~]# rpm -qa |grep cpp cpp-8.4.1-1.el8.x86_64 abrt-addon-ccpp-2.10.9-20.el8.x86_64 mcpp-2.7.2-20.el8.x86_64 libmcpp-2.7.2-20.el8.x86_64
All packages are matched to the gcc version. Therefore, we prepare and install the versions of the two packages to be newly installed (libstdc++-devel, gcc-c++) as 8.4.1-1. Then, it is easy to work because it does not upgrade gcc-related packages.
Packages can be found easily at https://rpmfind.net/linux/rpm2html/search.php?query=ntsysv&submit=Search+...&system=&arch=.
First, search for libstdc++-devel 8.4.1-1 version. If you search for libstdc++-devel on the above page, a list of downloadable files appears below.
Find 8.4.1-1 here and download the rpm.
In the same way, gcc-c++ also searches for 8.4.1-1 instead of 8.5.0-4.el8_5 and downloads it with the wget command.
Install the downloaded rpm
Since the downloaded package rpm does not upgrade, it can be installed immediately.
[root@localhost ~]# ll total 14668 -rw-------. 1 root root 2747 Jul 17 06:11 anaconda-ks.cfg -rw-r--r--. 1 root root 12857496 Oct 12 2020 gcc-c++-8.4.1-1.el8.x86_64.rpm -rw-r--r--. 1 root root 2148004 Oct 12 2020 libstdc++-devel-8.4.1-1.el8.x86_64.rpm -rw-------. 1 root root 2073 Jul 17 06:11 original-ks.cfg
Be sure to install packages from depencencies first.
[root@localhost ~]# rpm -Uvh libstdc++-devel-8.4.1-1.el8.x86_64.rpm warning: libstdc++-devel-8.4.1-1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY Verifying... ################################# [100%] Preparing... ################################# [100%] Updating / installing... 1:libstdc++-devel-8.4.1-1.el8 ################################# [100%] [root@localhost ~]# rpm -Uvh gcc-c++-8.4.1-1.el8.x86_64.rpm warning: gcc-c++-8.4.1-1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY Verifying... ################################# [100%] Preparing... ################################# [100%] Updating / installing... 1:gcc-c++-8.4.1-1.el8 ################################# [100%]
Let's check whether it is installed properly. You can see that it is installed properly. Now you can copy these two packages and install them on the offline server.
[root@localhost ~]# g++ --version g++ (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1) Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Training
This is an example of offline installation of libcurl-devel without explanation.
[root@localhost ~]# yum install libcurl-devel Last metadata expiration check: 0:25:24 ago on Sun 17 Jul 2022 08:02:26 AM PDT. Dependencies resolved. ============================================================================================= Package Architecture Version Repository Size ============================================================================================= Installing: libcurl-devel x86_64 7.61.1-22.el8 baseos 834 k Upgrading: libcurl x86_64 7.61.1-22.el8 baseos 301 k openssl x86_64 1:1.1.1k-5.el8_5 baseos 709 k openssl-libs x86_64 1:1.1.1k-5.el8_5 baseos 1.5 M Transaction Summary ============================================================================================= Install 1 Package Upgrade 3 Packages Total download size: 3.3 M Is this ok [y/N]: N Operation aborted. [root@localhost ~]# rpm -qa |grep libcurl libcurl-7.61.1-18.el8.x86_64 [root@localhost ~]# wget https://rpmfind.net/linux/centos/8-stream/BaseOS/x86_64/os/Packages/libcurl-devel-7.61.1-18.el8.x86_64.rpm --2022-07-17 08:29:30-- https://rpmfind.net/linux/centos/8-stream/BaseOS/x86_64/os/Packages/libcurl-devel-7.61.1-18.el8.x86_64.rpm Resolving rpmfind.net (rpmfind.net)... 195.220.108.108 Connecting to rpmfind.net (rpmfind.net)|195.220.108.108|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 852712 (833K) [application/x-rpm] Saving to: ‘libcurl-devel-7.61.1-18.el8.x86_64.rpm’ libcurl-devel-7.61.1-18 100%[============================>] 832.73K 527KB/s in 1.6s 2022-07-17 08:29:33 (527 KB/s) - ‘libcurl-devel-7.61.1-18.el8.x86_64.rpm’ saved [852712/852712] [root@localhost ~]# rpm -Uvh libcurl-devel-7.61.1-18.el8.x86_64.rpm warning: libcurl-devel-7.61.1-18.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY Verifying... ################################# [100%] Preparing... ################################# [100%] Updating / installing... 1:libcurl-devel-7.61.1-18.el8 ################################# [100%]
댓글
댓글 쓰기