Solaris Zone覚え書き
どっかのページをそのままコピペしました。ごめんなさい。
対話式
test環境として、test Zoneを作成してみる。
Zoneを置くディレクトリは、/raidbox/zones/test-zoneとした。
# zonecfg -z test
test: No such zone configured
Use ‘create’ to begin configuring a new zone.
(’create’を実行して新しいゾーンの構成開始)
zonecfg:test> create
zonecfg:test>
(testZone を作成するディレクトリの指定)
zonecfg:test> set zonepath=/raidbox/zones/test-zone/root
zonecfg:test>
(ネットワークインタフェースの設定)
zonecfg:test> add net
zonecfg:test:net> set physical=e1000g0
zonecfg:test:net> set address=192.168.xx.xx/24
zonecfg:test:net> end
zonecfg:test>
(自動起動の設定)
zonecfg:test> set autoboot=true
zonecfg:test>
(設定の確認:’info’での出力例、PAGER環境変数で指定したコマンドで出力される)
zonecfg:testZone> info
zonepath: /raidbox/zones/test-zone/root
Zone autoboot: true
pool:
inherit-pkg-dir: ← ‘inherit-pkg-dir’は共有ファイルシステムで global zone と共有する。
dir: /lib non-global zone においてRead-Onlyの
inherit-pkg-dir: ループバックファイルシステム(lofs)としてマウントされる
dir: /platform ので書き込み出来ない。
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
net:
address: 192.168.xx.xx
physical: e1000g0
zonecfg:test>
(設定の確認:’export’での出力例、コマンドファイル作成時などに使用)
zonecfg:testZone> export
create -b
set zonepath=/raidbox/zones/test/root
set autoboot=true
add inherit-pkg-dir
set dir=/lib
end
add inherit-pkg-dir
set dir=/platform
end
add inherit-pkg-dir
set dir=/sbin
end
add inherit-pkg-dir
set dir=/usr
end
add net
set address=192.168.10.11
set physical=iprb0
end
zonecfg:testZone>
(構成情報の確認、何も出力されなければ正しい)
zonecfg:testZone> verify
zonecfg:testZone>
(設定終了、自動的に’commit’されて設定がファイルに出力される)
zonecfg:testZone> exit
#
#
(確認)
# zoneadm list -vc
ID NAME STATUS PATH
0 global running /
- testZone configured /zone/testZone
以上の作業で設定ファイル /etc/zones/testZone.xml が作成される。
/etc/zones/testZone.xml の内容を以下に示す。
$ cat /etc/zones/testZone.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE zone PUBLIC “-//Sun Microsystems Inc//DTD Zones//EN” “file:///usr/share/lib/xml/dtd/zonecfg.dtd.1″>
<!–
DO NOT EDIT THIS FILE. Use zonecfg(1M) instead.
–>
<zone name=”testZone” zonepath=”/zone/testZone” autoboot=”true”>
<inherited-pkg-dir directory=”/lib”/>
<inherited-pkg-dir directory=”/platform”/>
<inherited-pkg-dir directory=”/sbin”/>
<inherited-pkg-dir directory=”/usr”/>
<network address=”10.31.191.18″ physical=”iprb0″/>
</zone>
システムのインストール
zoneadmin -z test install
初期設定(ブート)
zoneadmin -z test boot
zlogin -C test
zone の管理
状態の確認
$ zoneadm list -vc
起動(boot)
# zoneadm -z ゾーン名 boot
再起動(reboot)
# zoneadm -z ゾーン名 reboot
停止
# zoneadm -z ゾーン名 halt
コンソール接続(global zone から)
# zlogin -C ゾーン名
rootユーザで接続(global zone から)
# zlogin ゾーン名
ユーザを指定して接続(global zone から)
# zlogin -l ユーザ名 ゾーン名
プロセスの確認(global zone から)
# ps -z ゾーン名 -Z
zone の削除
状態確認
$ zoneadm list -vc
ID NAME STATUS PATH
0 global running /
1 testZone running /zone/testZone ← STATUSが"running"なので動作している
停止
(停止処理) # zoneadm -z testZone halt # (状態の確認) # zoneadm list -vc ID NAME STATUS PATH 0 global running / - testZone installed /zone/testZone ← STATUSが"installed"になる
アンインストール
(アンインストール処理) # zoneadm -z testZone uninstall ゾーン testZone を uninstall してよろしいですか (y/[n])? y ← 確認で"y"を入力 # (状態の確認) # zoneadm list -vc ID NAME STATUS PATH 0 global running / - testZone configured /zone/testZone ← STATUSが"configured"になる
構成情報削除
(構成情報削除処理) # zonecfg -z testZone delete Are you sure you want to delete zone testZone (y/[n])? y ← 確認で"y"を入力 # (状態の確認) # zoneadm list -vc ID NAME STATUS PATH 0 global running / ← testZone の情報が消えている (以上の処理で /etc/zones から testZone.xml ファイルも削除される)









