gcc-c ++コンパイル環境のCentosオフラインインストール

1.背景

同社のサーバーオペレーティングシステムのほとんどは、サーバーの最小インストールバージョンのcentosとしての使用に適しているため、このバージョンにはデフォルトでgcc-c ++コンパイル環境がなく、ソースパッケージをインストールする必要があるときにmakeを使用してコンパイルすることはできません。ソフトウェア、これは非常に不便です。また、サーバーは基本的にイントラネットであり、外部ネットワークに接続できず、オフラインでのみインストールできます。この記事では、centos6.5を使用してgcc-c ++をオフラインでインストールします。他のバージョンのcentosのインストールも同じですが、必要なパッケージバージョンが異なります。

全体的な考え方は、外部ネットワークからrpmパッケージをダウンロードし、内部ネットワークからオフラインでインストールすることです。

2.rpmパッケージを入手します

パッケージを取得する方法はたくさんあります。yum-yinstall--downloadonly--downloaddir = / tmp gcc-c ++を使用して、必要なrpmパッケージと必要な依存関係をローカルの/ tmpディレクトリにダウンロードして保存することを選択します。

Centos6.5の最小インストールにはデフォルトで--downloadonlyがありません。最初に、プラグインyum-plugin-downloadonlyをインストールする必要があります。

まず、ターゲットサーバーのバージョンと整合性があり最小限のインストールで外部ネットワークに接続できるサーバー準備します。これは、VMwareがワークステーションとして作成した仮想マシンすることができます。サーバーの運用と保守に長期間携わっている場合は、さまざまなrpmパッケージを見つけたり、画像ファイルやWebサイトに関連する依存関係を見つけたりする手間を省くために、仮想マシンを保持してさまざまなrpmパッケージをダウンロードすることをお勧めします。

仮想マシンの構成は必要ありません。私のものは次のとおりです。

 仮想マシンの基本構成(ネットワーク、yumソース、yum-plugin-downloadonlyなど)を完了し、スナップショットを作成して、仮想マシンを初期状態に後で復元しやすくします。仮想マシンにgcc-c ++がインストールされていないことを確認してください。インストールされていない場合、downloadonlyはrpmパッケージをダウンロードできません。次に、コマンドを直接使用してrpmパッケージをダウンロードできます。次のように:

[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.すべてのrpmパッケージをgcc-c ++をインストールする必要があるイントラネットターゲットサーバーの/ tmpディレクトリに転送し、コマンドyum localinstall gcc-c ++ / tmp / *を使用してオフラインでインストールします。

yum localinstall gcc-c++ /tmp/*

 

おすすめ

転載: blog.csdn.net/ct_666/article/details/111519155