Centos6.5安装Virtualbox并在vbox上安装配置Centos6.5mini
一,环境信息
硬件:笔记本
操作系统:Centos 6.5 64位
安装用户:root
二,安装步骤
1,安装关联的package
#yum install kernel kernel-headers kernel-devel gcc make
2,查看下载的内核代码版本
1)ls /usr/src/kernels/
2)2.6.32-421.29.2.el6.x86_64
查看本机的内核版本
1)uname -r
2.6.32-431.29.2.el6.x86_64
上面2个版本一定要一致,不然会有问题。内核升级后reboot,后执行如下命令:
uname -r
2.6.32-431.29.2.el6.x86_64
这时,2个版本一致了。
3,开始安装VirtualBox
1) cd /etc/yum.repos.d/
2) wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
3)yum install VirtualBox-4.3
4,将用户分配到vb组中
/usr/sbin/usermod -a -G vboxusers root
5,执行# /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel modules [确定]
Recompiling VirtualBox kernel modules [确定]
Starting VirtualBox kernel modules [确定]
6,启动Virtualbox
virtualbox
三,常见错误
1,下载VirtualBox-4.3-4.3.26_98988_el6-1.x86_64.rpm安装,报如下错:
Makefile:183: * Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again\u3002 \u505c\u6b62\u3002
原因:没有内核原文件
解决方法:
先安装gcc kernel kernel-devel等程序
1)yum install gcc 从软件仓库下载gcc,然后安装,这个是编译器
2)yum install make 安装make,这个是自动编译源码的工具,写好makefile就可以方便编译
3)yum install kernel-headers 安装内核,编译内核,驱动必要的
4)yum install kernel-devel 同上
5)yum install kernel
2,启动virtualbox时,报如下错:
virtualbox
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (2.6.32-431.29.2.el6.x86_64) or it failed to load. Please recompile the kernel module and install it by
sudo /etc/init.d/vboxdrv setup
You will not be able to start VMs until this problem is fixed.
解决方法:执行#/etc/init.d/vboxdrv setup
CentOS6.5下ping不通外网但能ping通内网的解决办法(vbox虚拟机里遇到方法相同)
问题描述
[root@localhost ~]# ping www.baidu.com
ping: unknown host www.baidu.com
解决方法
1.首先确定已经连接上路由器,并且路由器能够访问外网,可以通过访问网关进行确定
[root@localhost ~]# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.96 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.75 ms
如果确定网络没问题的情况下, 可以通过如下步骤寻找解决办法:
- 确定设置了域名服务器, 没有的话, 建议设置Google的公共DNS服务, 它应该不会出问题的 8.8.8.8
[root@localhost ~]# cat /etc/resolv.conf //查看是否设置域名服务器
[root@localhost ~]# vi /etc/resolv.conf
加入下面两行:
nameserver 8.8.8.8
nameserver 114.114.114.114
- 确保网关已设置
查看命令 :
grep GATEWAY /etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=192.168.40.1
如果未设置, 则通过如下方式增加网关:
route add default gw 192.168.1.1
或者手工编写/etc/sysconfig/network-scripts/ifcfg*文件后, 重启network服务:
service network restart
3) 确保可用dns解析
grep hosts /etc/nsswitch.conf
hosts: files dns
virtualbox虚拟机安装centos6.5及配置上网
1.打开VBox,并且创建CentOS 6.5 64位环境。
a)新建 虚拟机 环境,由于VBox环境没有CentOS的选项,所以可以选择other Linux(64Bit)
b)动态分配硬盘大小所以你可以选择大一点的硬盘空间 我设置32G(不用的话不会占用的)
2、下载CentOS 6.5 mimi系统
CentOS系统官网:http://www.centos.org
CentOS6.5 mini 安装和基本配置(https://blog.csdn.net/qq_15145665/article/details/72859034)
mini版和完整版的安装是有区别的,有些东西是自动默认安装的,像引导,主机名,分区
1。安装选择界面,这个选第一个
2。镜像完整性检查,一般都是跳过SKIP
3。进入安装了
4。语言选择,简体中文
5。键盘布局,用默认的us
6。这里会给一个警告,提示要初始化你的磁盘,选初始化Re-initialize,多块磁盘可以选第四个
7。时区选择,亚洲/上海
8。设置root密码
9。磁盘分区类型
使用整个磁盘
替换已有的linux系统
使用空闲空间
选前两个都可以
删除改写磁盘
然后就是安装系统,引导,设置主机名,不用管,自动完成
10。安装完成,重启
centos6.5 minimal 基本环境配置
1.启动网卡,默认网卡是不启动的
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=no 改为 yes
#service network restart 重启网络
2.配置sshd
mini默认安装sshd,
在 /etc/hosts.deny 和 /etc/hosts.allow 最后都加上一句 sshd:ALL ,保存
#service sshd restart
3.关闭selinux
#vi /etc/selinux/config
将 SELINUX=enforcing 改成 SELINUX=disabled,保存。
重启系统 reboot
4.配置yum源
yum -y install wget //安装下载工具
cd /etc/yum.repos.d/ //进入yum配置文件目录
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo //下载网易的源配置文件
导入CentOS-6的GPG证书
#rpm --import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6 //这句可用可不用
在所有mirrorlist前面加上#,把所有KaTeX parse error: Expected 'EOF', got '#' at position 19: …easever替换成6,保存 #̲sed -i '/mirror…/d’ CentOS-Base-163.repo
#sed -i ‘s/$releasever/6/’ CentOS-Base-163.repo
#sed -i ‘s/RPM-GPG-KEY-CentOS-5/RPM-GPG-KEY-CentOS-6/’ CentOS-Base-163.repo
mv CentOS-Base.repo CentOS-Base.repo.bak //备份旧的配置文件
#mv CentOS6-Base-163.repo CentOS-Base.repo //把下载的配置文件改名
yum clean all //清理缓存
yum makecache //更新缓存
yum update //更新系统
5.安装常用软件包
yum -y install vim
yum -y install gcc gcc-c++ make
在虚拟机VirtualBox中centos6.5网络设置
1.点击创建好的虚拟机,选择设置–》网络–》1网卡选择桥接,eth0
2.网卡2,ok保存
顺序不能乱,我的网卡在设置过程中顺序乱了也会受影响,切记