电脑技术学习

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

dn001
最近刚刚发布的 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 PATH
0 global running /

首先创建一个目录,用来存放新的soft zone的文件。
root@b1000:/# mkdir -p /zone/zone1
root@b1000:/# ls -ld /zone/zone1
drwxr-xr-x 2 root other 512 Dec 4 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 PATH
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 Dec 4 14:42 /zone/zone1
root@b1000:/# chmod 0700 /zone/zone1
root@b1000:/# ls -ld /zone/zone1
drwx------ 2 root other 512 Dec 4 14:42 /zone/zone1
root@b1000:/# zoneadm -z zone1 install
Preparing to install zone <zone1>.
Copying <2365> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <994> packages on the zone.
Initializing package <57> of <994>: percent complete: 5%
......
.....
...
这里大约需要二十分钟左右
Initialized <994> packages on zone.
Zone <zone1> is initialized.
Installation of these packages generated errors: <SUNWj5rt SUNWnsb SUNWmpatchmgr>
Installation of these packages generated warnings: <SUNWmoznav SUNWmozgm SUNWwbmc
SUNWmga SUNWdclnt SUNWlvma SUNWlvmg SUNWrmui SUNWpmgr>
The file </zone/zone1/root/var/sadm/system/logs/install_log> contains a log of the zone installation.
root@b1000:/# zoneadm list -vc
ID NAME STATUS PATH
0 global running /
- zone1 installed /zone/zone1

启动这个zone:
root@b1000:/# zoneadm -z zone1 boot

进入zone1的Console:
root@b1000:/# zlogin -C zone1
[Connected to zone 'zone1' console]
[NOTICE: Zone booting up]

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


[NOTICE: Zone rebooting]


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.
Dec 4 15:18:42 MyWeb sendmail[8940]: My unqualified host name (MyWeb) unknown; sleeping for retry
Dec 4 15:19:42 MyWeb sendmail[8940]: 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
Dec 4 15:19:42 MyWeb sendmail[8941]: My unqualified host name (MyWeb) unknown; sleeping for retry
Dec 4 15:19:42 MyWeb sendmail[8942]: 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:
Dec 4 15:21:53 MyWeb login: ROOT LOGIN /dev/console
Sun Microsystems Inc. SunOS 5.10 s10_63 May 2004
# df -k
Filesystem kbytes used avail capacity Mounted 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<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
eri0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.0.101 netmask ffffff00 broadcast 192.168.0.255
# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 9054 8810 0 15:20:20 ? 0:00 /usr/lib/saf/sac -t 300
root 8906 8802 0 15:18:39 ? 0:00 /usr/sbin/nscd
root 8802 8802 0 15:18:27 ? 0:00 zsched
root 9055 8810 0 15:20:20 console 0:00 -sh
root 8810 8802 0 15:18:38 ? 0:00 init
root 8899 8802 0 15:18:39 ? 0:00 /usr/lib/autofs/automountd
daemon 8833 8802 0 15:18:39 ? 0:00 /usr/lib/crypto/kcfd
root 8895 8802 0 15:18:39 ? 0:00 /usr/sbin/syslogd
daemon 8858 8802 0 15:18:39 ? 0:00 /usr/sbin/rpcbind
root 8904 8802 0 15:18:39 ? 0:00 /usr/sbin/cron
root 8911 8802 0 15:18:40 ? 0:00 /usr/sbin/inetd -s
root 8967 8963 0 15:19:43 ? 0:00 /usr/sadm/lib/smc/bin/smcboot
root 8964 8963 0 15:19:43 ? 0:00 /usr/sadm/lib/smc/bin/smcboot
root 8949 8802 0 15:19:43 ? 0:00 /usr/lib/utmpd
root 8965 8802 0 15:19:43 ? 0:00 /usr/lib/im/htt -port 9010 -s
yslog -message_locale C
root 8963 8802 0 15:19:43 ? 0:00 /usr/sadm/lib/smc/bin/smcboot
root 8966 8965 0 15:19:43 ? 0:00 htt_server -port 9010 -syslog
-message_locale C
root 9030 8802 0 15:19:45 ? 0:00 /usr/lib/dmi/snmpXdmid -s MyW
eb
root 9058 8802 0 15:20:20 ? 0:00 /usr/lib/ssh/sshd
root 9057 9054 0 15:20:20 ? 0:00 /usr/lib/saf/ttymon
daemon 8974 8802 0 15:19:44 ? 0:02 /usr/lib/ST/stfontserverd
root 9028 8802 0 15:19:45 ? 0:00 /usr/lib/dmi/dmispd
root 9059 8802 0 15:20:43 ? 0:00 /usr/lib/sendmail -bd -q15m
root 9022 8802 0 15:19:45 ? 0:00 /usr/lib/snmp/snmpdx -y -c /e
tc/snmp/conf
root 8999 8802 0 15:19:44 ? 0:00 /usr/dt/bin/dtlogin -daemon
root 9042 8802 0 15:19:46 ? 0:00 /usr/sfw/sbin/snmpd
smmsp 9060 8802 0 15:20:43 ? 0:00 /usr/lib/sendmail -Ac -q15m
root 9069 9055 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 Microsystems sun4u
Memory size: 1024 Megabytes
System Peripherals (Software Nodes):

prtconf: devinfo facility not available

# exit

按 ~ 然后按 . 退出zone1的Console,回到global zone,也就是真正的B1000
MyWeb console login: ~.
[Connection to zone 'zone1' console closed]
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/

标签: