楼主: 种过一豆
收起左侧

[分享] Oracle VirtualBox 安装使用一条龙教程

  [复制链接]
种过一豆
 楼主| 发表于 2011-6-20 17:51:05 | 显示全部楼层
本帖最后由 种过一豆 于 2011-10-23 09:50 编辑

virtualbox 虚拟机克隆


      4.1.4有了方便的克隆功能(前一个小版本就有了吧,不知道记错了没有),现在实现VirtualBox的克隆也就是点点鼠标的事情,下面简单举一个例子,更多的东西有兴趣的人去深入挖掘一下:



1.png
2.png
3.png
4.png
5.png
6.png

      当然了,还可以在链接克隆基础上的虚拟系统中再链接一份出来,操作步骤一样,只需要定位到克隆出来的系统中再次重复操作一次克隆步骤,完成后效果如下图:


7.png






============== 以下繁琐的操作仅供有爱好的人去试验了================



    首先在开始运行里面敲入cmd命令  打开命令提示符,在cmd提示符中连续敲入cd..命令退回到C盘根目录下

    敲入cd命令进入vbox程序的安装目录  C:\>cd "Program Files\Oracle\VirtualBox"


1.jpg


    如果没有修改安装路径的话vboxmanage.exe程序应该是在Program Files\Oracle\VirtualBox目录下

    进入vboxmanage.exe 所在的目录后就可以着手虚拟机克隆

    敲入命令 vboxmanage clonehd 原始镜像文件路径+名称 新的镜像文件路径+名称


    例如:我的虚拟机镜像文件路径是系统默认保存的,在C:\Documents and Settings\Administrator\VirtualBox VMs下,这时需要克隆一份windows 2003的系统,同时克隆的系统依然放在windows 2003的目录下,只需要进行如下操作

vboxmanage clonehd “C:\Documents and Settings\Administrator\VirtualBox VMs\windows 2003\windows 2003-disk1.vmdk” “C:\Documents and Settings\Administrator\VirtualBox VMs\windows 2003\windows 2003-disk2.vmdk”


2.jpg

    敲入上面命令之后一份一样的系统就被克隆出来了,进入windows 2003 的文件夹可以看到一个新vmdk文件诞生


3.jpg



    红圈圈捆起来的就是........

    不过这时打开vbox主程序还是看不到这个被克隆的虚拟机的,需要新建一个虚拟机,名称与之前的windows 2003 不一样,比如取名为2003 ,到创建硬盘镜像的时候选择已经存在的hard disk,找到新克隆的那个镜像下一步即可


4.jpg



    再次打开vbox主程序就可以看到两份一样的2003系统,大功告成,重启系统进去看看吧


5.jpg


种过一豆
 楼主| 发表于 2011-6-20 17:51:53 | 显示全部楼层
本帖最后由 种过一豆 于 2011-10-23 09:30 编辑

Virtualbox 差分磁盘实现



        差分磁盘挺好用,具体的差分磁盘语义上的界定就不说了,比较讨厌咬文嚼字......


        看图示操作即可


1.jpg


2.jpg


3.jpg


4.jpg


5.jpg


6.jpg


7.jpg


8.jpg


9.jpg


10.jpg


11.jpg


       至于在新建立的虚拟机中再生成快照的时候,也要把autoreset属性通过上面的方法off掉,还原的时候又要重新设置(因为uuid变化了),有点小麻烦


       下面再说一下如何把原来释放掉磁盘的虚拟机利用起来

12.jpg


13.jpg


14.jpg


15.jpg


16.jpg
种过一豆
 楼主| 发表于 2011-6-20 17:52:27 | 显示全部楼层
本帖最后由 种过一豆 于 2011-6-25 07:43 编辑

上传的图已经太多了

贴几个传送门的链接吧


virtualbox 安装android 视频教程

http://bbs.kafan.cn/forum.php?mo ... ;extra=#pid19167517




种过一豆
 楼主| 发表于 2011-6-20 17:52:55 | 显示全部楼层
