Solaris的虚拟化:在Solaris 10 下的 zone创建实例

常见的Unix虚拟化技术有硬分区,软分区。

其中的硬分区,惠普对应nPar,IBM对应LPAR,Sun对应动态系统域domain;

软分区中,惠普对应vPar, IBM对应Micro-parition, Sun 对应N1 grid container或zone。

 

这里是本人在x86的solaris10中创建zone的一个具体实例。

 

solaris10的环境如下:

bash-3.00# uname -a
SunOS Sol10X86 5.10 Generic i86pc i386 i86pc
bash-3.00# hostname
Sol10X86

bash-3.00# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        zone zone01
        inet 127.0.0.1 netmask ff000000
pcn0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.11.11.42 netmask ffffff00 broadcast 10.11.11.255
        ether 0:c:29:db:e4:86

 

 

首先创建zone使用的目录:

 

bash-3.00# mkdir /zone
bash-3.00#  cd /zone
bash-3.00#  mkdir zone01
bash-3.00# chmod -r 700 zone01

 

 

创建新zone的配置信息:

bash-3.00# zonecfg -z zone01
zone01: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:zone01> create
zonecfg:zone01> set zonepath=/zone/zone01
zonecfg:zone01> add net
zonecfg:zone01:net> set address=10.11.11.94
zonecfg:zone01:net> set physical=pcn0
zonecfg:zone01:net> end
zonecfg:zone01> verify
zonecfg:zone01> commit
zonecfg:zone01> exit

 

Install Zone:

 

bash-3.00# zoneadm -z zone01 install
Preparing to install zone <zone01>.
Creating list of files to copy from the global zone.
Copying <2932> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1360> packages on the zone.
Initialized <1360> packages on zone.
Zone <zone01> is initialized.
Installation of these packages generated warnings: <SUNWvtsr>
The file </zone/zone01/root/var/sadm/system/logs/install_log> contains a log of
the zone installation.

 

启动zone:

bash-3.00# zoneadm -z zone01 boot

zlogin: zone 'zone1' unknown

 

登录Zone:

bash-3.00# zlogin -C zone01
[Connected to zone 'zone01' console]
44/947/950/966/99
99/99

 

最初登录时需要填写选择一些信息,如语言,region,terminal type,hostname,root密码等等。

基本上比较简单。下面是部分配置信息:

 

Select a Language

   0. English
   1. French
   2. German
   3. Italian
   4. Japanese
   5. Korean
   6. Simplified Chinese
   7. Spanish
   8. Swedish
   9. Traditional Chinese

Please make a choice (0 - 9), or press h or ? for help: 0

 

Select a Locale

   0. English (C - 7-bit ASCII)
   1. Albania (ISO8859-2)
   2. Australia (ISO8859-1)
   3. Belgium-Flemish (ISO8859-1)
   4. Belgium-Flemish (ISO8859-15 - Euro)
   5. Belgium-Flemish (UTF-8)
   6. Bosnia (ISO8859-2)
   7. Brazil (ISO8859-1)
   8. Brazil (UTF-8)
   9. Bulgaria (ISO8859-5)
  10. Canada-English (ISO8859-1)
  11. Catalan, Spain (ISO8859-1)
  12. Catalan, Spain (ISO8859-15 - Euro)
  13. Croatia (ISO8859-2)
  14. Czech Republic (ISO8859-2)
  15. Czech Republic (UTF-8 + euro)
  16. Czech Republic (UTF-8)
  17. Denmark (ISO8859-1)
  18. Denmark (ISO8859-15 - Euro)

Press Return to show more choices.
Please make a choice (0 - 67), or press h or ? for help: 0

 

 

What type of terminal are you using?
 1) ANSI Standard CRT
 2) DEC VT52
 3) DEC VT100
 4) Heathkit 19
 5) Lear Siegler ADM31
 6) PC Console
 7) Sun Command Tool
 8) Sun Workstation
 9) Televideo 910
 10) Televideo 925
 11) Wyse Model 50
 12) X Terminal Emulator (xterms)

 13) CDE Terminal Emulator (dtterm)
 14) Other

 

(这里我选择的是 3) DEC VT100。 可能是因为从命令行打开的,最初选择了CDE,结果后面的配置信息的文字都显示不出来,只好重新来一次,选择了3)

 

System identification is completed.


        This system is configured with NFS version 4, which uses a domain
        name that is automatically derived from the system's name services.
        The derived domain name is sufficient for most configurations. In a
        few cases, mounts that cross different domains might cause files to
        be owned by "nobody" due to the lack of a common domain name.

        Do you need to override the system's default NFS version 4 domain
        name (yes/no) ? [no] :

        For more information about how the NFS version 4 default domain
        name is derived and its impact, refer to the man pages for nfs(4)
        and nfsmapid(1m), and the System Administration Guide: Network
        Services.


(这里系统自动重启,之后提示登录)

rebooting system due to change(s) in /etc/default/init

[NOTICE: Zone rebooting]

SunOS Release 5.10 Version Generic 32-bit
Copyright 1983-2005 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.
Hostname: zone01


zone01 console login: root
Password:

Nov 21 15:22:57 zone01 login: ROOT LOGIN /dev/console
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
# ifconfig -a
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
pcn0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.11.11.94 netmask ffffff00 broadcast 10.11.11.255
# hostname
zone01

 

这样就成功登陆进去了,可以作为一个Solaris 10 虚拟机独立使用了。

 

从外面ping 10.11.11.94,可以ping成功了。

 

 

注意:

创建zone目录的时候,要将group和world权限都设置为-,否则在install的时候会报错:

bash-3.00# zoneadm -z zone01 install
/zone/zone01 must not be group readable.
/zone/zone01 must not be group executable.
/zone/zone01 must not be world readable.
/zone/zone01 must not be world executable.
could not verify zonepath /zone/zone01 because of the above errors.
zoneadm: zone zone01 failed to verify

 

使用chmod将其设置为700

bash-3.00# chmod 700 -r /zone/zone01

 

 

参考资料:

http://bbs.chinaunix.net/archiver/tid-459817.html

http://bbs.163jsp.com/posts/list/236.html

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值