Вы находитесь на странице: 1из 7

12/17/12

Oracle Solaris 11 ZFS Lab

OracleSolaris11ZFSLab
TableofContents
ExerciseZ.1:ZFSPools
ExerciseZ.2:ZFSFileSystems
ExerciseZ.3:ZFSCompression
ExerciseZ.4:ZFSDeduplication
ExerciseZ.5:ZFSSnapshots
ExerciseZ.6:ZFSClones

ExerciseZ.1:ZFSPools
Task:Youhaveseveraldiskstouseforyournewfilesystem.Createanewdiskpoolandafilesystemon
topofit.
Lab:Wewillcheckthestatusofdiskpools,createourownpoolandexpandit.
OurSolaris11installationalreadyhasaZFSpool.It'syourrootfilesystem.Checkthis:
root@solaris:~#zpoollist
NAMESIZEALLOCFREECAPDEDUPHEALTHALTROOT
rpool15.9G5.64G10.2G35%1.00xONLINE

ThisisourrootsystemZFSpool.InSolaris11therootfilesystemmustbeZFScreatedontopofZFS
pool.Whatdoweknowaboutthispool?
root@solaris:~#zpoolstatusrpool
pool:rpool
state:ONLINE
scan:nonerequested
config:

NAMESTATEREADWRITECKSUM
rpoolONLINE000
c3t0d0s0ONLINE000

errors:Noknowndataerrors

Let'snowcreateourownZFSpool.Whatdoweneedforthat?Justseveraldisksandonecommand.We
willcreateseveralfilesin/dev/dskdirectorytheywillactasdisksinourlab:
root@solaris:~#cd/dev/dsk
root@solaris:~#mkfile200mdisk{0..9}

We'lltakefourdisksandcreateaZFSpoolwithRAIDZprotection:
root@solaris:~#zpoolcreatelabpoolraidzdisk0disk1disk2disk3

le:///Users/pavelanni/Projects/SolarisLab/lab/ZFS Lab.html

1/7

12/17/12

Oracle Solaris 11 ZFS Lab

Thatwaseasy,wasn'tit?Andfast,too!CheckourZFSpoolsagain:
root@solaris:~#zpoollist
NAMESIZEALLOCFREECAPDEDUPHEALTHALTROOT
labpool780M194K780M0%1.00xONLINE
rpool15.9G7.57G8.30G47%1.00xONLINE

Bytheway,thefilesystemwasalsocreatedandmountedautomatically:
root@solaris:~#zfslistlabpool
NAMEUSEDAVAILREFERMOUNTPOINT
labpool97.2K551M44.9K/labpool

Doyouneedmorespace?AddingdiskstotheexistingZFSpoolisaseasyascreatingit:
root@solaris:~#zpooladdlabpoolraidzdisk4disk5disk6disk7

Checkitagain:
root@solaris:~#zfslistlabpool
NAMEUSEDAVAILREFERMOUNTPOINT
labpool97.2K1.11G44.9K/labpool

Notetheincreasedfilesystem'ssize.Alsonotetherearetwodiskgroupsinthispoolbothprotectedwith
RAIDZ.ZFShasmanyoptionstoprotectsyourdata,youcanlearnandexperimentswiththemlater.
Backtotop

ExerciseZ.2:ZFSFileSystems
Task:Youhavetocreatehomedirectoriesforyourusersusefilesystemquotatolimittheirspace.
Lab:We'llcreateauser"joe"andsetadiskquotaforhim.
CreatingauserisprettysimilartomostUnix/Linuxsystems.What'sdifferentiswhat'sgoingonbehindthe
scenes.
root@solaris:~#useraddmjoe
root@solaris:~#passwdjoe
NewPassword:oracle1
ReenternewPassword:oracle1
passwd:passwordsuccessfullychangedforjoe

InSolaris11behindthesceneswecreateaseparateZFSfilesystemfortheuser(parameterm)in
/export/home.Checkit:
root@solaris:~#zfslist
NAMEUSEDAVAILREFERMOUNTPOINT
labpool97.2K1.11G44.9K/labpool
rpool7.65G7.97G39K/rpool
rpool/ROOT5.59G7.97G31Klegacy
rpool/ROOT/solaris5.59G7.97G5.17G/
le:///Users/pavelanni/Projects/SolarisLab/lab/ZFS Lab.html

2/7

12/17/12

Oracle Solaris 11 ZFS Lab

rpool/ROOT/solaris/var330M7.97G183M/var
rpool/dump1.03G8.01G1.00G
rpool/export1.48M7.97G32K/export
rpool/export/home1.44M7.97G33K/export/home
rpool/export/home/joe686K7.97G686K/export/home/joe
rpool/export/home/lab760K7.97G760K/export/home/lab
rpool/swap1.03G8.01G1.00G

Whatdoesitmeanforus,systemadministrators?ThatmeanswecanuseallkindsofZFSfeatures
(compression,deduplication,encryption)onaperuserbasis.Wecancreatesnapshotsandperform
rollbacksonaperuserbasis.Moreaboutthatlater.Nowwe'llsetadiskquotaforjoe'shomedirectory.
root@solaris:~#zfssetquota=200mrpool/export/home/joe

Nowchangeuserto"joe"andcheckhowmuchspaceyoucanuse:
root@solaris:#sujoe
joe@solaris$mkfile110mfile1
joe@solaris$mkfile110mfile2

FirstfilewascreatedOK,butwiththesecondonewe'vegotanerror:"Diskquotaexceeded".
Changethequotaforjoeintheotherwindow:
root@solaris:~#zfssetquota=300mrpool/export/home/joe

Thenchangebacktothejoe'swindowandtryagain:
joe@solaris$/usr/sbin/mkfile110mfile2

Success!Asyoucansee,it'sprettyeasytocreateandmanageZFSfilesystems.Remember,bydefault
Solaris11createsaseparateZFSfilesystemforeachuser.
Backtotop

ExerciseZ.3:ZFSCompression
Task:Youarebecominglowonyourdiskspace.Nowyouknowhowtoaddmorediskstoyourpooland
expandyourfilesystem.WhatotherZFSfeaturescanhelpyoutosolvethisproblem?
Lab:InourlabwewillcompressourSolarismanualsdirectoryandseeifweareabletouseitafterthat.
Createaseparatefilesystemforthisonour'labpool'ZFSpool:
root@solaris:~#zfscreatelabpool/zman
root@solaris:~#zfslist|grepzman
labpool/zman31K7.78G31K/labpool/zman

Setcompressionto"gzip"(thereareoptionstogzipandotheralgorithmstoocheckthemanual).Youcan
dothatalsowhilecreatingthefilesystem.
root@solaris:~#zfssetcompression=gziplabpool/zman
le:///Users/pavelanni/Projects/SolarisLab/lab/ZFS Lab.html

3/7

12/17/12

Oracle Solaris 11 ZFS Lab

CopythefirstpartofSolarismanualsthere(itwilltakesometime,bepatient):
root@solaris:~#cprp/usr/share/man/man1/labpool/zman/

Comparethesizes:
root@solaris:~#dush/usr/share/man/labpool/zman
15.2M/usr/share/man
6.8M /labpool/zman

Wejusthavesavedabout55%ofdiskspace.Notbad!Checkifyouareabletousethemanualsafter
compression:
root@solaris:~#exportMANPATH=/labpool/zman;manls

Backtotop

ExerciseZ.4:ZFSDeduplication
Task:Userstendtokeepalotofsimilarfilesintheirarchives.Isitpossibletosavespacebydeduplication?
Lab:WewillcreateaZFSfilesystemwithdeduplicationturnedonandseeifithelps.
Let'smodelthefollowingsituation:wehaveafilesystemwhichisusedasanarchive.We'llcreateseparate
filesystemsforeachuserandimaginethattheystoresimilarfilesthere.
WewillusetheZFSpoolcalledlabpoolthatwehavecreatedinthefirstexercise.
Createafilesystemwithdeduplicationandcompression:
root@solaris:~#zfscreateodedup=onocompression=gziplabpool/archive

Createusers'filesystems(we'llcallthema,b,c,dforsimplicity):
root@solaris:~#zfscreatelabpool/archive/a
root@solaris:~#zfscreatelabpool/archive/b
root@solaris:~#zfscreatelabpool/archive/c
root@solaris:~#zfscreatelabpool/archive/d

Checktheir"dedup"parameter:
root@solaris:~#zfsgetdeduplabpool/archive/a
NAMEPROPERTYVALUESOURCE
labpool/archive/adeduponinheritedfromlabpool/archive

