情況說明
(1)solaris地區zone也就是相當於solaris虛擬化,也是目前oracle在solaris平台下的虛擬化方案之一。
(2)solaris地區zone分為稀疏根地區與完全根地區,簡單一點就是稀疏根地區共用縮主機檔案系統中的程式與檔案,核心檔案與庫唯讀,佔用空間小,完全根地區就是完全複製一份solaris作業系統檔案,完全獨立的作業系統。本文就是建立的是完全根地區zone。
1.建立zfs檔案系統目錄,準備zone建立
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013236323-0.png" height="88" />
建立rpool/vmtest01—zfs檔案系統並掛載到/vmtest01.
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013235S3-1.png" height="191" />
2.建立vmtest01完全地區zone(1)建立配置過程如下
[root@node2:/]# zonecfg -z vmtest01vmtest01: 沒有配置此類地區使用 'create' 開始配置新地區。zonecfg:vmtest01>zonecfg:vmtest01> create -bzonecfg:vmtest01> set zonepath=/vmtest01zonecfg:vmtest01> set autoboot=truezonecfg:vmtest01> set scheduling-class=FSSzonecfg:vmtest01>zonecfg:vmtest01> add netzonecfg:vmtest01:net> set physical=e1000g0zonecfg:vmtest01:net> set address=192.168.233.200zonecfg:vmtest01:net> set defrouter=192.168.233.2zonecfg:vmtest01:net> endzonecfg:vmtest01>zonecfg:vmtest01> add capped-memoryzonecfg:vmtest01:capped-memory> set physical=512Mzonecfg:vmtest01:capped-memory> set swap=1024Mzonecfg:vmtest01:capped-memory> set locked=512Mzonecfg:vmtest01:capped-memory> endzonecfg:vmtest01>zonecfg:vmtest01> commitzonecfg:vmtest01> exportcreate -bset zonepath=/vmtest01set autoboot=trueset scheduling-class=FSSset ip-type=sharedadd netset address=192.168.233.200set physical=e1000g0set defrouter=192.168.233.2endadd capped-memoryset physical=512Mendadd rctlset name=zone.max-swapadd value (priv=privileged,limit=1073741824,action=deny)endadd rctlset name=zone.max-locked-memoryadd value (priv=privileged,limit=536870912,action=deny)endzonecfg:vmtest01> verifyzonecfg:vmtest01> exit[root@node2:/]#
建立完畢後,會在/etc/zone目錄下建立vmtest01.xml設定檔。
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/201323O29-2.png" height="670" />
(2)開始複製安裝檔案系統
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013235K0-3.png" height="198" />
(3)啟動vmtest01虛擬機器
可以看到vmtest01虛擬機器的狀態。
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013235F1-4.png" height="127" />
CONFIGURED 已配置)INCOMPLETE 不完整)INSTALLED 已安裝)READY 就緒)RUNNING 正在運行)SHUTTING_DOWN正在關閉)DOWN 關閉)在標準的非全域地區初啟過程中,地區會經過以下狀態:CONFIGURED->INSTALLED->READY->RUNNING
(4)進入vmtest01虛擬機器控制台進行系統配置
一步一步安裝進行,直到完畢。
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/201323CE-5.png" height="441" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013233D9-6.png" height="243" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013232934-7.png" height="299" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013235462-8.png" height="294" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013236413-9.png" height="294" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/201323CD-10.png" height="292" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013236219-11.png" height="295" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013235645-12.png" height="300" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013233395-13.png" height="299" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013233Q2-14.png" height="298" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/20132314L-15.png" height="299" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013236062-16.png" height="298" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013232116-17.png" height="295" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013232945-18.png" height="295" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013234A1-19.png" height="201" />
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013233203-20.png" height="331" />
(5)退出虛擬機器
輸入~.斷行符號即可退出。
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013232404-21.png" height="190" />
3.zone虛擬機器管理
(1)查看虛擬機器
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013235915-22.png" height="123" />
(2)啟動,暫停,重啟
啟動ZONE
# zoneadm -z vmtest01 boot
準備ZONE,不啟動
# zoneadm -z vmtest01 ready
ZONE停機
# zoneadm -z vmtest01 halt
重啟ZONE
# zoneadm -z vmtest01 reboot
(3)虛擬機器進入與退出
1)進入虛擬機器
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013234247-23.png" height="127" />
2)輸入~.退出虛擬機器
650) this.width=650;" style="border-bottom:0px;border-left:0px;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://www.bkjia.com/uploads/allimg/131227/2013231C0-24.png" height="95" />
(4)虛擬機器刪除
[root@node2:/]# zoneadm -z vmtest01 uninstall您確定要 uninstall 地區 vmtest01 (y/[n])? y該地區的 ZFS 檔案系統已被銷毀。[root@node2:/]#
(5)虛擬機器組態檔刪除
[root@node2:/]# zonecfg -z vmtest01 delete您確定要刪除地區 vmtest01 (y/[n])? y[root@node2:/]#
4.樣本稀疏根地區建立樣本
# zonecfg -z vmtest01zonecfg:vmtest01> createzonecfg:vmtest01> set zonepath=/vmtest01zonecfg:vmtest01> set autoboot=truezonecfg:vmtest01> set scheduling-class=FSSzonecfg:vmtest01> remove inherit-pkg-dir dir=/libzonecfg:vmtest01> remove inherit-pkg-dir dir=/platformzonecfg:vmtest01> remove inherit-pkg-dir dir=/sbinzonecfg:vmtest01> remove inherit-pkg-dir dir=/usrzonecfg:vmtest01> add netzonecfg:vmtest01:net> set physical=e1000g0zonecfg:vmtest01:net> set address=192.168.233.200zonecfg:vmtest01:net> set defrouter=192.168.233.2zonecfg:vmtest01:net> endzonecfg:vmtest01> add capped-memoryzonecfg:vmtest01:capped-memeory> set physical=512Mzonecfg:vmtest01:capped-memeory> set swap=1024Mzonecfg:vmtest01:capped-memeory> set locked=512Mzonecfg:vmtest01:capped-memeory> endzonecfg:vmtest01> commitzonecfg:vmtest01> exportzonecfg:vmtest01> verifyzonecfg:vmtest01> exit# zoneadm -z vmtest01 install# zoneadm -z vmtest01 boot# zoneadm list -vi# zlogin -C vmtest01# zlogin vmtest01
本文出自 “koumm的linux技術部落格” 部落格,請務必保留此出處http://koumm.blog.51cto.com/703525/1305008