我正在使用Generic_142901-04内核testingSolaris 10 10/09(s10x_u8wos_08a)上的区域。
主机服务器有两个物理网卡(bnx0和bnx1),由于我打算运行几个(三个或更多)区域,因此将NIC专用于区域是不可能的。 目前,我没有任何“专用”IP地址分配给这些区域,所以我从DHCP获得租约。
我的问题,我们会回到一旦我告诉你我目前的设置,主要围绕这个networkingconfiguration。
以下是我设置区域的步骤(附加一些信息):
erikn@global:~ $ zpool status zpool1 pool: zpool1 state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM zpool1 ONLINE 0 0 0 c1t1d0 ONLINE 0 0 0 errors: No known data errors erikn@global:~ $ zfs list zpool1 NAME USED AVAIL REFER MOUNTPOINT zpool1 84.1G 183G 6.14G /zpool1 erikn@global:~ $ pfexec zfs create zpool1/zones erikn@global:~ $ pfexec zfs set mountpoint=/zones zpool1/zones erikn@global:~ $ pfexec zonecfg -z test \ > 'create -b ; > set zonepath=/zones/test ; > verify ; > commit' erikn@global:~ $ zoneadm list -vic ID NAME STATUS PATH BRAND IP 0 global running / native shared - test configured /zones/test native shared
我继续安装区域
erikn@global:~ $ pfexec zoneadm -z test install A ZFS file system has been created for this zone. Preparing to install zone <test>. Creating list of files to copy from the global zone. Copying <196614> files to the zone. Initializing zone product registry. Determining zone package initialization order. Preparing to initialize <1595> packages on the zone. Initialized <1595> packages on zone. Zone <test> is initialized. Installation of these packages generated errors: <SUNWvbox SUNWpostgr-83-server-data-root CSWcacertificates CSKmysql32 SUNWpostgr-82-libs SUNWpostgr-82-server SUNWpostgr-82-client SUNWpostgr-82-devel CSKphp5 SUNWpostgr-82-contrib CSKapache2 SUNWpostgr-82-server-data-root> Installation of <1> packages was skipped. The file </zones/test/root/var/sadm/system/logs/install_log> contains a log of the zone installation.
所以有些软件包会产生错误,但是这并不关心我,因为我不需要在这个区域内使用它们。
无论如何,安装退出零。
erikn@global:~ $ echo $? 0
我启动了该区域
erikn@global:~ $ pfexec zoneadm -z test boot
并连接到“控制台”。
erikn@global:~ $ pfexec zlogin -C test
我跟着安装; select语言(英文),设置语言环境(USA(en_US.ISO8859-1)),terminaltypes(DEC VT100),给它一个主机名(testing),设置时区(欧洲/奥斯陆),设置一个root密码“password123” – 不,只是在开玩笑)。
将根shell更改为bash:
# usermod -s /usr/bin/bash root UX: usermod: root is currently logged in, some changes may not take effect until next login.
退出并重新login。
由于有很多启用的服务(包括远程login和手指),我认为这将是更容易禁用一切,然后重新启用服务,直到我有一个工作系统。
-bash-3.00# svcs | grep " svc:" | sed "s/ \{1,\}/ /g" | cut -d' ' -f3 | \ > xargs svcadm disable
正如所料,这样做导致进入系统维护模式的区域。
我重新启用了所有的milstone服务:
-bash-3.00# svcs -a | grep " svc:/milestone/" | sed "s/ \{1,\}/ /g" | \ > cut -d' ' -f3 | xargs svcadm enable
启用了sshd和syslogd。
-bash-3.00# svcadm enable svc:/network/ssh:default -bash-3.00# svcadm enable svc:/system/system-log:default
打开依赖服务,使他们:
-bash-3.00# while [ $( svcs -xv | wc -l ) -gt 0 ] ; do > svcs -xv | grep "^svc" | cut -d' ' -f1 | xargs svcadm enable > done Hostname: test Reading ZFS config: done.
启用控制台login并检查状态。
-bash-3.00# svcadm enable svc:/system/console-login:default -bash-3.00# svcs -xv svc:/system/console-login:default (Console login) State: offline since August 27, 2012 11:38:04 AM CEST Reason: Unknown. See: http://sun.com/msg/SMF-8000-AR See: man -M /usr/share/man -s 1M ttymon Impact: This service is not running.
重新启动该区域。
-bash-3.00# reboot
是由控制台login提示迎接。 login。检查的服务状态:
-bash-3.00# svcs -xv
没有输出是好的输出。
停止了该区域,并从全球区域拍摄了一个快照,以便采取措施。
-bash-3.00# halt Aug 27 12:10:08 test halt: halted by root Aug 27 12:10:09 test syslogd: going down on signal 15 [NOTICE: Zone halted] ~. [Connection to zone 'test' console closed] erikn@global:~ $ pfexec zfs snapshot zpool1/zones/test@neat
之后,我再次启动了这个区域,找出了安装的软件包的依赖顺序(使用这个“pkgdep”脚本),并删除了一些我不需要的东西。
接下来是configurationnetworking的时候了,这个问题就是这个问题。
从全局区域,我创build了一个逻辑接口,并将其分配给“testing”区域。
erikn@global:~ $ pfexec ifconfig bnx1:1 plumb zone test
我们可以validation这是分配给该区域的:
-bash-3.00# ifconfig bnx1:1 bnx1:1: flags=1100842<BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4> mtu 1500 index 5 inet 0.0.0.0 netmask 0
现在,由于区域被configuration为IPtypes“共享”,所以它将不能在接口上发送DHCP请求。 因此,我们从全球范围内做到这一点:
erikn@global:~ $ pfexec ifconfig bnx1:1 dhcp start ifconfig: bnx1:1: wait timed out, operation still pending...
那不太好,现在呢?
erikn@global:~ $ echo $? 4
回到区域。
-bash-3.00# ifconfig bnx1:1 bnx1:1: flags=1104843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,ROUTER,IPv4> mtu 1500 index 5 inet 10.0.6.92 netmask fffffc00 broadcast 10.0.7.255
那么,我们有一个IP地址…(这里,我用10.0.4.0/22取代了networking,但是networking掩码是一样的)。
我们修改我们的/etc/nsswitch.conf和/etc/resolv.conf来使用我们的名字服务器。
由于我们在我们的networking上使用HTTP代理,我们必须记得导出(我通常把它放在〜/ .bash_profile中)
-bash-3.00# export http_proxy=http://proxy.example.com:8080 -bash-3.00# /usr/sfw/bin/wget http://www.google.com --2012-08-27 13:03:30-- http://www.google.com/ Resolving proxy.example.com... 10.0.7.17 Connecting to proxy.example.com|10.0.7.17|:8080... connected. Proxy request sent, awaiting response... 302 Found Location: http://www.google.no/ [following] --2012-08-27 13:03:40-- http://www.google.no/ Connecting to proxy.example.com|10.0.7.17|:8080... connected. Proxy request sent, awaiting response... 200 OK Length: unspecified [text/html] Saving to: `index.html' [ <=> ] 11,343 --.-K/s in 0s 2012-08-27 13:03:40 (65.3 MB/s) - `index.html' saved [11343]
虽然事情似乎有效,但并不完美。 让我们回到全球区域。
首先我们有一个真正的bnx1接口,它也使用DHCP。
erikn@global:~ $ ifconfig bnx1 dhcp status Interface State Sent Recv Declined Flags bnx1 BOUND 2357 1558 778 (Began, Expires, Renew) = (08/27/2012 12:09, 08/31/2012 12:09, 08/29/2012 12:09)
然后我们有我们的逻辑接口:
erikn@global:~ $ ifconfig bnx1:1 dhcp status Interface State Sent Recv Declined Flags bnx1:1 PRE_BOUND 20 14 6
让我们创build另一个逻辑接口,但是我们不会将这个接口放在任何区域,所以它将属于全局区域:
erikn@global:~ $ pfexec ifconfig bnx1:2 plumb erikn@global:~ $ pfexec ifconfig bnx1:2 dhcp start erikn@global:~ $ echo $? 0 erikn@global:~ $ ifconfig bnx1:2 bnx1:2: flags=1104843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,ROUTER,IPv4> mtu 1500 index 5 inet 10.0.6.123 netmask fffffc00 broadcast 10.0.7.255 erikn@global:~ $ ifconfig bnx1:2 dhcp status Interface State Sent Recv Declined Flags bnx1:2 BOUND 5 4 1 (Began, Expires, Renew) = (08/27/2012 13:11, 08/31/2012 13:11, 08/29/2012 13:11)
所以这工作相当完美。 唉,这对我们帮不了多less。
我试图把这个接口交给区域“testing”:
erikn@global:~ $ pfexec ifconfig bnx1:2 zone test erikn@global:~ $ echo $? 0
这不是太高兴:
erikn@global:~ $ ifconfig bnx1:2 dhcp status Interface State Sent Recv Declined Flags bnx1:2 DECLINING 6 4 2
然后在界面上重新启动和释放DHCP客户端,就会得到和上次一样的结果:
erikn@global:~ $ pfexec ifconfig bnx1:2 dhcp release erikn@global:~ $ pfexec ifconfig bnx1:2 dhcp start ifconfig: bnx1:2: wait timed out, operation still pending...
作为最后一次绝望的尝试,我尝试过:
erikn@global:~ $ pfexec ifconfig bnx1:2 plumb \ > netmask 0xfffffc00 \ > broadcast 10.0.7.255 \ > zone test \ > up
没有这样的运气。
erikn@global:~ $ pfexec ifconfig bnx1:2 dhcp start ifconfig: bnx1:2: wait timed out, operation still pending...
我的问题基本上是:
是否有可能为Solaris 10/09区域分配IP分配的IP,而不给它自己的物理NIC?
我是否以错误的方式去做这件事? 我应该为区域使用专用IP,并让主机执行NAT吗? 那可能吗?
对我而言,最终目标是在每个区域中运行不同的联网服务。
将有一些networking通信跨区域,和
他们也将运行networking可访问的服务,将被我们的networking上的其他主机使用。
区域虚拟接口有一些function有限…有些状态不能设置,数据包filter也不能在区域中工作。 如果我没有记错,区域接口不能发送以太网广播,所以没有DHCP。
顺便说一句,为什么你做这个臃肿的区域设置界面? 那这个呢?
pfexec zonecfg -z test > 'create -b ; > set zonepath=/zones/test ; > add net ; > set physica=bnx1 ; > set address=10.0.6.92 ; > end ; > verify ; > commit'
它将从全局区域接口inheritancenetworking掩码。 当然,你可以设置更多的接口,或者把区域放在'内部'接口上(没有公共IP),并且让ipf提供NAT 。