大坏蛋 发表于 2008-09-04 14:20

Solaris10的革命性功能之一 Solaris 10 N1 Grid Container


Solaris10的革命性功能之一 Solaris 10 N1 Grid Container
最近刚刚发布的 Solaris 10 操作系统,号称Sun公司的真正意义上的里程碑式操作系统,带
来了诸多突破性技术,如 Solaris Containers、动态跟踪 (DTrace)、预测性自我修复和ZFS动态
文件系统等。
    比较感兴趣的是Solaris Container,也就是N1 Grid Container--网格?!现在好像比较
流行这个,Oracle 10g 也是Grid的意思。。。。
    这个Solaris Container号称可以让每个 Solaris 10 创建多达 8192 个的安全、无故障软件
分区,相对于SunFire 3800/4800/6800/4900/6900/12K/15K/25K的硬件分区好像更夸张一点,感觉
有点像PC上的VMware。IBM最近的P5系列也是,好像现在各大厂商都热衷于这个,叫什么server
virtualization
开始上手:
root@b1000:/# uname -a
SunOS b1000 5.10 s10_63 sun4u sparc SUNW,Sun-Blade-1000
刚装完的系统,只有一个global zone
root@b1000:/# zoneadm list -vc
ID NAME             STATUS         
http://www.lupaworld.com/bbs/images/smilies/default/titter.gif
ATH                           
   0 global         running      /
首先创建一个目录,用来存放新的soft zone的文件。
root@b1000:/# mkdir -p /zone/zone1
root@b1000:/# ls -ld /zone/zone1
drwxr-xr-x   2 root   other      512 Dec4 14:42 /zone/zone1
创建一个zone1的软分区:
root@b1000:/# zonecfg -z zone1
zone1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:zone1> create
zonecfg:zone1> set zonepath=/zone/zone1
zonecfg:zone1> set autoboot=true
zonecfg:zone1> add net
zonecfg:zone1:net> set address=192.168.0.101
zonecfg:zone1:net> set physical=eri0
zonecfg:zone1:net> end
zonecfg:zone1> info
zonepath: /zone/zone1
autoboot: true
pool:
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
net:
address: 192.168.0.101
physical: eri0
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> ^D
root@b1000:/#
创建完成,查看zone1的信息:
root@b1000:/# zonecfg -z zone1 info
zonepath: /zone/zone1
autoboot: true
pool:
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
net:
address: 192.168.0.101
physical: eri0
root@b1000:/# zoneadm list -vc
ID NAME             STATUS         
http://www.lupaworld.com/bbs/images/smilies/default/titter.gif
ATH                           
   0 global         running      /                              
   - zone1            configured   /zone/zone1
安装操作系统文件刚刚配置完成的zone1:
root@b1000:/# zoneadm -z zone1 install
/zone/zone1 must not be group readable.
/zone/zone1 must not be group executable.
/zone/zone1 must not be world readable.
/zone/zone1 must not be world executable.
could not verify zonepath /zone/zone1 because of the above errors.
zoneadm: zone zone1 failed to verify
root@b1000:/# ls -ld /zone/zone1
drwxr-xr-x   2 root   other      512 Dec4 14:42 /zone/zone1
root@b1000:/# chmod 0700 /zone/zone1
root@b1000:/# ls -ld /zone/zone1
drwx------   2 root   other      512 Dec4 14:42 /zone/zone1
root@b1000:/# zoneadm -z zone1 install
Preparing to install zone .
Copyingfiles to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initializepackages on the zone.
Initializing packageof : percent complete: 5%
......
.....
...
这里大约需要二十分钟左右
Initializedpackages on zone.                                 
Zoneis initialized.
Installation of these packages generated errors:
Installation of these packages generated warnings:
The filecontains a log of the zone installation.
root@b1000:/# zoneadm list -vc
ID NAME             STATUS         
http://www.lupaworld.com/bbs/images/smilies/default/titter.gif
ATH                           
   0 global         running      /                              
   - zone1            installed      /zone/zone1