本帖最后由 种过一豆 于 2011-6-23 18:41 编辑

虚拟系统磁盘扩容



1.jpg


2.jpg


3.jpg


4.jpg


5.jpg


6.jpg


7.jpg


8.jpg


9.jpg


10.jpg


11.jpg


12.jpg


13.jpg


14.jpg


15.jpg


16.jpg


17.jpg


18.jpg


19.jpg


20.jpg


21.jpg


22.jpg


windows下添加磁盘很是麻烦,如果其他平台就相对容易一些(dd if=/dev/sda of=/dev/sdb bs=  count=  .....命令就可以实现)
种过一豆
 楼主| 发表于 2011-6-20 17:53:26 | 显示全部楼层
本帖最后由 种过一豆 于 2011-11-27 13:18 编辑

这里讲一点VirtualBox的网络使用问题



Network Address Translation (NAT) is the simplest way of accessing an external network from a virtual machine. Usually, it does not require any configuration on the host network and guest system. For this reason, it is the default networking mode in VirtualBox.

A virtual machine with NAT enabled acts much like a real computer that connects to the Internet through a router. The "router", in this case, is the VirtualBox networking engine, which maps traffic from and to the virtual machine transparently. The disadvantage of NAT mode is that, much like a private network behind a router, the virtual machine is invisible and unreachable from the outside internet; you cannot run a server this way unless you set up port forwarding

Security Features --- Networking


The default networking mode for VMs is NAT which means that the VM acts like a computer behind a router, see the section called “Network Address Translation (NAT)”. The guest is part of a private subnet belonging to this VM and the guest IP is not visible from the outside. This networking mode works without any additional setup and is sufficient for many purposes.

If bridged networking is used, the VM acts like a computer inside the same network as the host, see the section called “Bridged networking”. In this case, the guest has the same network access as the host and a firewall might be necessary to protect other computers on the subnet from a potential malicious guest as well as to protect the guest from a direct access from other computers. In some cases it is worth considering using a forwarding rule for a specific port in NAT mode instead of using bridged networking.

Some setups do not require a VM to be connected to the public network at all. Internal networking (see the section called “Internal networking”) or host-only networking (see the section called “Host-only networking”) are often sufficient to connect VMs among each other or to connect VMs only with the host but not with the public network.


      上面这段手册里面说的大概内容就是nat联网方式是VirtualBox虚拟机默认的,nat方式联网guest处于私有网络中,也是比较安全的一种联网方式,在nat联网方式下外部机器无法直接访问guest;


      实现端口映射可以用vboxmanage命令,官方手册上的说明如下,当然了,能不用command就不用,这样太麻烦了,下面会简单说一下如何在GUI界面操作映射:

You will need to know which ports on the guest the service uses and to decide which ports to use on the host (often but not always you will want to use the same ports on the guest and on the host). You can use any ports on the host which are not already in use by a service. For example, to set up incoming NAT connections to an ssh server in the guest, use the following command:

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"

With the above example, all TCP traffic arriving on port 2222 on any host interface will be forwarded to port 22 in the guest. The protocol name tcp is a mandatory attribute defining which protocol should be used for forwarding (udp could also be used). The name guestssh is purely descriptive and will be auto-generated if omitted. The number after --natpf denotes the network card, like in other parts of VBoxManage.

To remove this forwarding rule again, use the following command:

VBoxManage modifyvm "VM name" --natpf1 delete "guestssh"

If for some reason the guest uses a static assigned IP address not leased from the built-in DHCP server, it is required to specify the guest IP when registering the forwarding rule:

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,10.0.2.19,22"

This example is identical to the previous one, except that the NAT engine is being told that the guest can be found at the 10.0.2.19 address.

To forward all incoming traffic from a specific host interface to the guest, specify the IP of that host interface like this:

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,127.0.0.1,2222,,22"

