免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3648 | 回复: 1
打印 上一主题 下一主题

solaris的虚拟化--zone的应用实验. [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-28 12:30 |只看该作者 |倒序浏览
近期研究了一下solaris zone的技术,感觉比vmware ESX的一些东西要好一些.

zone只是一个solaris的组件来发布的吧,不象ESX那样整合作一个OS,可能还是感觉ESX的vmdk文件的太大,导致IO有问题,虽然vmfs的文件系统已经是针对大文件优化过了,但感觉还是慢.可能是以前测试的机器太慢造成的.现在没办法考证了,下面是我学习zone的一个实验资料,希望能帮到大家.

下面是以dell 1850,solaris10x86 u5为基础做的.
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c0t0d0s0      3.9G   1.6G   2.3G    40%    /
/devices                 0K     0K     0K     0%    /devices
ctfs                     0K     0K     0K     0%    /system/contract
proc                     0K     0K     0K     0%    /proc
mnttab                   0K     0K     0K     0%    /etc/mnttab
swap                   4.9G   892K   4.9G     1%    /etc/svc/volatile
objfs                    0K     0K     0K     0%    /system/object
/dev/dsk/c0t0d0s5      5.9G   2.6G   3.2G    46%    /usr
/usr/lib/libc/libc_hwcap1.so.1
                       5.9G   2.6G   3.2G    46%    /lib/libc.so.1
fd                       0K     0K     0K     0%    /dev/fd
/dev/dsk/c0t0d0s6      5.9G    65M   5.8G     2%    /var
swap                   4.9G   7.0M   4.9G     1%    /tmp
swap                   4.9G    32K   4.9G     1%    /var/run
/dev/dsk/c0t0d0s7       48G   5.7G    41G    13%    /home

#Mkdir /home/zone
#Chmod 700 /home/zone
这里的700是文档要求的,正常走即可.下面是配置 zone,其实是可以配置很多的,但我觉得配成完全根区域比较好,这主要还是考虑虽然稀疏根区域能在一定量的共享一些文件,但实际上我觉得这在无形中增加了一定的维护压力,系统运行稳定还是主要的,如果对宿主进行大量的更新文件,会不会影响到zone里面的应用还不好说,完全根区域是对宿主文件的全部CP,达到文件使用的隔离,虽然有一些空间的浪费,但现在动不动就是146G,300G,750G,1T的年代,存储空间根本不是问题,而更重要的是维护方面,易维护和稳定.

下面只列出一个简单的例子,实际还可以对CPU进行虚拟化管理,我只是为了快捷
# zonecfg  -z zone1
zone1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:zone1> create -b
zonecfg:zone1> set zonepath=/home/zone
zonecfg:zone1> set autoboot=true
zonecfg:zone1> add net
zonecfg:zone1:net> set address=192.168.195.215
zonecfg:zone1:net> set physical=e1000g0
zonecfg:zone1:net> end
zonecfg:zone1> verify
zonecfg:zone1> commit;
zonecfg:zone1> commit
zonecfg:zone1> exit

查看zone的状态
# zoneadm list
global
[root@sol10-2 /home]
# zoneadm list -vi
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared

下面是在zonecfg -z zone1 的前提下查看相关信息
zonecfg:zone1> info
zonename: zone1
zonepath: /home/zone
brand: native
autoboot: true
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
net:
        address: 192.168.195.215
        physical: e1000g0
zonecfg:zone1> quit


下面开始安装zone的系统文件,实际zone的文件安装位置是在/home/zone1下面,是以一个目录形式存在的.不象一些其它虚拟技术是单一文件的.觉得这个还是挺牛的.
# zoneadm -z zone1 install
Preparing to install zone .
Creating list of files to copy from the global zone.
Copying  files to the zone.






Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize  packages on the zone.
Initialized  packages on zone.                                 
Zone  is initialized.
The file  contains a log of the zone installation.

现在在查看状态,已经发现zone已经显示有zone1这个了,并且当前的状态是已经安装完成.
# zoneadm list -vi
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared
   - zone1            installed  /home/zone                     native   shared

下面开始启动zone1
# zoneadm -z zone1 boot
zoneadm: zone 'zone1': WARNING: e1000g0:1: no matching subnet found in netmasks(4) for 192.168.195.215; using default of 255.255.255.0.
[root@sol10-2 /home]
下面是查看网卡情况,虚拟化的技术核心都是对现在有硬件设备的重复利用,达到利用率一个比较高的程度.通过ifconfig -a可以查到网卡已经被zone1使用了,并且虚拟出来lo0:1,e1000g0:1
# ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
lo0:1: flags=2001000849 mtu 8232 index 1
        zone zone1
        inet 127.0.0.1 netmask ff000000
e1000g0: flags=1000843 mtu 1500 index 2
        inet 192.168.195.205 netmask ffffff00 broadcast 192.168.195.255
        ether 0:14:22:20:f2:f
e1000g0:1: flags=1000843 mtu 1500 index 2
        zone zone1
        inet 192.168.195.215 netmask ffffff00 broadcast 192.168.195.255
[root@sol10-2 /home]
#

现在在查看状态就是running了.
# zoneadm list -vi
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared
   1 zone1            running    /home/zone                     native   shared
[root@sol10-2 /home]
#

下面是对zone1进行登入操作.类似vmware的窗口操作.
#Zlogin -C zone1
System identification is completed.

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


[NOTICE: Zone rebooting]


SunOS Release 5.10 Version Generic_127128-11 64-bit
Copyright 1983-2008 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.
Hostname: zone1

zone1 console login: Jul 20 08:55:22 zone1 sendmail[21108]: My unqualified host name (zone1) unknown; sleeping for retry

zone1 console login: root
Password:
Jul 20 08:56:00 zone1 login: ROOT LOGIN /dev/console
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
进去之后,通过ps -ef可以查看当前的init初始进程已经没有了,而是出现了一个zsched进程,这个进程来负责这个zone的资源调度及使用
# bash
bash-3.00# ps -ef
     UID   PID  PPID   C    STIME TTY         TIME CMD
    root 20642 20642   0 08:54:45 ?           0:00 zsched
  daemon 20792 20642   0 08:55:08 ?           0:00 /usr/lib/nfs/nfs4cbd
  daemon 20877 20642   0 08:55:09 ?           0:00 /usr/lib/nfs/lockd
    root 20654 20642   0 08:55:03 ?           0:03 /lib/svc/bin/svc.startd
    root 20930 20927   0 08:55:10 ?           0:00 /usr/lib/saf/ttymon
  daemon 20710 20642   0 08:55:07 ?           0:00 /usr/lib/crypto/kcfd
    root 20885 20642   0 08:55:09 ?           0:00 /usr/lib/utmpd
    root 20652 20642   0 08:55:03 ?           0:00 /sbin/init
    root 20886 20642   0 08:55:09 ?           0:01 /usr/lib/inet/inetd start
    root 21138 20642   0 08:55:29 ?           0:00 /usr/lib/snmp/snmpdx -y -c /etc/snmp/conf
    root 20927 20654   0 08:55:10 ?           0:00 /usr/lib/saf/sac -t 300
    root 20776 20642   0 08:55:08 ?           0:00 /usr/sbin/cron
    root 20656 20642   0 08:55:03 ?           0:06 /lib/svc/bin/svc.configd
    root 20911 20909   0 08:55:10 ?           0:00 /usr/sadm/lib/smc/bin/smcboot
    root 20709 20642   0 08:55:07 ?           0:00 /usr/sbin/nscd
    root 21145 20642   0 08:55:31 ?           0:00 /usr/lib/dmi/dmispd
    root 20912 20909   0 08:55:10 ?           0:00 /usr/sadm/lib/smc/bin/smcboot
    root 20895 20654   0 08:55:09 console     0:00 -sh
    root 20909 20642   0 08:55:10 ?           0:00 /usr/sadm/lib/smc/bin/smcboot
  daemon 20785 20642   0 08:55:08 ?           0:00 /usr/sbin/rpcbind
    root 21146 20642   0 08:55:31 ?           0:00 /usr/lib/dmi/snmpXdmid -s zone1
  daemon 20795 20642   0 08:55:08 ?           0:00 /usr/lib/nfs/nfsmapid
    root 21181 20895   0 08:56:02 console     0:00 bash
  daemon 20807 20642   0 08:55:08 ?           0:00 /usr/lib/nfs/statd
    root 21182 21181   0 08:56:03 console     0:00 ps -ef
    root 21083 20642   0 08:55:15 ?           0:00 /usr/lib/autofs/automountd
    root 21084 21083   0 08:55:15 ?           0:00 /usr/lib/autofs/automountd
    root 21101 20642   0 08:55:18 ?           0:00 /usr/lib/ssh/sshd
    root 21099 20642   0 08:55:17 ?           0:00 /usr/sbin/syslogd
    root 21107 20654   0 08:55:22 ?           0:00 /sbin/sh /lib/svc/method/smtp-sendmail start
    root 21108 21107   0 08:55:22 ?           0:00 /usr/sbin/newaliases
    root 21117 20642   0 08:55:23 ?           0:00 /usr/sfw/sbin/snmpd
下面显示zone磁盘空间的地方需要注意一下,这里面的/的使用情况实际上是宿方的/home/分区的使用情况,等于他们再共享使用/home/分区.
bash-3.00# df -h
Filesystem             size   used  avail capacity  Mounted on
/                       48G   5.7G    41G    13%    /
/dev                    48G   5.7G    41G    13%    /dev
proc                     0K     0K     0K     0%    /proc
ctfs                     0K     0K     0K     0%    /system/contract
mnttab                   0K     0K     0K     0%    /etc/mnttab
objfs                    0K     0K     0K     0%    /system/object
swap                   4.9G   288K   4.9G     1%    /etc/svc/volatile
/usr/lib/libc/libc_hwcap1.so.1
                        48G   5.7G    41G    13%    /lib/libc.so.1
fd                       0K     0K     0K     0%    /dev/fd
swap                   4.9G     4K   4.9G     1%    /tmp
swap                   4.9G    12K   4.9G     1%    /var/run


准备要clone zone
# zonecfg -z zone1 export -f ./ffff
编辑ffff,修改必要的信息.如果zonepath,IP地址
create -b
set zonepath=/home/zone3
set autoboot=true
set ip-type=shared
add net
set address=192.168.195.216
set physical=e1000g0
End

# zonecfg -z zone3 -f ./ffff  导入配置文件,
下面开始进行clone
# zoneadm -z zone3 clone zone1
Cloning zonepath /home/zone...



# zoneadm list -vi
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared
   - zone1            installed  /home/zone                     native   shared
   - zone3            installed  /home/zone3                    native   shared
[root@sol10-2 /home]



下面是开始启动zone
# zoneadm -z zone3 boot
zoneadm: zone 'zone3': WARNING: e1000g0:1: no matching subnet found in netmasks(4) for 192.168.195.216; using default of 255.255.255.0.
[root@sol10-2 /home]
# zlogin -C zone3
[Connected to zone 'zone3' console]


You did not enter a selection.
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
Type the number of your choice and press Return: 3
Creating new rsa public/private host key pair
Creating new dsa public/private host key pair
Configuring network interface addresses: e1000g0.

- Host Name for e1000g0:1 ------------------------------------------------------

  Enter the host name which identifies this system on the network.  The name
  must be unique within your domain; creating a duplicate host name will cause
  problems on the network after you install Solaris.

  A host name must have at least one character; it can contain letters,
  digits, and minus signs (-).


    Host name for e1000g0:1 zone32





在宿主上面看到的网卡情况
[root@sol10-2 /home]
# ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
lo0:1: flags=2001000849 mtu 8232 index 1
        zone zone3
        inet 127.0.0.1 netmask ff000000
e1000g0: flags=1000843 mtu 1500 index 2
        inet 192.168.195.205 netmask ffffff00 broadcast 192.168.195.255
        ether 0:14:22:20:f2:f
e1000g0:1: flags=1000843 mtu 1500 index 2
        zone zone3
        inet 192.168.195.216 netmask ffffff00 broadcast 192.168.195.255
[root@sol10-2 /home]

# zoneadm list -iv
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared
   4 zone3            running    /home/zone3                    native   shared
   - zone1            installed  /home/zone                     native   shared
[root@sol10-2 /home]
# zoneadm -z zone1 boot
zoneadm: zone 'zone1': WARNING: e1000g0:2: no matching subnet found in netmasks(4) for 192.168.195.215; using default of 255.255.255.0.
# zoneadm list -iv
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared
   4 zone3            running    /home/zone3                    native   shared
   5 zone1            running    /home/zone                     native   shared
[root@sol10-2 /home]
# \




下面是ssh登入也都正常,至此zone已经实验成功。
# ssh root@192.168.195.215
Host key not found from database.
Key fingerprint:
xihel-kabeg-modid-vukaz-gumuk-rekom-boneg-lotes-gypov-myzyn-fyxyx
You can get a public key's fingerprint by running
% ssh-keygen -F publickey.pub
on the keyfile.
Are you sure you want to continue connecting (yes/no)? yes
Host key saved to /root/.ssh2/hostkeys/key_22_192.168.195.215.pub
host key for 192.168.195.215, accepted by root Sun Jul 20 2008 10:19:37 +0800
Keyboard-interactive:
Password:
Authentication successful.
Last login: Sun Jul 20 10:20:06 2008
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
# w
10:21am  up 4 min(s),  2 users,  load average: 0.04, 0.13, 0.10
User     tty           login@  idle   JCPU   PCPU  what
root     pts/5        10:20am                      -sh
root     pts/6        10:21am                      w
#


两个zone都启来以后,查看网卡
[root@sol10-2 /home]
# ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
lo0:1: flags=2001000849 mtu 8232 index 1
        zone zone3
        inet 127.0.0.1 netmask ff000000
lo0:2: flags=2001000849 mtu 8232 index 1
        zone zone1
        inet 127.0.0.1 netmask ff000000
e1000g0: flags=1000843 mtu 1500 index 2
        inet 192.168.195.205 netmask ffffff00 broadcast 192.168.195.255
        ether 0:14:22:20:f2:f
e1000g0:1: flags=1000843 mtu 1500 index 2
        zone zone3
        inet 192.168.195.216 netmask ffffff00 broadcast 192.168.195.255
e1000g0:2: flags=1000843 mtu 1500 index 2
        zone zone1
        inet 192.168.195.215 netmask ffffff00 broadcast 192.168.195.255
[root@sol10-2 /home]


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/8601/showart_1094379.html

论坛徽章:
0
2 [报告]
发表于 2008-10-07 18:43 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP