background
Enterprise client servers are generally in the internal network, and will restrict the server's access to the external network to ensure the security of the server, but this causes a lot of inconvenience. For example, package installation tools such as yum cannot be used. A well-done company will build one. Private warehouses, warehouses can be agents to central warehouses, but according to experience, most companies are not good at private warehouses. Many programs can be installed with one line of yum. If you install offline, you need to install all the dependencies, which may not be possible. After the installation is complete, how to use the yum installer even when offline? This article will discuss this issue.
accomplish
In fact, the most convenient thing about yum is that it can help us resolve dependencies and automatically install all dependencies. Assuming that yum can download all dependencies, then the most troublesome problem is actually solved. We get these dependencies and install them one by one. Just fine. Fortunately, yum not only provides the function of downloading dependencies, but also can install all downloaded dependencies at once. Let's take the installation of openssl as an example.
download
First, you need to find a server with the same operating system version as the intranet server to download the dependency package. Take Centos as an example to check the operating system version number
# more /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)
You can use a virtual machine to create an operating system of the same version locally, or you can create a preemptible instance of the same version in Alibaba Cloud. In short, you have to find a server of the same version that can access the Internet. Normally, we need to execute the following to install openssl Order
yum install openssl
Change the command to the following to download but not install
# yumdownloader --assumeyes --destdir=/u01/software/openssl --resolve openssl
已加载插件:langpacks
--> 正在检查事务
---> 软件包 openssl.x86_64.1.1.0.2k-21.0.3.el7_9 将被 安装
--> 正在处理依赖关系 openssl-libs(x86-64) = 1:1.0.2k-21.0.3.el7_9,它被软件包 1:openssl-1.0.2k-21.0.3.el7_9.x86_64 需要
--> 正在检查事务
---> 软件包 openssl-libs.x86_64.1.1.0.2k-16.0.1.el7 将被 升级
--> 正在处理依赖关系 openssl-libs(x86-64) = 1:1.0.2k-16.0.1.el7,它被软件包 1:openssl-1.0.2k-16.0.1.el7.x86_64 需要
---> 软件包 openssl-libs.x86_64.1.1.0.2k-21.0.3.el7_9 将被 更新
--> 正在检查事务
---> 软件包 openssl.x86_64.1.1.0.2k-16.0.1.el7 将被 升级
--> 解决依赖关系完成
No Presto metadata available for ol7_latest
(1/2): openssl-1.0.2k-21.0.3.el7_9.x86_64.rpm | 493 kB 00:00:02
(2/2): openssl-libs-1.0.2k-21.0.3.el7_9.x86_64.rpm | 1.2 MB 00:00:03
# ll /u01/software/openssl
总用量 1732
-rw-r--r--. 1 root jomoo 505244 5月 14 05:01 openssl-1.0.2k-21.0.3.el7_9.x86_64.rpm
-rw-r--r--. 1 root jomoo 1254768 5月 14 05:01 openssl-libs-1.0.2k-21.0.3.el7_9.x86_64.rpm
If there is no yumdownloader, you can execute yum install yum-utils -y to install
Install
Package the downloaded rpm package and upload it to the intranet server, and put it in the specified directory, such as /u01/software/openssl
, and execute the following command to install
yum install -y --cacheonly --disablerepo=* /u01/software/openssl/*.rpm
You can also create a local warehouse
vi /etc/yum.repos.d/local.repo
[local]
name=ansible
baseurl=file:///u01/software/openssl
gpgcheck=0
enabled=1
cd /u01/software/
createrepo openssl
in conclusion
A long time ago, I heard from an older generation that when there was no yum, they installed svn on the server. They did it for a day. Now only one line of command is needed. Yum really facilitates the installation of the program. The method introduced in this article is simple, but It is a very useful method to solve the problem of using yum offline
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。