Centos offline installation of gcc-c++ compilation environment

1. Background

Since most of the company's server operating systems are more suitable for use as a server's minimal installation version of centos, this version does not have a gcc-c++ compilation environment by default, and you cannot use make to compile when you need to install source package software, which is very inconvenient. And the servers are basically intranets, unable to connect to the external network, and can only be installed offline. This article uses centos6.5 to install gcc-c++ offline. The installation of other versions of centos is also the same, but the required package version is different.

The overall idea is to download the rpm package from the external network and install it offline from the internal network.

2. Get the rpm package

There are many ways to obtain packages. We choose to use yum -y install --downloadonly --downloaddir=/tmp gcc-c++ to download the required rpm package and required dependencies to the local /tmp directory for storage.

Centos6.5 minimal installation does not have --downloadonly by default, you need to install the plugin yum-plugin-downloadonly first.

First, prepare a server that is consistent with the target server version and can be connected to the external network with a minimal installation. It can be a virtual machine created by VMware as our workstation. If you are engaged in server operation and maintenance for a long time, it is recommended to keep a virtual machine to download various rpm packages, so as to avoid the pain of finding various rpm packages and related dependencies on image files or websites.

There is no requirement for virtual machine configuration, mine is as follows:

 Complete the basic configuration of the virtual machine (network, yum source, yum-plugin-downloadonly, etc.), and take a snapshot to facilitate subsequent restoration of the virtual machine to its initial state. Make sure that the virtual machine has not installed gcc-c++, otherwise downloadonly will not be able to download the rpm package. Then you can directly use the command to download the rpm package. as follows:

[root@study ~]# gcc -v
-bash: gcc: command not found
[root@study ~]# yum -y install yum-downloadonly
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                     | 3.7 kB     00:00     
extras                                                                                                   | 3.7 kB     00:00     
updates                                                                                                  | 3.7 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package yum-plugin-downloadonly.noarch 0:1.1.30-14.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
 Package                                  Arch                    Version                           Repository             Size
================================================================================================================================
Installing:
 yum-plugin-downloadonly                  noarch                  1.1.30-14.el6                     base                   20 k

Transaction Summary
================================================================================================================================
Install       1 Package(s)

Total download size: 20 k
Installed size: 21 k
Downloading Packages:
yum-plugin-downloadonly-1.1.30-14.el6.noarch.rpm                                                         |  20 kB     00:00     
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid: "CentOS-6 Key (CentOS 6 Official Signing Key) <[email protected]>"
 From  : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : yum-plugin-downloadonly-1.1.30-14.el6.noarch                                                                 1/1 
  Verifying  : yum-plugin-downloadonly-1.1.30-14.el6.noarch                                                                 1/1 

Installed:
  yum-plugin-downloadonly.noarch 0:1.1.30-14.el6                                                                                

Complete!
[root@study ~]# yum -y install --downloadonly --downloaddir=/tmp gcc-c++
Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.4.7-4.el6 will be installed
--> Processing Dependency: libstdc++-devel = 4.4.7-4.el6 for package: gcc-c++-4.4.7-4.el6.x86_64
--> Processing Dependency: gcc = 4.4.7-4.el6 for package: gcc-c++-4.4.7-4.el6.x86_64
--> Processing Dependency: libmpfr.so.1()(64bit) for package: gcc-c++-4.4.7-4.el6.x86_64
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-4.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-4.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-4.el6.x86_64
--> Processing Dependency: libgomp.so.1()(64bit) for package: gcc-4.4.7-4.el6.x86_64
---> Package libstdc++-devel.x86_64 0:4.4.7-4.el6 will be installed
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-4.el6 will be installed
---> Package glibc-devel.x86_64 0:2.12-1.132.el6 will be installed
--> Processing Dependency: glibc-headers = 2.12-1.132.el6 for package: glibc-devel-2.12-1.132.el6.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.132.el6.x86_64
---> Package libgomp.x86_64 0:4.4.7-4.el6 will be installed
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.12-1.132.el6 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.132.el6.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.132.el6.x86_64
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Running transaction check
---> Package kernel-headers.x86_64 0:2.6.32-431.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
 Package                            Arch                      Version                             Repository               Size
================================================================================================================================
Installing:
 gcc-c++                            x86_64                    4.4.7-4.el6                         base                    4.7 M
