图形界面是一个程序,可以通过yum在网上下载,也可以在DVD中找到安装包,一个错误的做法是一开始变把CentOS-7.0-1406-x86_64-DVD.iso文件放进光盘里面
不管使用IDE还是SATA控制器,第一,第二通道,主控制还是从控制器,virutalbox只会使用光驱启动方式去读取CentOS-7.0-1406-x86_64-DVD.iso,这会导致进入安装界面,而不能进入已经存在的centos.vdi系统
这显然不是我们想要的结果,为了避免这种情况,我们要把光盘区域留空,另外如果你删除了光盘区域,在linux系统启动以后是无法再添加的
这样可以按照正常启动centos,这个时候我们才选择插入光盘,好比台式电脑看电影DVD一样
DVD也是一种设备,就像硬盘也是一种设备一样,会出现在/dev目录下,光盘设备对应的目录是 /dev/cdrom
接下来的操作流程可以根据redhat 7 document一步一步来,我发现最难的地方反而是搜文档,虽然解决方案在其他博客或网站都有,但官方文档永远更让人安心,地址:7.1.4. Upgrading the System Off-line with ISO and Yum
创建目录并挂载
[root@centos7 yum.repos.d]# umount /media/cdrom
[root@centos7 yum.repos.d]# mount -o loop /dev/cdrom /media/cdrom
the
-o
loop
option is required to mount the file as a block device.
检查一下是否挂载成功
[root@centos7 dev]# ls -lh /media/cdrom
total 607K
-rw-r--r--. 1 500 502 14 Jul 5 2014 CentOS_BuildTag
drwxr-xr-x. 3 500 502 2.0K Jul 4 2014 EFI
-rw-r--r--. 1 500 502 611 Jul 5 2014 EULA
-rw-r--r--. 1 500 502 18K Jul 5 2014 GPL
drwxr-xr-x. 3 500 502 2.0K Jul 4 2014 images
drwxr-xr-x. 2 500 502 2.0K Jul 4 2014 isolinux
drwxr-xr-x. 2 500 502 2.0K Jul 4 2014 LiveOS
drwxr-xr-x. 2 500 502 568K Jul 5 2014 Packages
drwxr-xr-x. 2 root root 4.0K Jul 5 2014 repodata
-rw-r--r--. 1 500 502 1.7K Jul 5 2014 RPM-GPG-KEY-CentOS-7
-rw-r--r--. 1 500 502 1.7K Jul 5 2014 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2.9K Jul 7 2014 TRANS.TBL
下一个目标是,创建一个本地的yum源,所有的repository都在目录/etc/yum.repos.d里面
[root@centos7 yum]# cd /etc/yum.repos.d
[root@centos7 yum.repos.d]# ls -l
total 56
-rw-r--r--. 1 root root 1664 Dec 9 17:59 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Dec 9 17:59 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Dec 9 17:59 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 290 Dec 9 17:59 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Dec 9 17:59 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Dec 9 17:59 CentOS-Sources.repo
-rw-r--r--. 1 root root 1952 Dec 9 17:59 CentOS-Vault.repo
-rw-r--r--. 1 root root 209 Jan 7 17:32 dag.repo
-rw-r--r--. 1 root root 957 Nov 26 2014 epel.repo
-rw-r--r--. 1 root root 1056 Nov 26 2014 epel-testing.repo
-rw-r--r--. 1 root root 739 Jun 12 2014 mirrors-rpmforge
-rw-r--r--. 1 root root 717 Jun 12 2014 mirrors-rpmforge-extras
-rw-r--r--. 1 root root 728 Jun 12 2014 mirrors-rpmforge-testing
-rw-r--r--. 1 root root 1128 Dec 18 09:34 rpmforge.repo
我们创建一个centos7的本地repository
vi ./local_centos7.repo
在里面添加如下信息
[local_centos7]
name=local_centos7
baseurl=file:///mnt/cdrom/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
里面各个option的意思如下
- [centos7]: Name of the new repo section.
- name: Name of the new repository.
- baseurl: The current location of the packages.
- Enabled: Enabled repository, value ‘1’ means enable and ‘0’ means disable.
- gpgcheck: Check the signature of the packages, before installing them.
- gpgkey: Location of the key.
刷新一下repository, 好比 source /root/.barshrc 和mysql的flush privileges一样,貌似document没有做这一步操作
[root@centos7 yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base centos7 dag epel extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
验证一下刚配置的centos7 repository看看是否能使用,能使用的repository显示enable否则显示disable
yum repolist all
为什么那么多的repository 只enable了几个而不全部使用呢?我们可以尝试把所有的打开
yum-config-manager --enable \*
关于repository的关闭大开,document位置在这里:Example 7.29. Enabling all repositories
结果是光是查询postgrepSQL这个软件就查询了5分钟,从一大堆网址里面搜,然后挑选速度最快的那个
[root@centos7 yum.repos.d]# yum info postgresql
Loaded plugins: fastestmirror
base-debuginfo | 2.5 kB 00:00:00
base-source | 2.9 kB 00:00:00
file:///media/CentOS/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /media/CentOS/repodata/repomd.xml"
Trying other mirror.
c7-media | 3.6 kB 00:00:00
centosplus | 3.4 kB 00:00:00
centosplus-source | 2.9 kB 00:00:00
cr | 3.3 kB 00:00:00
dag | 1.9 kB 00:00:00
epel/x86_64/metalink | 4.8 kB 00:00:00
epel-debuginfo/x86_64/metalink | 4.9 kB 00:00:00
epel-debuginfo | 3.0 kB 00:00:00
epel-source/x86_64/metalink | 4.8 kB 00:00:00
epel-source | 3.5 kB 00:00:00
epel-testing/x86_64/metalink | 5.2 kB 00:00:00
epel-testing | 4.3 kB 00:00:00
epel-testing-debuginfo/x86_64/metalink | 5.4 kB 00:00:00
epel-testing-debuginfo | 3.0 kB 00:00:00
epel-testing-source/x86_64/metalink | 5.2 kB 00:00:00
epel-testing-source | 3.5 kB 00:00:00
extras | 3.4 kB 00:00:00
extras-source | 2.9 kB 00:00:00
fasttrack | 3.3 kB 00:00:00
local_centos7 | 3.6 kB 00:00:00
rpmforge | 1.9 kB 00:00:00
rpmforge-extras | 1.9 kB 00:00:00
rpmforge-testing | 1.9 kB 00:00:00
updates | 3.4 kB 00:00:00
updates-source | 2.9 kB 00:00:00
c7-media/group_gz FAILED
file:///media/CentOS/repodata/4b9ac2454536a901fecbc1a5ad080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz: [Errno 14] curl#37 - "Couldn't open file /media/CentOS/repodata/4b9ac2454536a901fecbc1a5ad080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz"
Trying other mirror.
(1/19): c7-media/primary_db | 2.7 MB 00:00:00
(2/19): cr/7/x86_64/primary_db | 1.2 kB 00:00:00
(3/19): centosplus/7/x86_64/primary_db | 1.0 MB 00:00:02
(4/19): centosplus-source/7/primary_db | 4.3 kB 00:00:01
(5/19): epel-debuginfo/x86_64/primary_db | 520 kB 00:00:01
(6/19): epel-testing/x86_64/group_gz | 169 kB 00:00:00
(7/19): epel-testing/x86_64/updateinfo | 70 kB 00:00:00
(8/19): epel-testing/x86_64/primary_db | 497 kB 00:00:00
(9/19): epel-testing-debuginfo/x86_64/primary_db | 53 kB 00:00:00
(10/19): epel-testing-source/x86_64/updateinfo | 70 kB 00:00:00
(11/19): epel-testing-source/x86_64/primary_db | 140 kB 00:00:00
(12/19): extras-source/7/primary_db | 5.5 kB 00:00:00
(13/19): fasttrack/7/x86_64/primary_db | 1.2 kB 00:00:00
(14/19): updates-source/7/primary_db | 35 kB 00:00:02
(15/19): c7-media/group_gz | 157 kB 00:00:00
(16/19): epel-source/x86_64/updateinfo | 460 kB 00:00:05
(17/19): base-source/7/primary_db | 949 kB 00:00:15
(18/19): base-debuginfo/x86_64/primary_db | 973 kB 00:00:18
(19/19): epel-source/x86_64/primary_db | 1.3 MB 00:00:48
(1/2): rpmforge-extras/primary_db | 11 kB 00:00:00
(2/2): rpmforge-testing/primary_db | 2.4 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* c7-media:
* centosplus: mirrors.163.com
* epel: mirrors.hustunique.com
* epel-debuginfo: mirrors.hustunique.com
* epel-source: mirrors.hustunique.com
* epel-testing: mirrors.hustunique.com
* epel-testing-debuginfo: mirrors.hustunique.com
* epel-testing-source: mirrors.hustunique.com
* extras: mirrors.163.com
* fasttrack: mirrors.163.com
* rpmforge: mirrors.digipower.vn
* rpmforge-extras: mirrors.digipower.vn
* rpmforge-testing: mirrors.digipower.vn
* updates: mirrors.yun-idc.com
(1/10): C7.0.1406-extras/x86_64/primary_db | 43 kB 00:00:02
(2/10): C7.0.1406-fasttrack/x86_64/primary_db | 124 kB 00:00:03
(3/10): C7.1.1503-centosplus/x86_64/primary_db | 2.2 MB 00:02:24
(4/10): C7.1.1503-extras/x86_64/primary_db | 120 kB 00:00:04
(5/10): C7.1.1503-fasttrack/x86_64/primary_db | 71 kB 00:00:04
(6/10): C7.0.1406-centosplus/x86_64/primary_db | 3.5 MB 00:02:54
(7/10): C7.1.1503-base/x86_64/primary_db | 5.1 MB 00:04:32
(8/10): C7.0.1406-updates/x86_64/primary_db | 7.2 MB 00:05:22
(9/10): C7.0.1406-base/x86_64/primary_db | 4.9 MB 00:05:24
(10/10): C7.1.1503-updates/x86_64/primary_db | 4.7 MB 00:05:12
Available Packages
Name : postgresql
Arch : i686
Version : 9.2.14
Release : 1.el7_1
Size : 3.0 M
Repo : C7.1.1503-updates/x86_64
Summary : PostgreSQL client programs
URL : http://www.postgresql.org/
License : PostgreSQL
Description : PostgreSQL is an advanced Object-Relational database management system (DBMS).
: The base postgresql package contains the client programs that you'll need to
: access a PostgreSQL DBMS server, as well as HTML documentation for the whole
: system. These client programs can be located on the same machine as the
: PostgreSQL server, or on a remote machine that accesses a PostgreSQL server
: over a network connection. The PostgreSQL server can be found in the
: postgresql-server sub-package.
Name : postgresql
Arch : x86_64
Version : 9.2.14
Release : 1.el7_1
Size : 3.0 M
Repo : C7.1.1503-updates/x86_64
Summary : PostgreSQL client programs
URL : http://www.postgresql.org/
License : PostgreSQL
Description : PostgreSQL is an advanced Object-Relational database management system (DBMS).
: The base postgresql package contains the client programs that you'll need to
: access a PostgreSQL DBMS server, as well as HTML documentation for the whole
: system. These client programs can be located on the same machine as the
: PostgreSQL server, or on a remote machine that accesses a PostgreSQL server
: over a network connection. The PostgreSQL server can be found in the
: postgresql-server sub-package.
[3]- Killed yum repolist all
禁止全部的repository
yum-config-manager --disable \*
只使用刚才配置的repository
yum-config-manager --enable local_centos7
确认一下
yum repolist all
这样我们搜索一个软件就很快出现了
[root@centos7 yum.repos.d]# yum info httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
Name : httpd
Arch : x86_64
Version : 2.4.6
Release : 17.el7.centos.1
Size : 2.7 M
Repo : local_centos7
Summary : Apache HTTP Server
URL : http://httpd.apache.org/
License : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.