启动这个zone:
root@b1000:/# zoneadm -z zone1 boot
进入zone1的Console:
root@b1000:/# zlogin -C zone1


SunOS Release 5.10 Version s10_63 64-bit
Copyright 1983-2004 Sun Microsystems, Inc.All rights reserved.
Use is subject to license terms.
Hostname: zone1
The system is coming up.Please wait.
Select a Language
0. English
1. Simplified Chinese
2. Traditional Chinese
Please make a choice (0 - 2), or press h or ? for help:
接下来的和平时安装系统一样,设置主机名,时区,域名解析方式等等,
System identification is completed.
rebooting system due to change(s) in /etc/default/init

SunOS Release 5.10 Version s10_63 64-bit
Copyright 1983-2004 Sun Microsystems, Inc.All rights reserved.
Use is subject to license terms.
Hostname: MyWeb
The system is coming up.Please wait.
starting rpc services: rpcbind done.
syslog service starting.
Dec4 15:18:42 MyWeb sendmail: My unqualified host name (MyWeb) unknown; sleeping for retry
Dec4 15:19:42 MyWeb sendmail: unable to qualify my own domain name (MyWeb) -- using short name
WARNING: local host name (MyWeb) is not qualified; see cf/README: WHO AM I?
/etc/mail/aliases: 12 aliases, longest 10 bytes, 138 bytes total
Dec4 15:19:42 MyWeb sendmail: My unqualified host name (MyWeb) unknown; sleeping for retry
Dec4 15:19:42 MyWeb sendmail: My unqualified host name (MyWeb) unknown; sleeping for retry
STSF Font Server Daemon.
Standard Type Services Framework 0.11.1
Copyright (c) 2001-2004 Sun Microsystems, Inc. All Rights Reserved.
STSF is Open Source Software. http://stsf.freedesktop.org
Creating new rsa public/private host key pair
Creating new dsa public/private host key pair
The system is ready.
哈哈,完成啦。。。。。。。。
虚拟的主机MyWeb启动成功,登陆。。。。。
MyWeb console login: root
Password:
Dec4 15:21:53 MyWeb login: ROOT LOGIN /dev/console
Sun Microsystems Inc.   SunOS 5.10      s10_63May 2004
# df -k
Filesystem            kbytes    used   avail capacityMounted on
/                  10080200 2702923 7276475    28%    /
/dev               10080200 2702923 7276475    28%    /dev
/lib               10080200 2702923 7276475    28%    /lib
/platform            10080200 2702923 7276475    28%    /platform
/sbin                10080200 2702923 7276475    28%    /sbin
/usr               10080200 2702923 7276475    28%    /usr
proc                     0       0       0   0%    /proc
mnttab                     0       0       0   0%    /etc/mnttab
fd                         0       0       0   0%    /dev/fd
swap               2737048      48 2737000   1%    /var/run
swap               2737000       0 2737000   0%    /tmp
# ifconfig -a
lo0:1: flags=1000849 mtu 8232 index 1
      inet 127.0.0.1 netmask ff000000
eri0:1: flags=1000843 mtu 1500 index 2
      inet 192.168.0.101 netmask ffffff00 broadcast 192.168.0.255
# ps -ef
   UID   PIDPPID   C    STIME TTY         TIME CMD
    root90548810   0 15:20:20 ?         0:00 /usr/lib/saf/sac -t 300
    root89068802   0 15:18:39 ?         0:00 /usr/sbin/nscd
    root88028802   0 15:18:27 ?         0:00 zsched
    root90558810   0 15:20:20 console   0:00 -sh
    root88108802   0 15:18:38 ?         0:00 init
    root88998802   0 15:18:39 ?         0:00 /usr/lib/autofs/automountd
daemon88338802   0 15:18:39 ?         0:00 /usr/lib/crypto/kcfd
    root88958802   0 15:18:39 ?         0:00 /usr/sbin/syslogd
