相比OpenSolaris2008.05, OpenSolaris2008.11修正了一些bug,并且在很多方面都有了突出的改进,对硬件的支持也越来越好了。为了让实验室的朋友们都能感受OpenSolaris2008.11的魅力,最近我在Xen 3.3上以全虚拟化的方式安装了OpenSolaris操作系统。服务器配置:Intel(R) Xeon(R) CPU E5310 @ 1.60GHz,8核,4G内存。安装过程很顺利,运行起来效果良好。
在我们的服务器上,已经安装好了Xen3.3,并以Redhat Linux作为Dom 0,所以OpenSolaris只能以全虚拟化的形式在Dom U里安装了。当然,Sun也推出了基于Xen的xVM Server,其Dom 0是由Solaris来充当的。下面介绍具体的安装过程:
首先把OpenSolaris的安装镜像ISO文件下载到本地目录~/OpenSolaris/iso/。
第二步,用命令dd if=/dev/zero of=~/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]
if re.search('64', arch):
arch_libdir = 'lib64'
else:
arch_libdir = 'lib'
#----------------------------------------------------------------------------
# Kernel image file.
kernel = "/usr/lib/xen/boot/hvmloader"
#-----------------------------------------------------------------------------
# The domain build function. HVM domain uses 'hvm'.
builder='hvm'
#-----------------------------------------------------------------------------
# Initial memory allocation (in megabytes) for the new domain.
#
# WARNING: Creating a domain with insufficient memory may cause out of
# memory errors. The domain needs enough memory to boot kernel
# and modules. Allocating less than 32MBs is not recommended.
#内存大小设置为2G
memory = 2048
#-----------------------------------------------------------------------------
# A name for your domain. All domains must have different names.
#虚拟机的名字为OpenSolaris
name = "OpenSolaris"
#-----------------------------------------------------------------------------
# The number of cpus guest platform has, default=1
#虚拟CPU的个数为4
vcpus=4
#-----------------------------------------------------------------------------
# Optionally define mac and/or bridge for the network interfaces.
# Random MACs are assigned if not given.
#vif = [ 'type=ioemu, mac=00:16:3e:00:00:11, bridge=xenbr0, model=ne2k_pci' ]
# type=ioemu specify the NIC is an ioemu device not netfront
#vif = [ 'type=ioemu, bridge=xenbr0' ]
#网卡使用eth0物理网卡
vif = [ 'type=ioemu, bridge=eth0' ]
#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for 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 Model to be used
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
#-----------------------------------------------------------------------------
# boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
#boot="cda"
#设置为从光驱启动
boot="d"
#----------------------------------------------------------------------------
# enable SDL library for graphics, default = 0
sdl=0
#----------------------------------------------------------------------------
# enable OpenGL for texture rendering inside the SDL window, default = 1
# valid only if sdl is enabled.
opengl=1
#----------------------------------------------------------------------------
# enable VNC library for graphics, default = 1
#启动后通过vnc连接访问其图形界面
vnc=1
#----------------------------------------------------------------------------
# address that should be listened on for the VNC server if vnc is set.
# default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp
#允许任何IP使用vnc服务
vnclisten="0.0.0.0"
#----------------------------------------------------------------------------
# set VNC display number, default = domid
#vncdisplay=1
#----------------------------------------------------------------------------
# try to find an unused port for the VNC server, default = 1
#vncunused=1
#----------------------------------------------------------------------------
# set password for domain's VNC console
# default is depents on vncpasswd in xend-config.sxp
#没有设置vnc密码
vncpasswd=''
#----------------------------------------------------------------------------
# enable stdvga, 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:1、IP:2(依此类推)来访问。接下来就和在物理机上安装OpenSolaris一样了。
最后在安装好系统后,将配置文件稍作修改:一个是将disk设置改为disk = [ 'file:/home/haiou/OpenSolaris/OpenSolaris.img,hda,w' ],因为不再需要光驱;另一个是将boot=d改为boot=c,不再从光驱启动,而是从硬盘启动。
在安装好OpenSolaris后,开始对网络进行配置。首先在图形界面中配置好IP、gateway、DNS等,然后对/etc/nsswitch.conf这个配置文件进行修改,即将hosts: files一行修改为hosts: files dns(即在hosts一行后加上“dns”);但是重启网络后发现还是上不了网,更奇怪的是所有的IP都ping的通,但就是ping不通URL,于是怀疑是iptables的原因,试探性的用iptables –F将iptables禁掉,就可以上网了,果然是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后就可以正常上网了。
阅读(569) | 评论(0) | 转发(0) |