赞
踩
由于公司服务器操作系统大多是更适合用做server的centos最小化安装版,这个版本默认是没有gcc-c++编译环境的,需要安装源码包软件时不能使用make编译,非常不方便。而且服务器基本上都是内网,无法连接外网,只能离线安装。本文使用centos6.5离线安装gcc-c++,centos其他版本安装也是一样的,只是需要的包版本不同。
整体思路是外网下载rpm包,内网离线安装。
获取包的方式很多,我们选择使用 yum -y install --downloadonly --downloaddir=/tmp gcc-c++ 将所需的rpm包及所需依赖下载到本地/tmp目录保存。
centos6.5最小化安装默认没有--downloadonly,需要先安装插件 yum-plugin-downloadonly。
首先准备一台跟目标服务器版本一致且最小化安装的可以连接外网的服务器,可以是VMware创建的虚拟机,作为我们的工作站。如果时长期搞服务器运维的,建议常备一台虚拟机用来下载各种rpm包,免去了在映像文件或网站上找各种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) <centos-6-key@centos.org>"
- 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/*
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。