Childrenfilesystemsinheritparametersfromtheirparents.
Createanarchivefrom/usr/share/man/man1,forexample.
root@solaris:~#tarczf/tmp/man.tar.gz/usr/share/man

Andcopyitfourtimestothefilesystemswe'vejustcreated.Don'tforgettocheckdeduplicationrateafter
le:///Users/pavelanni/Projects/SolarisLab/lab/ZFS Lab.html

4/7

12/17/12

Oracle Solaris 11 ZFS Lab

eachcopy.
root@solaris:~#cd/labpool/archive
root@solaris:/labpool/archive#lslh/tmp/man.tar.gz
rwrr1rootroot3.1MDec1317:03/tmp/man.tar.gz
root@solaris:/labpool/archive#zpoollistlabpool
NAMESIZEALLOCFREECAPDEDUPHEALTHALTROOT
labpool1.52G1.05M1.52G0%1.00xONLINE
root@solaris:/labpool/archive#cp/tmp/man.tar.gza/
root@solaris:/labpool/archive#zpoollistlabpool
NAMESIZEALLOCFREECAPDEDUPHEALTHALTROOT
labpool1.52G40.5M1.48G2%1.00xONLINE
root@solaris:/labpool/archive#cp/tmp/man.tar.gzb/
root@solaris:/labpool/archive#zpoollistlabpool
NAMESIZEALLOCFREECAPDEDUPHEALTHALTROOT
labpool1.52G40.7M1.48G2%2.00xONLINE
root@solaris:/labpool/archive#cp/tmp/man.tar.gzc/
root@solaris:/labpool/archive#zpoollistlabpool
NAMESIZEALLOCFREECAPDEDUPHEALTHALTROOT
labpool1.52G41.5M1.48G2%3.00xONLINE
root@solaris:/labpool/archive#cp/tmp/man.tar.gzd/
root@solaris:/labpool/archive#zpoollistlabpool
NAMESIZEALLOCFREECAPDEDUPHEALTHALTROOT
labpool1.52G41.2M1.48G2%4.00xONLINE

ItmighttakeacoupleofsecondsforZFStocommitthosechangesandreportthecorrectdedupratio.Just
repeatthecommandifyoudon'tseetheresultslistedabove.
Remember,wesetcompressionto"on"aswellwhenwecreatedthefilesystem?Checkthecompression
ratio:
root@solaris:/labpool/archive#zfsgetcompressratiolabpool/archive
NAMEPROPERTYVALUESOURCE
labpool/archivecompressratio1.01x

Thereasonissimple:weplacedinthefilesystemfilesthatarecompressedalready.Sometimes
compressioncansaveyousomespace,sometimesdeduplicationcanhelp.
Backtotop

ExerciseZ.5:ZFSSnapshots
Task:Auserhasaccidentallydeletedherfile.Howtorestoreitwithoutgettingtothetapebackup?
Lab:Createasnpashotofourarchivefilesystem:
root@solaris:~#zfssnapshotrlabpool/archive@snap1

Notethe'r'parametertellingZFSthatwewanttosnapshotalldependentfilesystemsaswell.Checkyour
work:
le:///Users/pavelanni/Projects/SolarisLab/lab/ZFS Lab.html

5/7

12/17/12

Oracle Solaris 11 ZFS Lab

root@solaris:~#zfslistrtalllabpool
NAMEUSEDAVAILREFERMOUNTPOINT
labpool18.5M1.10G47.9K/labpool
labpool/archive12.7M1.10G52.4K/labpool/archive
labpool/archive@snap1052.4K
labpool/archive/a3.17M1.10G3.17M/labpool/archive/a
labpool/archive/a@snap103.17M
labpool/archive/b3.17M1.10G3.17M/labpool/archive/b
labpool/archive/b@snap103.17M
labpool/archive/c3.17M1.10G3.17M/labpool/archive/c
labpool/archive/c@snap103.17M
labpool/archive/d3.17M1.10G3.17M/labpool/archive/d
labpool/archive/d@snap103.17M
labpool/zman5.41M1.10G5.41M/labpool/zman

Imagineuser'a'haddeletedherarchivestoredin/labpool/archive/a.
root@solaris:~#rm/labpool/archive/a/*

Andshecomestoyouaskingforhelp."Canyourestoremyarchivebeforetomorrow?",sheasks.Of
course,youcan!Inamatterofseconds,nothours,herarchivefileswillbeback!Justrollbackthe
snapshot!
root@solaris:~#zfsrollbacklabpool/archive/a@snap1

