Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1094208
  • 博文数量: 286
  • 博客积分: 3124
  • 博客等级: 中校
  • 技术积分: 5186
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-24 23:42
个人简介

Bomi

文章存档

2015年(1)

2013年(1)

2012年(281)

2008年(3)

分类: 虚拟化

2012-02-05 11:56:25

相比OpenSolaris2008.05,OpenSolaris2008.11修正了一些bug,并且在很多方面都有了突出的改进,对硬件的支持也越来越好了。为了让实验室的朋友们都能感受OpenSolaris2008.11的魅力,最近我在Xen 3.3上以全虚拟化的方式安装了OpenSolaris操作系统。服务器配置:Intel(R) Xeon(R) CPU E5310 @ 1.60GHz8核,4G内存。安装过程很顺利,运行起来效果良好。

在我们的服务器上,已经安装好了Xen3.3,并以RedhatLinux作为Dom 0,所以OpenSolaris只能以全虚拟化的形式在Dom U里安装了。当然,Sun也推出了基于XenxVM Server,其Dom 0是由Solaris来充当的。下面介绍具体的安装过程:
首先把OpenSolaris的安装镜像ISO文件下载到本地目录~/OpenSolaris/iso/


第二步,用命令dd if=/dev/zero f=~/OpenSolaris/OpenSolaris.img bs=1k seek=40M count=1创建一个磁盘镜像,该磁盘镜像被虚拟机当作硬盘使用。磁盘文件的名字为OpenSolaris.img,大小为40G。(注意:用该命令创建的磁盘镜像文件的大小是随着磁盘内容的增加而动态增长的,刚创建好磁盘镜像时用ls –l命令查看到的大小40G并不是真实占用的空间,用du –sh命令可以看到刚创建好的磁盘镜像占用空间只有16K
第三步,写一个配置文件~/OpenSolaris/OpenSolaris.cfg,内容如下:
#-----------------------------------------------------------------------------
import os, re
arch =os.uname()[4]
ifre.search('64', arch):

arch_libdir = 'lib64'
else:

arch_libdir = 'lib'
#----------------------------------------------------------------------------
# Kernel imagefile.
kernel ="/usr/lib/xen/boot/hvmloader"
#-----------------------------------------------------------------------------
# The domainbuild function. HVM domain uses 'hvm'.
builder='hvm'
#-----------------------------------------------------------------------------
# Initialmemory allocation (in megabytes) for the new domain.
#
# WARNING:Creating a domain with insufficient memory may cause out of
#
memory errors. The domain needsenough memory to boot kernel
#
and modules. Allocating less than32MBs is not recommended.
#内存大小设置为2G
memory = 2048
#-----------------------------------------------------------------------------
# A name foryour domain. All domains must have different names.
#虚拟机的名字为OpenSolaris
name ="OpenSolaris"
#-----------------------------------------------------------------------------
# The number ofcpus guest platform. has, default=1
#虚拟CPU的个数为4
vcpus=4
#-----------------------------------------------------------------------------
# Optionallydefine mac and/or bridge for the network interfaces.
# Random MACsare assigned if not given.
#vif = ['type=ioemu, mac=00:16:3e:00:00:11, bridge=xenbr0, model=ne2k_pci' ]
# type=ioemuspecify the NIC is an ioemu device not netfront
#vif = ['type=ioemu, bridge=xenbr0' ]
#网卡使用eth0物理网卡
vif = ['type=ioemu, bridge=eth0' ]
#----------------------------------------------------------------------------
# Define thedisk devices you want the domain to have access to, and
# what you wantthem accessible as.
# Each diskentry is of the form. phy:UNAME,DEV,MODE
# where UNAMEis the device, DEV is the device name the domain will see,
# and MODE is rfor read-only, w for read-write.
#磁盘镜像文件使用file:/home/haiou/OpenSolaris/OpenSolaris.img,同时把file:/home/haiou/OpenSolaris/iso/OpenSolaris.iso当作光驱使用。
disk = ['file:/home/haiou/OpenSolaris/OpenSolaris.img,hda,w', 'file:/home/haiou/OpenSolaris/iso/OpenSolaris.iso,hdc:cdrom,r']
#----------------------------------------------------------------------------
# Device Modelto be used
device_model ='/usr/' + arch_libdir + '/xen/bin/qemu-dm'
#-----------------------------------------------------------------------------
# boot onfloppy (a), hard disk (c), Network (n) or CD-ROM (d)
# default: harddisk, cd-rom, floppy
#boot="cda"
#设置为从光驱启动
boot="d"
#----------------------------------------------------------------------------
# enable SDLlibrary for graphics, default = 0
sdl=0
#----------------------------------------------------------------------------
# enable OpenGLfor texture rendering inside the SDL window, default = 1
# valid only ifsdl is enabled.
pengl=1
#----------------------------------------------------------------------------
# enable VNClibrary for graphics, default = 1
#启动后通过vnc连接访问其图形界面
vnc=1
#----------------------------------------------------------------------------
# address thatshould be listened on for the VNC server if vnc is set.
# default is touse 'vnc-listen' setting from /etc/xen/xend-config.sxp
#允许任何IP使用vnc服务
vnclisten="0.0.0.0"
#----------------------------------------------------------------------------
# set VNCdisplay number, default = domid
#vncdisplay=1
#----------------------------------------------------------------------------
# try to findan unused port for the VNC server, default = 1
#vncunused=1
#----------------------------------------------------------------------------
# set passwordfor domain's VNC console
# default isdepents on vncpasswd in xend-config.sxp
#没有设置vnc密码
vncpasswd=''
#----------------------------------------------------------------------------
# enablestdvga, default = 0 (use cirrus logic device model)
stdvga=0
#-----------------------------------------------------------------------------
#
serial port re-direct to pty deivce,/dev/pts/n
#
then xm console or minicom can connect
serial='pty'


第四步,使用命令sudo xm create ~/OpenSolaris/OpenSolaris.cfg来启动虚拟机,并用命令sudo xm list来查看相应状态。


第五步,通过命令vncviewer 127.0.0.1命令来访问其图形界面。注意:有时端口被其它虚拟机占用时需要用IP:1IP:2(依此类推)来访问。接下来就和在物理机上安装OpenSolaris一样了。


最后在安装好系统后,将配置文件稍作修改:一个是将disk设置改为disk = ['file:/home/haiou/OpenSolaris/OpenSolaris.img,hda,w' ],因为不再需要光驱;另一个是将boot=d改为boot=c,不再从光驱启动,而是从硬盘启动。


在安装好OpenSolaris后,开始对网络进行配置。首先在图形界面中配置好IPgatewayDNS等,然后对/etc/nsswitch.conf这个配置文件进行修改,即将hosts: files一行修改为hosts: files dns(即在hosts一行后加上“dns);但是重启网络后发现还是上不了网,更奇怪的是所有的IPping的通,但就是ping不通URL,于是怀疑是iptables的原因,试探性的用iptables –Fiptables禁掉,就可以上网了,果然是iptables的问题;最后在/etc/sysconfig/iptables文件中加上两行:
-A RH-Firewall-1-INPUT -m state --state NEW-m tcp -p tcp --dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW-m udp -p udp --dport 53 -j ACCEPT
重启iptables后就可以正常上网了。
阅读(534) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~