当前位置:   article > 正文

centos离线安装gcc-c++编译环境_centos gc++ 离线

centos gc++ 离线

1.背景

由于公司服务器操作系统大多是更适合用做server的centos最小化安装版,这个版本默认是没有gcc-c++编译环境的,需要安装源码包软件时不能使用make编译,非常不方便。而且服务器基本上都是内网,无法连接外网,只能离线安装。本文使用centos6.5离线安装gcc-c++,centos其他版本安装也是一样的,只是需要的包版本不同。

整体思路是外网下载rpm包,内网离线安装。

2.获取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包了。如下:

  1. [root@study ~]# gcc -v
  2. -bash: gcc: command not found
  3. [root@study ~]# yum -y install yum-downloadonly
  4. Loaded plugins: fastestmirror
  5. Loading mirror speeds from cached hostfile
  6. * base: mirrors.aliyun.com
  7. * extras: mirrors.aliyun.com
  8. * updates: mirrors.aliyun.com
  9. base | 3.7 kB 00:00
  10. extras | 3.7 kB 00:00
  11. updates | 3.7 kB 00:00
  12. Setting up Install Process
  13. Resolving Dependencies
  14. --> Running transaction check
  15. ---> Package yum-plugin-downloadonly.noarch 0:1.1.30-14.el6 will be installed
  16. --> Finished Dependency Resolution
  17. Dependencies Resolved
  18. ================================================================================================================================
  19. Package Arch Version Repository Size
  20. ================================================================================================================================
  21. Installing:
  22. yum-plugin-downloadonly noarch 1.1.30-14.el6 base 20 k
  23. Transaction Summary
  24. ================================================================================================================================
  25. Install 1 Package(s)
  26. Total download size: 20 k
  27. Installed size: 21 k
  28. Downloading Packages:
  29. yum-plugin-downloadonly-1.1.30-14.el6.noarch.rpm | 20 kB 00:00
  30. warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
  31. Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
  32. Importing GPG key 0xC105B9DE:
  33. Userid: "CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>"
  34. From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
  35. Running rpm_check_debug
  36. Running Transaction Test
  37. Transaction Test Succeeded
  38. Running Transaction
  39. Warning: RPMDB altered outside of yum.
  40. Installing : yum-plugin-downloadonly-1.1.30-14.el6.noarch 1/1
  41. Verifying : yum-plugin-downloadonly-1.1.30-14.el6.noarch 1/1
  42. Installed:
  43. yum-plugin-downloadonly.noarch 0:1.1.30-14.el6
  44. Complete!
  45. [root@study ~]# yum -y install --downloadonly --downloaddir=/tmp gcc-c++
  46. Loaded plugins: downloadonly, fastestmirror
  47. Loading mirror speeds from cached hostfile
  48. * base: mirrors.aliyun.com
  49. * extras: mirrors.aliyun.com
  50. * updates: mirrors.aliyun.com
  51. Setting up Install Process
  52. Resolving Dependencies
  53. --> Running transaction check
  54. ---> Package gcc-c++.x86_64 0:4.4.7-4.el6 will be installed
  55. --> Processing Dependency: libstdc++-devel = 4.4.7-4.el6 for package: gcc-c++-4.4.7-4.el6.x86_64
  56. --> Processing Dependency: gcc = 4.4.7-4.el6 for package: gcc-c++-4.4.7-4.el6.x86_64
  57. --> Processing Dependency: libmpfr.so.1()(64bit) for package: gcc-c++-4.4.7-4.el6.x86_64
  58. --> Running transaction check
  59. ---> Package gcc.x86_64 0:4.4.7-4.el6 will be installed
  60. --> Processing Dependency: libgomp = 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.x86_64
  61. --> Processing Dependency: cpp = 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.x86_64
  62. --> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-4.el6.x86_64
  63. --> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-4.el6.x86_64
  64. --> Processing Dependency: libgomp.so.1()(64bit) for package: gcc-4.4.7-4.el6.x86_64
  65. ---> Package libstdc++-devel.x86_64 0:4.4.7-4.el6 will be installed
  66. ---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
  67. --> Running transaction check
  68. ---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
  69. --> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
  70. --> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
  71. ---> Package cpp.x86_64 0:4.4.7-4.el6 will be installed
  72. ---> Package glibc-devel.x86_64 0:2.12-1.132.el6 will be installed
  73. --> Processing Dependency: glibc-headers = 2.12-1.132.el6 for package: glibc-devel-2.12-1.132.el6.x86_64
  74. --> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.132.el6.x86_64
  75. ---> Package libgomp.x86_64 0:4.4.7-4.el6 will be installed
  76. --> Running transaction check
  77. ---> Package glibc-headers.x86_64 0:2.12-1.132.el6 will be installed
  78. --> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.132.el6.x86_64
  79. --> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.132.el6.x86_64
  80. ---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
  81. --> Running transaction check
  82. ---> Package kernel-headers.x86_64 0:2.6.32-431.el6 will be installed
  83. --> Finished Dependency Resolution
  84. Dependencies Resolved
  85. ================================================================================================================================
  86. Package Arch Version Repository Size
  87. ================================================================================================================================
  88. Installing:
  89. gcc-c++ x86_64 4.4.7-4.el6 base 4.7 M
  90. Installing for dependencies:
  91. cloog-ppl x86_64 0.15.7-1.2.el6 base 93 k
  92. cpp x86_64 4.4.7-4.el6 base 3.7 M
  93. gcc x86_64 4.4.7-4.el6 base 10 M
  94. glibc-devel x86_64 2.12-1.132.el6 base 978 k
  95. glibc-headers x86_64 2.12-1.132.el6 base 608 k
  96. kernel-headers x86_64 2.6.32-431.el6 base 2.8 M
  97. libgomp x86_64 4.4.7-4.el6 base 118 k
  98. libstdc++-devel x86_64 4.4.7-4.el6 base 1.6 M
  99. mpfr x86_64 2.4.1-6.el6 base 157 k
  100. ppl x86_64 0.10.2-11.el6 base 1.3 M
  101. Transaction Summary
  102. ================================================================================================================================
  103. Install 11 Package(s)
  104. Total download size: 26 M
  105. Installed size: 59 M
  106. Downloading Packages:
  107. (1/11): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm | 93 kB 00:00
  108. (2/11): cpp-4.4.7-4.el6.x86_64.rpm | 3.7 MB 00:02
  109. (3/11): gcc-4.4.7-4.el6.x86_64.rpm | 10 MB 00:05
  110. (4/11): gcc-c++-4.4.7-4.el6.x86_64.rpm | 4.7 MB 00:02
  111. (5/11): glibc-devel-2.12-1.132.el6.x86_64.rpm | 978 kB 00:00
  112. (6/11): glibc-headers-2.12-1.132.el6.x86_64.rpm | 608 kB 00:00
  113. (7/11): kernel-headers-2.6.32-431.el6.x86_64.rpm | 2.8 MB 00:01
  114. (8/11): libgomp-4.4.7-4.el6.x86_64.rpm | 118 kB 00:00
  115. (9/11): libstdc++-devel-4.4.7-4.el6.x86_64.rpm | 1.6 MB 00:00
  116. (10/11): mpfr-2.4.1-6.el6.x86_64.rpm | 157 kB 00:00
  117. (11/11): ppl-0.10.2-11.el6.x86_64.rpm | 1.3 MB 00:00
  118. --------------------------------------------------------------------------------------------------------------------------------
  119. Total 1.5 MB/s | 26 MB 00:17
  120. exiting because --downloadonly specified
  121. [root@study ~]# ll /tmp/
  122. 总用量 26772
  123. -rw-r--r--. 1 root root 95248 7月 3 2011 cloog-ppl-0.15.7-1.2.el6.x86_64.rpm
  124. -rw-r--r--. 1 root root 3906116 11月 25 2013 cpp-4.4.7-4.el6.x86_64.rpm
  125. -rw-r--r--. 1 root root 10567364 11月 25 2013 gcc-4.4.7-4.el6.x86_64.rpm
  126. -rw-r--r--. 1 root root 4946968 11月 25 2013 gcc-c++-4.4.7-4.el6.x86_64.rpm
  127. -rw-r--r--. 1 root root 1001012 11月 25 2013 glibc-devel-2.12-1.132.el6.x86_64.rpm
  128. -rw-r--r--. 1 root root 622736 11月 25 2013 glibc-headers-2.12-1.132.el6.x86_64.rpm
  129. -rw-r--r--. 1 root root 2970072 11月 25 2013 kernel-headers-2.6.32-431.el6.x86_64.rpm
  130. -rw-r--r--. 1 root root 121064 11月 25 2013 libgomp-4.4.7-4.el6.x86_64.rpm
  131. -rw-r--r--. 1 root root 1674172 11月 25 2013 libstdc++-devel-4.4.7-4.el6.x86_64.rpm
  132. -rw-r--r--. 1 root root 160772 7月 3 2011 mpfr-2.4.1-6.el6.x86_64.rpm
  133. -rw-r--r--. 1 root root 1322280 7月 3 2011 ppl-0.10.2-11.el6.x86_64.rpm
  134. -rw-------. 1 root root 0 12月 16 23:32 yum.log
  135. -rw-------. 1 root root 2689 12月 17 11:28 yum_save_tx-2020-12-17-11-28pFvIGs.yumtx
  136. [root@study ~]#

 3.将所有rpm包转移到需要安装gcc-c++的内网目标服务器的/tmp目录下,使用命令yum localinstall gcc-c++ /tmp/* 离线安装

yum localinstall gcc-c++ /tmp/*

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/469017
推荐阅读
相关标签
  

闽ICP备14008679号