Youmayask"HowoftenshouldImakesnapshots?Dosnapshotstakealotofspace?Theanswerishere:
root@solaris:~#zfslistrtalllabpool
NAMEUSEDAVAILREFERMOUNTPOINT
labpool18.5M1.10G47.9K/labpool
labpool/archive12.7M1.10G52.4K/labpool/archive
labpool/archive@snap1052.4K
labpool/archive/a3.17M1.10G3.17M/labpool/archive/a
labpool/archive/b3.17M1.10G3.17M/labpool/archive/b
labpool/archive/c3.17M1.10G3.17M/labpool/archive/c
labpool/archive/d3.17M1.10G3.17M/labpool/archive/d
labpool/zman5.41M1.10G5.41M/labpool/zman

Thesnapshotuses0bytesbecausewehavenotchangedanythinginyourhomedirectory.Whenyou
makechangestoyourfilesystem,itwilltakemorespace.Trytochangesomethinginthe/labpool/archive
directoryandcheckthesizesagain.LearnmoreabouthowsnapshotsworkfromourOTNtechnical
presentationsandarticles.
Foodforthought:Howcansnapshotsbeusedinthereallifeenvironment?Backupisthefirstideathat
comestomind.Whatelse?

ExerciseZ.6:ZFSClones
Task:Weneedtocreateacopyofourtransactionaldatatodosomeanalysisandmodifications.Inother
words,weneedawriteablesnapshot.
le:///Users/pavelanni/Projects/SolarisLab/lab/ZFS Lab.html

6/7

12/17/12

Oracle Solaris 11 ZFS Lab

Lab:InthislabwewilluseZFScloningfeature.Clonesaresimilartosnapshots,butyoucanmodifythem.
Similarlytosnapshots,ittakessecondstocreatethemandtheytakealmostnospaceuntilyoustart
changingyourfiles.
Clonescan'tbecreatedfromalivefilesystem.Tocreateaclonewehavetohaveasnapshotfirst.Inthis
labwecanuseasnapshot'@snap1'wehavejustcreated.
root@solaris:~#zfsclonelabpool/archive/a@snap1labpool/a_work
root@solaris:~#zfslistrtalllabpool
NAMEUSEDAVAILREFERMOUNTPOINT
labpool18.6M1.10G49.4K/labpool
labpool/a_work26.9K1.10G3.17M/labpool/a_work
labpool/archive12.8M1.10G52.4K/labpool/archive
labpool/archive@snap1052.4K
labpool/archive/a3.20M1.10G3.17M/labpool/archive/a
labpool/archive/a@snap126.9K3.17M
labpool/archive/b3.17M1.10G3.17M/labpool/archive/b
labpool/archive/b@snap103.17M
labpool/archive/c3.17M1.10G3.17M/labpool/archive/c
labpool/archive/c@snap103.17M
labpool/archive/d3.17M1.10G3.17M/labpool/archive/d
labpool/archive/d@snap103.17M
labpool/zman5.41M1.10G5.41M/labpool/zman

Checkifthearchiveisinplaceintheclonefilesystem:
root@solaris:~#cd/labpool/a_work
root@solaris:/labpool/a_work#ls
man.tar.gz

Unpackthearchiveandthenchecktheoriginaldirectory.
root@solaris:/labpool/a_work#tarxzvfman.tar.gz
....................
tar:Removingleading'/'from'/usr/share/man/man1/trackerservices.1'
xusr/share/man/man1/trackerservices.1,1938bytes,4tapeblocks
root@solaris:/labpool/a_work#lsl
total6413
rwrr1rootroot3257177Dec1317:05man.tar.gz
drwxrxrx3rootroot3Dec1318:04usr
root@solaris:/labpool/a_work#cd../archive/a
root@solaris:/labpool/archive/a#lsl
total6409
rwrr1rootroot3257177Dec1317:05man.tar.gz

Thispowerfulcloningfeaturecanbeusedforyourregulardata.OracleSolarisusesitinternallytocreate
bootenvironmentsandzoneclones.Theywillbedescribedinthefollowinglabexercises.
Backtotop

le:///Users/pavelanni/Projects/SolarisLab/lab/ZFS Lab.html

7/7

Вам также может понравиться