CentOS 6 - Yum offline install
Sometimes you need to install a package in an environment where you cannot use the Internet.
Note: This article is intended for CentOS 6. If you are using CentOS8, please refer to the following article.
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.
I will prepare as a virtual machine. If you don't know the OS version, run this command.
Now install the desired package using yum. If you want to install rpm, use the -Uvh option.
Because the monit package is in the epel repo, you must install epel repo. Then modify the repo files like this.
Uncomment the baseurl, comment the mirrorlist.
Then remove all cached data.
Now install the monit packages.
There are 4 directories(base, epel, extras, updates) in the /var/cache/yum/x86_64/6 directory. Check all the directories. Some complex packages leave depedent rpm files in other directories, and you must install those rpm files too.
Copy the rpm files to the original CentOS machine that can't connect to the internet, then ry=un the rpm command with -Uvh option
Note: This article is intended for CentOS 6. If you are using CentOS8, please refer to the following article.
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.
I will prepare as a virtual machine. If you don't know the OS version, run this command.
[root@localhost ~]# cat /etc/*release* CentOS release 6.7 (Final) LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch cat: /etc/lsb-release.d: Is a directory CentOS release 6.7 (Final) CentOS release 6.7 (Final) cpe:/o:centos:linux:6:GA
Install the package to the VM you prepared.
I'll install monit packages to CentOS 6.7. First edit yum.conf file like this. Set keepcache = 1shell> vi /etc/yum.conf [main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=1 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release
Now install the desired package using yum. If you want to install rpm, use the -Uvh option.
Because the monit package is in the epel repo, you must install epel repo. Then modify the repo files like this.
yum install epel-release vim /etc/yum.repos.d/epel.repo
Uncomment the baseurl, comment the mirrorlist.
[epel] name=Extra Packages for Enterprise Linux 6 - $basearch baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 [epel-debuginfo] name=Extra Packages for Enterprise Linux 6 - $basearch - Debug baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 6 - $basearch - Source baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 gpgcheck=1
Then remove all cached data.
yum clean all
Now install the monit packages.
[root@localhost src]# yum install monit Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Determining fastest mirrors * base: mirror.kakao.com * extras: mirror.fairway.ne.jp * updates: mirror.fairway.ne.jp base | 3.7 kB 00:00 base/primary_db | 4.7 MB 00:02 epel | 5.3 kB 00:00 epel/primary_db | 6.1 MB 00:03 extras | 3.4 kB 00:00 extras/primary_db | 29 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 6.6 MB 02:05 Resolving Dependencies --> Running transaction check ---> Package monit.x86_64 0:5.25.1-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================== Package Arch Version Repository Size ========================================================================================================================== Installing: monit x86_64 5.25.1-1.el6 epel 310 k Transaction Summary ========================================================================================================================== Install 1 Package(s) Total download size: 310 k Installed size: 814 k Is this ok [y/N]: y Downloading Packages: monit-5.25.1-1.el6.x86_64.rpm | 310 kB 00:01 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 Importing GPG key 0x0608B895: Userid : EPEL (6) <epel@fedoraproject.org> Package: epel-release-6-8.noarch (@extras) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 Is this ok [y/N]: y Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : monit-5.25.1-1.el6.x86_64 1/1 Verifying : monit-5.25.1-1.el6.x86_64 1/1 Installed: monit.x86_64 0:5.25.1-1.el6 Complete!
Check the rpm files
First, check the yum.log file.[root@localhost src]# cat /var/log/yum.log Oct 24 22:48:16 Installed: epel-release-6-8.noarch Oct 24 23:11:53 Installed: monit-5.25.1-1.el6.x86_64
There are 4 directories(base, epel, extras, updates) in the /var/cache/yum/x86_64/6 directory. Check all the directories. Some complex packages leave depedent rpm files in other directories, and you must install those rpm files too.
[root@localhost src]# ls -al /var/cache/yum/x86_64/6/epel/packages/ total 320 drwxr-xr-x. 2 root root 4096 Oct 24 23:11 . drwxr-xr-x. 4 root root 4096 Oct 24 23:12 .. -rw-r--r--. 1 root root 317148 Dec 27 2017 monit-5.25.1-1.el6.x86_64.rpm [root@localhost src]# ls -al /var/cache/yum/x86_64/6/base/packages/ total 8 drwxr-xr-x. 2 root root 4096 Oct 24 22:22 . drwxr-xr-x. 4 root root 4096 Oct 24 23:12 .. [root@localhost src]# ls -al /var/cache/yum/x86_64/6/extras/packages/ total 8 drwxr-xr-x. 2 root root 4096 Oct 24 23:07 . drwxr-xr-x. 3 root root 4096 Oct 24 23:08 ..
Copy the rpm files to the original CentOS machine that can't connect to the internet, then ry=un the rpm command with -Uvh option
yum -Uvh monit-5.25.1-1.el6.x86_64.rpm
댓글
댓글 쓰기