Installing for dependencies:
 cloog-ppl                          x86_64                    0.15.7-1.2.el6                      base                     93 k
 cpp                                x86_64                    4.4.7-4.el6                         base                    3.7 M
 gcc                                x86_64                    4.4.7-4.el6                         base                     10 M
 glibc-devel                        x86_64                    2.12-1.132.el6                      base                    978 k
 glibc-headers                      x86_64                    2.12-1.132.el6                      base                    608 k
 kernel-headers                     x86_64                    2.6.32-431.el6                      base                    2.8 M
 libgomp                            x86_64                    4.4.7-4.el6                         base                    118 k
 libstdc++-devel                    x86_64                    4.4.7-4.el6                         base                    1.6 M
 mpfr                               x86_64                    2.4.1-6.el6                         base                    157 k
 ppl                                x86_64                    0.10.2-11.el6                       base                    1.3 M

Transaction Summary
================================================================================================================================
Install      11 Package(s)

Total download size: 26 M
Installed size: 59 M
Downloading Packages:
(1/11): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm                                                              |  93 kB     00:00     
(2/11): cpp-4.4.7-4.el6.x86_64.rpm                                                                       | 3.7 MB     00:02     
(3/11): gcc-4.4.7-4.el6.x86_64.rpm                                                                       |  10 MB     00:05     
(4/11): gcc-c++-4.4.7-4.el6.x86_64.rpm                                                                   | 4.7 MB     00:02     
(5/11): glibc-devel-2.12-1.132.el6.x86_64.rpm                                                            | 978 kB     00:00     
(6/11): glibc-headers-2.12-1.132.el6.x86_64.rpm                                                          | 608 kB     00:00     
(7/11): kernel-headers-2.6.32-431.el6.x86_64.rpm                                                         | 2.8 MB     00:01     
(8/11): libgomp-4.4.7-4.el6.x86_64.rpm                                                                   | 118 kB     00:00     
(9/11): libstdc++-devel-4.4.7-4.el6.x86_64.rpm                                                           | 1.6 MB     00:00     
(10/11): mpfr-2.4.1-6.el6.x86_64.rpm                                                                     | 157 kB     00:00     
(11/11): ppl-0.10.2-11.el6.x86_64.rpm                                                                    | 1.3 MB     00:00     
--------------------------------------------------------------------------------------------------------------------------------
Total                                                                                           1.5 MB/s |  26 MB     00:17     


exiting because --downloadonly specified 
[root@study ~]# ll /tmp/
总用量 26772
-rw-r--r--. 1 root root    95248 7月   3 2011 cloog-ppl-0.15.7-1.2.el6.x86_64.rpm
-rw-r--r--. 1 root root  3906116 11月 25 2013 cpp-4.4.7-4.el6.x86_64.rpm
-rw-r--r--. 1 root root 10567364 11月 25 2013 gcc-4.4.7-4.el6.x86_64.rpm
-rw-r--r--. 1 root root  4946968 11月 25 2013 gcc-c++-4.4.7-4.el6.x86_64.rpm
-rw-r--r--. 1 root root  1001012 11月 25 2013 glibc-devel-2.12-1.132.el6.x86_64.rpm
-rw-r--r--. 1 root root   622736 11月 25 2013 glibc-headers-2.12-1.132.el6.x86_64.rpm
-rw-r--r--. 1 root root  2970072 11月 25 2013 kernel-headers-2.6.32-431.el6.x86_64.rpm
-rw-r--r--. 1 root root   121064 11月 25 2013 libgomp-4.4.7-4.el6.x86_64.rpm
-rw-r--r--. 1 root root  1674172 11月 25 2013 libstdc++-devel-4.4.7-4.el6.x86_64.rpm
-rw-r--r--. 1 root root   160772 7月   3 2011 mpfr-2.4.1-6.el6.x86_64.rpm
-rw-r--r--. 1 root root  1322280 7月   3 2011 ppl-0.10.2-11.el6.x86_64.rpm
-rw-------. 1 root root        0 12月 16 23:32 yum.log
-rw-------. 1 root root     2689 12月 17 11:28 yum_save_tx-2020-12-17-11-28pFvIGs.yumtx
[root@study ~]# 

 3. Transfer all rpm packages to the /tmp directory of the intranet target server that needs to install gcc-c++, and use the command yum localinstall gcc-c++ /tmp/* to install offline

yum localinstall gcc-c++ /tmp/*

 

Guess you like

Origin blog.csdn.net/ct_666/article/details/111519155