This forwards all TCP traffic arriving on the localhost interface (127.0.0.1) via port 2222 to port 22 in the guest.


      [注解]:一般来说nat方式联网是最适用的,不管是adsl拨号还是通过路由器的网络环境联网,在主机能够联网的情况下通过nat方式虚拟机都可以联网

      NAT方式下虚拟机ping主机可以ping通,反过来是不行的(换句话说虚拟机可以访问主机,而主机没有办法直接访问虚拟机)

      虚拟机nat下ping主机192.168.1.135  ------- 主机ip地址可以通过ipconfig /all 命令查看,也可以通过双击网络连接在图形界面上看到:

主机ip地址查看  --------  192.168.1.135

2.png

虚拟机ip地址查看  --------  10.0.2.15

3.png

虚拟机ping主机 ---- 通

1.png

主机ping虚拟机 --- 不通

4.png

      如果在虚拟机里面架设了一个服务器(这里我拿ftp服务器的例子来讲解),直接访问是不行的,不过可以通过端口映射功能实现在nat方式下主机访问虚拟机的ftp服务(不用命令了,直接图形界面操作吧)

----------------------- ServU服务器例子--------------------


      架设好相关服务后,直接在主机浏览器或者相对应服务器的客户端访问虚拟机服务访问不了(这里我拿浏览器直接访问虚拟机ftp服务器)

无法访问
5.png

打开虚拟机nat网卡设置 Port Forwarding ,添加端口映射,把虚拟机的相对应服务器端口映射出来
6.png

比如添加一条:
主机访问虚拟机ftp服务器的映射 协议选ftp, hostip填物理机器上的ip, hostport选一个1024以后未被占用的端口(不要超过65535)比如12345,guestip填虚拟机ip地址,guestport填对应服务器用到的端口比如ftp--21
7.png

添加完成后访问虚拟机服务器只需要通过 ftp:\\192.168.1.135:12345 即可

输入用户名密码
8.png

ok,可以看到内容
9.png
10.png


http服务器也是可以通过类似的方法添加端口映射访问的:

11.png
12.png

================

Host-only networking
Host-only networking is another networking mode that was added with version 2.2 of VirtualBox. It can be thought of as a hybrid between the bridged and internal networking modes: as with bridged networking, the virtual machines can talk to each other and the host as if they were connected through a physical ethernet switch. Similarly, as with internal networking however, a physical networking interface need not be present, and the virtual machines cannot talk to the world outside the host since they are not connected to a physical networking interface.

Instead, when host-only networking is used, VirtualBox creates a new software interface on the host which then appears next to your existing network interfaces. In other words, whereas with bridged networking an existing physical interface is used to attach virtual machines to, with host-only networking a new "loopback" interface is created on the host. And whereas with internal networking, the traffic between the virtual machines cannot be seen, the traffic on the "loopback" interface on the host can be intercepted.

Host-only networking is particularly useful for preconfigured virtual appliances, where multiple virtual machines are shipped together and designed to cooperate. For example, one virtual machine may contain a web server and a second one a database, and since they are intended to talk to each other, the appliance can instruct VirtualBox to set up a host-only network for the two. A second (bridged) network would then connect the web server to the outside world to serve data to, but the outside world cannot connect to the database.




nat下想让host跟guest互通还可以通过添加host-only来实现...

host-only类似于vmware下面网络设置的vmnet1/vmnet8虚拟交换机,主机跟虚拟机通过host-only连接在同一个子网内(许多人觉得这个host-only没有什么意义,其实这个host-only是很方便的,在虚拟机使用nat方式联网的时候,主机可以通过host-only方便地访问虚拟机内的资源,看起来这个方式比nat下的端口映射要麻烦一些,其实用起来会感觉到这种方式会更方便)

在用host-only之前,需要到VirtualBox全局设置里面检查一下有没有添加好host-only网络
1.png

如果看到下图所示那么就可以,如果没有看到点击那个带 加号 的按钮添加一个,第三个螺丝刀一样图标的是用来配置的,有兴趣可以点进去看一些详细的ip地址池情况,可以自己设置喜欢的私有地址
2.png