daemon88588802   0 15:18:39 ?         0:00 /usr/sbin/rpcbind
    root89048802   0 15:18:39 ?         0:00 /usr/sbin/cron
    root89118802   0 15:18:40 ?         0:00 /usr/sbin/inetd -s
    root89678963   0 15:19:43 ?         0:00 /usr/sadm/lib/smc/bin/smcboot
    root89648963   0 15:19:43 ?         0:00 /usr/sadm/lib/smc/bin/smcboot
    root89498802   0 15:19:43 ?         0:00 /usr/lib/utmpd
    root89658802   0 15:19:43 ?         0:00 /usr/lib/im/htt -port 9010 -s
yslog -message_locale C
    root89638802   0 15:19:43 ?         0:00 /usr/sadm/lib/smc/bin/smcboot
    root89668965   0 15:19:43 ?         0:00 htt_server -port 9010 -syslog
-message_locale C
    root90308802   0 15:19:45 ?         0:00 /usr/lib/dmi/snmpXdmid -s MyW
eb
    root90588802   0 15:20:20 ?         0:00 /usr/lib/ssh/sshd
    root90579054   0 15:20:20 ?         0:00 /usr/lib/saf/ttymon
daemon89748802   0 15:19:44 ?         0:02 /usr/lib/ST/stfontserverd
    root90288802   0 15:19:45 ?         0:00 /usr/lib/dmi/dmispd
    root90598802   0 15:20:43 ?         0:00 /usr/lib/sendmail -bd -q15m
    root90228802   0 15:19:45 ?         0:00 /usr/lib/snmp/snmpdx -y -c /e
tc/snmp/conf
    root89998802   0 15:19:44 ?         0:00 /usr/dt/bin/dtlogin -daemon
    root90428802   0 15:19:46 ?         0:00 /usr/sfw/sbin/snmpd
   smmsp90608802   0 15:20:43 ?         0:00 /usr/lib/sendmail -Ac -q15m
    root90699055   0 15:22:47 console   0:00 ps -ef
不用的Sendmail停掉
# mv /etc/rc2.d/S88sendmail /etc/rc2.d/s88sendmail
# /etc/init.d/sendmail stop
# prtdiag -v
prtdiag can only be run in the global zone
哦,prtdiag不能在zone里用
prtconf有信息出来:
# prtconf
System Configuration:Sun Microsystemssun4u
Memory size: 1024 Megabytes
System Peripherals (Software Nodes):
prtconf: devinfo facility not available
# exit
按 ~ 然后按 . 退出zone1的Console,回到global zone,也就是真正的B1000
MyWeb console login: ~.

root@b1000:/#
root@b1000:/#
root@b1000:/# zoneadm list -vc
ID NAME             STATUS         PATH                           
   0 global         running      /                              
   1 zone1            running      /zone/zone1
root@b1000:/# telnet 192.168.0.101
Trying 192.168.0.101...
Connected to 192.168.0.101.
Escape character is '^]'.
login: root
Password:
Not on system console
Connection to 192.168.0.101 closed by foreign host.
忘改/etc/default/login了。。。。。。。。。。。
总结:
1. 提高了系统的利用率,可以一个当N个使唤
2. 应用系统可以跑在互不干扰的动态系统域里
3. 完全可以把一个zone的root密码告诉别人,用来练手不错,整瘫了大不了
   zoneadm -z zone1 uninstall再zoneadm -z zone1 install就ok了
4. 应该还有许多好玩的功能待发掘。。。。
参考资料:
http://www.sun.com/bigadmin/content/zones/

本文来自
LUPA论坛
,如果查看原文请点:
http://www.lupaworld.com/bbs/redirect.php?fid=325&tid=1761&goto=nextoldset


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/3523/showart_1164302.html
页: [1]
查看完整版本: Solaris10的革命性功能之一 Solaris 10 N1 Grid Container