文章
服务器与存储管理
作者:Alexandre Borges
2014 年 4 月发布
第 1 部分 — 使用 COMSTAR 和 ZFS 配置虚拟化存储环境
第 2 部分 — 使用交换监视和使用 ZFS 卷扩大交换空间
第 3 部分 — 使用 ZFS 影子迁移
第 4 部分 — 将 ZFS 数据集委托给非全局区域
第 5 部分 — 使用 ZFS 加密
第 6 部分 — 使用 ZFS 快照
使用 Oracle Solaris 11 时,有时全局管理员需要将数据集(如 ZFS 文件系统)委托给非全局区域,因为非全局区域管理员需要一个专用文件系统来安装新应用。
|
将数据集委托 给非全局区域与向非全局区域添加 数据集或文件系统之间的区别在于,委托数据集时,非全局区域管理员可以控制数据集的属性。将文件系统添加到非全局区域时,只是与非全局区域共享文件系统空间,全局管理员仍控制着所添加文件系统的属性。
还请注意,大多数情况下,术语数据集 与文件系统 可互换使用。“委托数据集”与“添加文件系统”之间的唯一区别在于谁控制文件系统。大多数情况下,您将数据集委托给非全局区域或者向非全局区域添加文件系统。
将数据集委托给非全局区域是一项很轻松的任务,是本文要讨论的话题。
此任务大致分为两部分:
首先,建议为新的非全局区域创建一个专用池和一个文件系统:
root@solaris11-1:~# zpool create myzones c8t4d0 root@solaris11-1:~# zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT iscsi_pool 3.97G 2.62M 3.97G 0% 1.00x ONLINE - myzones 15.9G 126K 15.9G 0% 1.00x ONLINE - repo_pool 15.9G 7.64G 8.24G 48% 1.00x ONLINE - rpool 79.5G 37.8G 41.7G 47% 1.00x ONLINE - root@solaris11-1:~# zfs create myzones/delegated_zone root@solaris11-1:~# zfs list myzones/delegated_zone NAME USED AVAIL REFER MOUNTPOINT myzones/delegated_zone 31K 15.6G 31K /myzones/delegated_zone
然后,执行以下操作,创建一个名为 delegated_zone 的非全局区域:
root@solaris11-1:~# zonecfg -z delegated_zone Use 'create' to begin configuring a new zone. zonecfg:delegated_zone> create -b zonecfg:delegated_zone> set zonepath=/myzones/delegated_zone zonecfg:delegated_zone> set autoboot=true zonecfg:delegated_zone> set ip-type=shared zonecfg:delegated_zone> set brand=solaris zonecfg:delegated_zone> add net zonecfg:delegated_zone:net> set physical=net0 zonecfg:delegated_zone:net> set address=192.168.1.198 zonecfg:delegated_zone:net> set defrouter=192.168.1.1 zonecfg:delegated_zone:net> end zonecfg:delegated_zone> verify zonecfg:delegated_zone> commit zonecfg:delegated_zone> exit root@solaris11-1:~#
列出区域概要之后,可以看到 delegated_zone 还没有 ID,这是因为它尚未启动:
root@solaris11-1:~# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / solaris shared - delegated_zone configured /myzones/delegated_zone solaris shared
使用 zonecfg 命令可以收集有关新区域的更多信息:
root@solaris11-1:~# zonecfg -z delegated_zone info
zonename: delegated_zone
zonepath: /myzones/delegated_zone
brand: solaris
autoboot: true
bootargs:
file-mac-profile:
pool:
limitpriv:
scheduling-class:
ip-type: shared
hostid:
fs-allowed:
net:
address: 192.168.1.198
allowed-address not specified
configure-allowed-address: true
physical: net0
defrouter: 192.168.1.1
root@solaris11-1:~#
接下来,运行 sysconfig create-profile -o 命令创建一个名为 delegated_zone.xml 的配置文件,稍后安装新区域时会用到:
root@solaris11-1:~# sysconfig create-profile -o delegated_zone.xml
交互式 System Configuration 工具出现时,使用以下命令指定所需的配置信息:
开始安装区域之前,应检查发布者的位置(可以是远程,也可以是本地),确保可以访问能够在区域中安装 Oracle Solaris 软件包的本地发布者:
root@solaris11-1:~# pkg publisher PUBLISHER TYPE STATUS P LOCATION solaris origin online F http://localhost:9999/ solaris mirror online F http://localhost:9999/ solarisstudio (disabled) origin online F https://pkg.oracle.com/solarisstudio/release/ training (disabled) origin online F http://localhost:8888/
看起来我们可以访问位于 localhost:9999 的本地发布者 solaris,因此安装区域时可以使用该发布者。
为了安装区域,安装目录的所有者必须拥有读、写和执行权限 (rwx),因此运行以下命令:
root@solaris11-1:/myzones# chmod 700 delegated_zone
我们现在可以使用之前创建的 delegated_zone.xml 文件安装 delegated_zone 区域了:
root@solaris11-1:~# zoneadm -z delegated_zone install -c /root/delegated_zone.xml
The following ZFS file system(s) have been created:
myzones/delegated_zone
Progress being logged to /var/log/zones/zoneadm.20131206T171039Z.delegated_zone.install
Image: Preparing at /myzones/delegated_zone/root.
AI Manifest: /tmp/manifest.xml.2uaWxj
SC Profile: /root/delegated_zone.xml
Zonename: delegated_zone
Installation: Starting ...
Creating IPS image
Startup linked: 1/1 done
Installing packages from:
solaris
origin: http://localhost:9999/
DOWNLOAD PKGS FILES XFER (MB) SPEED
Completed 183/183 33556/33556 222.2/222.2 323k/s
PHASE ITEMS
Installing new actions 46825/46825
Updating package state database Done
Updating image state Done
Creating fast lookup database Done
Installation: Succeeded
Note: Man pages can be obtained by installing pkg:/system/manual
done.
Done: Installation completed in 830.765 seconds.
Next Steps: Boot the zone, then log into the zone console (zlogin -C)
to complete the configuration process.
Log saved in non-global zone as /myzones/delegated_zone/root/var/log/zones/zoneadm.20131206T171039Z.delegated_zone.install
好极了!一切正常。我们来看看区域状态:
root@solaris11-1:~# zoneadm list -iv ID NAME STATUS PATH BRAND IP 0 global running / solaris shared - delegated_zone installed /myzones/delegated_zone solaris shared
delegated_zone 现在的状态为 installed。
使用以下命令启动 delegated_zone:
root@solaris11-1:~# zoneadm -z delegated_zone boot
如果再次查看区域状态,应该会看到现在 delegated_zone 有了区域 ID,因为区域已经运行:
root@solaris11-1:~# zoneadm list -iv ID NAME STATUS PATH BRAND IP 0 global running / solaris shared 1 delegated_zone running /myzones/delegated_zone solaris shared
真棒!下面登录 delegated_zone 确认安装:
root@solaris11-1:~# zlogin delegated_zone [Connected to zone 'delegated_zone' pts/4] Oracle Corporation SunOS 5.11 11.1 September 2012 root@delegatedzone:~# uname -a SunOS delegatedzone 5.11 11.1 i86pc i386 i86pc root@delegatedzone:~# zfs list NAME USED AVAIL REFER MOUNTPOINT rpool 423M 15.2G 31K /rpool rpool/ROOT 423M 15.2G 31K legacy rpool/ROOT/solaris 423M 15.2G 397M / rpool/ROOT/solaris/var 24.4M 15.2G 23.8M /var rpool/VARSHARE 39K 15.2G 39K /var/share rpool/export 63K 15.2G 32K /export rpool/export/home 31K 15.2G 31K /export/home root@delegatedzone:~# zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT rpool 15.9G 423M 15.5G 2% 1.00x ONLINE - root@delegatedzone:~# exit logout [Connection to zone 'delegated_zone' pts/4 closed] root@solaris11-1:~#
有趣的是,与 delegated_zone 关联的 IP 地址 (192.168.1.198) 出现在与 net0 接口关联的全局区域网络配置中,这是因为我们在创建区域时指定了 ip-type=shared:
root@solaris11-1:/myzones# ipadm show-addr ADDROBJ TYPE STATE ADDR lo0/v4 static ok 127.0.0.1/8 lo0/zoneadmd.v4 static ok 127.0.0.1/8 net0/v4 dhcp ok 192.168.1.105/24 net0/zoneadmd.v4 static ok 192.168.1.198/24 lo0/v6 static ok ::1/128 lo0/zoneadmd.v6 static ok ::1/128 net0/v6 addrconf ok fe80::a00:27ff:fe56:85b8/10
环境准备好了。如前所述,ZFS 允许我们将文件系统(数据集)委托给非全局区域,然后非全局区域管理员将能够作为所有者管理此数据集。
可以轻松创建新池 (delegated_pool) 和新文件系统 (delegated_filesystem_1):
root@solaris11-1:/myzones# zpool create delegated_pool c8t8d0 root@solaris11-1:/myzones# zfs create delegated_pool/delegated_filesystem_1 root@solaris11-1:/myzones# zpool list delegated_pool NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT delegated_pool 3.97G 124K 3.97G 0% 1.00x ONLINE - root@solaris11-1:/myzones# zfs list delegated_pool/delegated_filesystem_1 NAME USED AVAIL REFER MOUNTPOINT delegated_pool/delegated_filesystem_1 31K 3.91G 31K /delegated_pool/delegated_filesystem_1
现在该执行主要任务了。我们将使用 zonecfg 命令委托 delegated_filesystem_1,然后查看结果,重新启动区域:
root@solaris11-1:~# zonecfg -z delegated_zone
zonecfg:delegated_zone> add dataset
zonecfg:delegated_zone:dataset> set name=delegated_pool/delegated_filesystem_1
zonecfg:delegated_zone:dataset> end
zonecfg:delegated_zone> verify
zonecfg:delegated_zone> commit
zonecfg:delegated_zone> exit
root@solaris11-1:~# zonecfg -z delegated_zone info
zonename: delegated_zone
zonepath: /myzones/delegated_zone
brand: solaris
autoboot: true
bootargs:
file-mac-profile:
pool:
limitpriv:
scheduling-class:
ip-type: shared
hostid:
fs-allowed:
net:
address: 192.168.1.198
allowed-address not specified
configure-allowed-address: true
physical: net0
defrouter: 192.168.1.1
dataset:
name: delegated_pool/delegated_filesystem_1
alias: delegated_filesystem
root@solaris11-1:~# zoneadm -z delegated_zone reboot
root@solaris11-1:~# zlogin delegated_zone
[Connected to zone 'delegated_zone' pts/4]
Oracle Corporation SunOS 5.11 11.1 September 2012
root@delegatedzone:~# uname -a
SunOS delegatedzone 5.11 11.1 i86pc i386 i86pc
root@delegatedzone:~# zfs list
NAME USED AVAIL REFER MOUNTPOINT
delegated_filesystem 31K 3.91G 31K /delegated_filesystem
rpool 446M 15.2G 31K /rpool
rpool/ROOT 446M 15.2G 31K legacy
rpool/ROOT/solaris 446M 15.2G 416M /
rpool/ROOT/solaris/var 24.5M 15.2G 23.8M /var
rpool/VARSHARE 39K 15.2G 39K /var/share
rpool/export 63K 15.2G 32K /export
rpool/export/home 31K 15.2G 31K /export/home
root@delegatedzone:~#
在全局区域运行以下命令,验证是否成功委托了新文件系统:
root@solaris11-1:~# zfs list -r delegated_pool NAME USED AVAIL REFER MOUNTPOINT delegated_pool 124K 3.91G 31K /delegated_pool delegated_pool/delegated_filesystem_1 31.5K 3.91G 31.5K /myzones/delegated_zone/root/delegated_filesystem
令人惊叹!我们成功地将一个数据集委托给 delegated_zone 区域。
以下是我撰写的其他一些文章的链接:
以下是有关 Oracle Solaris 11 的一些资源:
Alexandre Borges 是一位 Oracle ACE,曾于 2001 至 2010 年任职于 Sun Microsystems,并担任签约讲师,主要负责讲授 Oracle Solaris、Oracle Solaris Cluster、Oracle Solaris 安全性、Java EE、Sun 硬件和 MySQL 课程。目前,他为 Symantec、Oracle 合作伙伴、Hitachi 和 EC-Council 提供课程教学,并且讲授一些关于信息安全的非常专业的课程。此外,他还是 Linux Magazine Brazil 的特约撰稿人和专栏作家。
| 修订版 1.0,2014 年 4 月 9 日 |