还需要检查主机网络连接里面的host-only有没有开启(当然平时一般是用不到这个东西的,不需要的时候可以禁用掉host-only,不过开着也不碍事)
3.png

检查完毕后到相应虚拟机里面设置网卡(一块默认为nat方式联网,一块设置host-only方式跟主机互连)

4.png
5.png

启动虚拟机后会发现多了一块网卡,但是却没有分配到ip地址(有个感叹号的那个就是没有成功分配ip地址的)
7.png

点开主机host-only的图标,然后找到详细信息,可以看到默认的是192.168.250.0网断,子网掩码默认为c类ip地址的255.255.255.0
6.png

我们手动给虚拟机的网络连接2分配一个ip地址比如192.168.250.2,子网掩码跟主机那边看到的一样255.255.255.0,其他的不用填写
8.png
查找路由表可以看到主机里面192.168.250.0网段的数据转交给了192.168.250.1,再转发到虚拟机内部
12.png

这里以一个web服务器来做试验,设置完上面的步骤以后,我们在主机访问虚拟机web服务

打开浏览器,在里面输入刚才为虚拟机网络连接2指定的ip地址192.168.250.2
9.png

已经可以顺利地访问到虚拟机的相关服务了

如果此时断开host-only网卡的电源就不能访问web服务器,说明我们刚才的设置确实是为主机访问虚拟机相关服务提供了极大的便利(不需要切换到bridge方式下,毕竟bridge方式联网直接把虚拟机暴露给了局域网)
10.png
11.png







-------------------------------------------------
      Bdidge 方式联网---- 还需要解释么,就把guest当做局域网内另外一台独立的主机看待就好,让其自动获取或者是填上跟主机同一个网段内可用的ip地址即可,当然如果主机是直接连adsl/modem方式上网的话bridge方式联网就不一定能够行得通了......

       另外adsl方式下如果想实现主机跟物理机同时拨号的也是采用桥接联网的方式,不过前提是当地的ISP允许单帐户多拨号


......




      





评分

参与人数 1人气 +1 收起 理由
士兵许三多 + 1 下载才认真来看此贴,乃真是厉害!

查看全部评分

zby_1991
发表于 2011-6-20 18:01:37 | 显示全部楼层
这~~好后面的沙发啊···
编辑量比较恐怖

慢慢看
种过一豆
 楼主| 发表于 2011-6-20 18:04:15 | 显示全部楼层
zby_1991 发表于 2011-6-20 18:01
这~~好后面的沙发啊···
编辑量比较恐怖

沙花费

编辑量不小


主要是我都很懒的做神马教程,既然做了就详细点,把别人电脑卡死,那是一种乐趣
zby_1991
发表于 2011-6-20 18:08:03 | 显示全部楼层
种过一豆 发表于 2011-6-20 18:04
沙花费

编辑量不小

刚进来就掏了~~

~~全放一层,乐趣大大的
种过一豆
 楼主| 发表于 2011-6-20 18:10:51 | 显示全部楼层
zby_1991 发表于 2011-6-20 18:08
刚进来就掏了~~

~~全放一层,乐趣大大的

差分磁盘的暂时受不了了

zby_1991
发表于 2011-6-20 18:13:38 | 显示全部楼层
种过一豆 发表于 2011-6-20 18:10
差分磁盘的暂时受不了了

直接放原来那个链接呗~~
您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

手机版|杀毒软件|软件论坛| 卡饭论坛

Copyright © KaFan  KaFan.cn All Rights Reserved.

Powered by Discuz! X3.4( 沪ICP备2020031077号-2 ) GMT+8, 2024-12-22 20:50 , Processed in 0.132778 second(s), 17 queries .

卡饭网所发布的一切软件、样本、工具、文章等仅限用于学习和研究,不得将上述内容用于商业或者其他非法用途,否则产生的一切后果自负,本站信息来自网络,版权争议问题与本站无关,您必须在下载后的24小时之内从您的电脑中彻底删除上述信息,如有问题请通过邮件与我们联系。

快速回复 客服 返回顶部 返回列表