Unit 1 Advanced Filesystem Management.docx

上传人:b****5 文档编号:7273549 上传时间:2023-01-22 格式:DOCX 页数:13 大小:23.36KB
下载 相关 举报
Unit 1 Advanced Filesystem Management.docx_第1页
第1页 / 共13页
Unit 1 Advanced Filesystem Management.docx_第2页
第2页 / 共13页
Unit 1 Advanced Filesystem Management.docx_第3页
第3页 / 共13页
Unit 1 Advanced Filesystem Management.docx_第4页
第4页 / 共13页
Unit 1 Advanced Filesystem Management.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

Unit 1 Advanced Filesystem Management.docx

《Unit 1 Advanced Filesystem Management.docx》由会员分享,可在线阅读,更多相关《Unit 1 Advanced Filesystem Management.docx(13页珍藏版)》请在冰豆网上搜索。

Unit 1 Advanced Filesystem Management.docx

Unit1AdvancedFilesystemManagement

Uponcompletionofthisunit,youshouldbeableto:

·Performbackups

·SetupandmanageSoftwareRAIDdevices

·ConfigureLogicalVolumes

·SetupLVMSnapshots

ArchivingTools

·tar

·dump/restore

·rsync

·ProjectAmanda

·3rdpartyutilities

Archivesarecommonlycompressed

tarnativelysupportscompressionusinggzipandgunzip,orbzip2andbunzip2

1、tar命令使用“cf”命令选项可实现对文件和目录的归档=打包

tarcvf文件名.tar需要备份的文件或目录名

2、打包的同时进行压缩

#tar-zcvffilename.tar.gzfilename----打包的同时以gzip压缩

#tar-jcvffilename.tar.bz2filename----打包的同时以bzip2压缩

3、查看tar归档文件中的目录列表

Tartf文件名.tar---查看tar格式的归档文件中的内容

参数“t”表示查看归档文件中的文件和目录列表

参数“f”指定要查看的归档文件名

Tartzf文件名.tar.gz---查看压缩的归档文件中的内容

参数“z”表示查看的是压缩归档文件

Tarjzf文件名.tar.bz2

4.、使用tar命令恢复归档文件

参数“x”表示释放归档文件

Tar-xvf文件名.tar-C目录名

Tar-zxvf文件名.tar.gz-C目录名

Tar-jxvf文件名.tar.bz2-C目录名

以上两个命令可完成恢复归档文件到指定目录,如果不使用-c选项,tar会将归档文件恢复到当前目录

CreatingFileArchives:

OtherTools

·Zipandunzip

·Supportspkzip-compatiblearchives

·example:

#zip-retc.zip/etc/

#unzipetc.zip

·file-roller----Graphicalmulti-formatarchivingtool

·Dd命令的用法:

语法:

ddif=“input_file”of=“output_file”bs=”block_size”count=“number”

如将/etc/passwd备份到/tmp/passwd.back中

#ddif=/etc/passwdof=/tmp/passwd.back

再如备份/dev/hda的MBR

#ddif=/dev/hdaof=/tmp/mbr.backbs=512count=1

#ddif=/dev/zeroof=/tmp/swapbs=4kcount=16382----该档案的大小为4k*16382=63.99M

#ddif=/dev/hdaof=dev/hdb----完整地将/dev/hda都备份到/dev/hdb中。

注解:

dd命令是用来转换文件并且用于复制,if指的是要输入文件格式,of指的是输出文件,将其输出到/tmp/swap,bs指的是一个分区占用多少kbytes,count值还有多少bs,文件容量为bs*count~64M

制作引导光盘:

#ls-l/mnt/iso/images/----(/mnt/iso为光盘挂载点,可列出引导盘的镜像文件,boot.iso是安装程序引导光盘的镜像文件,使用光盘刻录软件可以将该文件刻录为引导光盘。

Diskboot.img是USB设备引导的镜像文件。

使用dd命令可以将该文件制成可安装程序的U盘。

方法如下:

#ddif=diskboot.imgof=/dev/sda

CPIO的用法:

原理:

通过数据流重导向的方法,将文件进行输入与输出的一种方式。

常用于备份与还原

#cpio–covB>[file|device]----备份

#cpio–icduv<[file|device]----还原

例如:

#findtest1|cpio-o>test.cpio----找出test1目录下的所有文件并打包,打包后命名为test.cpio

#cpio-it

#cpio-id

将系统上所有数据都写入磁带机:

#find/-print|cpio–cobB>/dev/st0

将磁带机上的数据还原回来

#cpio–icduv

注解:

由于cpio无法直接读取文件,而需要“每一个文件或目录的路径连同文件名一起”才可以记录下来,因此cpio常与find一起使用,虽不太好用,但却可以备份任何数据,包括/dev/中的任何设备文件

Remotebackups

·Username@hostname:

/path(username为指定的使用者名称,hostname为远程主机)

·tar-czvfxiaofan@example:

/var/host.tar.gz/home

·dump-0ufxiaofan@example:

/var/home.dump/home

Archivingtools:

tar

·tarcanbackuptoafileortapedevice

·SupportsGZIPandBZIP2compression

·Canpreservefilepermissions,ownershipandtimestamps

·Supportsextendedattributes

·Usesrmttowritetoaremotetapedevice

ArchivingTools:

dump/restore

·Backupandrestoreext2/3filesystems

·Doesnotworkwithotherfilesystems

·dumpshouldonlybeusedonunmountedfilesystemsorfilesystemsthatareread-only.

·Candofullorincrementalbackups

·Examples:

Dump-0u-f/dev/nst0/dev/hda2(其中“-0~-9”:

“-0”指的是完全备份;“-1~-9”指的是增量备份)

Restore-rf/dev/nst0

Usingdump

Thedumpcommandcanbedirectedtoread/etc/fstabanddobackupsbasedoninformationitkeepsastowhichfilesystemsneedtobebackedup.

Forexample,

Dump-0u-f/dev/nst1/home

Willdoafullbackupofthe/homefilesystemontothetapedevicenst1.The–uoptionwillupdatethefile/etc/dumpdates,whichwillrecorddumpinformationforfutureusebydump.Afteralevel0backup,dumpwillperformanincrementalbackupeverydayonactivefilesystemslistedin/etc/fstab.

Thecommand:

Dump-4u-f/dev/nst1/home

Willperformanincrementalupdateofallfilesthatchangedsincethelastbackupoflevel3orlower,asrecordedinthe/etc/dumpdatesfile.

Dump-0ufxiaofan@svr:

/dev/nst0/home

Performsaremotebackupusingrmt.Useuser@host:

pathformattospecifytheremoteuser,host,anddevice.SSHcanbeusedasatransportlayerwhen$RSHissettossh.

Usingrestore

Torestoredatabackedupwithdump,makeacleanfilesystem(usingmkfs),mountthefilesystem,andcdtothedirectorywherethefilesystemismounted.Thenruntherestorecommand:

Restore-rf/dev/nst1

ArchivingTools:

rsync

·Efficientlycopiesfilestoorfromremotesystems

·Usessecuresshconnectionsfortransport

·rsync*.confbarney:

/home/joe/configs/

·Fasterthanscp–copiesdifferencesinlikefiles

Rsyncisaprogramthatworksinmuchthesamewaythattheolderrcpdoes,buthasmanymoreoptionsandusesthersyncremote-updateprotocoltogreatlyincreasethespeedoffiletransferswhenthedestinationfilealreadyexists.

Thersyncremote-updateprotocolallowsrsynctotransferjustthedifferencesbetweentwosetsoffilesusinganefficientchecksum-searchalgorithm.Thisutilityisusefulfortaskslikeupdatingwebcontent,becauseitwillonlytransferthechangedfiles.

Usefuloptionstorsync

-ecommand----specifiesanexternal,rsh-compatibleprogramtoconnectwith(usuallyssh)

-a----recurssubdirectories,preservingpermissions,etc.

-r----recurssubdirectorieswithoutpreservingpermissions,etc.

--partial----continuespartiallydownloadedfiles

--progress----printsaprogressbarwhiletransferring

-P----isthesameas--partial--progress

-p----preservepermissions

-A----preserveACLs(implies–p)

-X----preserveextendedattributes(implies–p)

WhatisSoftwareRAID?

·Multipledisksgroupedtogetherinto“arrays”toprovidebetterperformance,redundancyorboth.

·mdadm----providestheadministrationinterfacetosoftwareRAID.

·Many“RAIDLevels”supported,includingRAID0,1,5and6.

·Sparedisksaddextraredundancy

·RAIDdevicesarenamed,/dev/md0,/dev/md1,/dev/md2,/dev/md3andsoon.

ThemostcommandonlyusedRAIDare:

·RAID0orStriping(带区卷):

Twoormoredisksusedtocreateasinglelargehighperformancevolume.Performanceisbetterifdriversofequalsizeareused.Noredundancy,sochanceoffailureisveryhigh.Arraysizeequalsthesumofalldisksinarray.

·RAID1orMirroring:

Twodiskscontainingthesamedataupdatedsimultaneously.Redundancyoffersgoodprotectionagainstdiskfailure.Canslowwriteperformancebuttendstoimprovereadperformance.OnlyRAIDtypethatyoucanplacethe/bootpartitionon.Hotsparediskscanbeusedtoimprovefault-tolerance.Arraysizeequalsthesizeofthesmallestdiskused.

·RAID5:

Threeormorediskwithzeroormorehotspares.Agoodbalancebetweenperformanceandreliability.Redundancyisachievedbysplitting(分区)parity(奇偶性)betweenalldisks,onediskcanbelostwithoutcausingarrayfailure.Bothreadandwritespeedsareusuallyimproved,butincertaincaseswriteperformanceisdramaticallydecreased.ForthisreasonRAID5isoftennotagoodchoicetohostdatabases.

·RAID6,orstripingwithdual(duplicated)distributedparity.SimilartoRAID5exceptthatitimprovesfaulttolerancebyallowingthefailureofanytwodrivesinthearray.Whilethesimultaneousfailureoftwodevicesmaybeanunlikelyevent,RAID6protectsthearrayfromdatalossduringrecoveryofasinglediskfailure,providestheadministratoradditionaltimetoperformrebuilds,improvestheviabilityoflessexpensivedrivesinenterprisestoragesolutions,and,sinceRAIDonlypassivelychecksforbadblocks,protectionfromundiscoveredblockerrors.

Onceanarrayiscreatedit’sdevice,/dev/md0forexample,isusedthesamewayas/dev/hda6or/dev/sda6mayhavebeenusedinanearlierexample.

SoftwareRAIDConfiguration

·CreateanddefineRAIDdevicesusingmdadm

Mdadm-C/de/md0-ayes-l1-n2-x1elements…

·FormateachRAIDdevicewithafilesystem

Mke2fs-j/dev/md0

·TesttheRAIDdevices

·mdadmallowyoutocheckthestatusofyourRAIDdevices

Mdadm--detail/dev/md0

·providesnotificationservicesonthestatus

SoftwareRAIDTestingandRecovery

·Simulating(模拟)diskfailures

Mdadm/dev/md0-f/dev/sda1

·RecoveringfromasoftwareRAIDdiskfailure

·Replacethefailedharddriveandpoweron

·Reconstructpartitionsonthereplacementdrive

·mdadm/dev/md0-a/dev/sda1

·mdadm-r----removethefaileddiskfromthearray

·mdadm,/proc/mdstat,andsyslogmessages

·Disassemble(反汇编)orauto-assemblediskarray

Mdadm-S/dev/md0

Mdadm-A-s

WhatisLogicalVolumeManager(LVM)?

·Alayerofabstractionthatallowseasymanipulationofvolumes.Includingresizingoffilesystems

·Allowreorganizationoffilesystemsacrossmultiplephysicaldevices

·DevicesaredesignatedasPhysicalVolumes

·OneormorePhysicalVolumesareusedtocreateaVolumeGroup

·VolumeGroupsaredefinedwithPhysicalExtentsofafixedsize

·LogicalVolumesarecreatedonVolumeGroupsandarecomposedofPhysicalExtents

·FilesystemsmaybecreatedonLogicalVolumes

CreatingLogicalVolumes

·Createphysicalvolumes

Pvcreate/dev/hda3

·Assignphysicalvolumestovolumegroups

Vgcreatevg0/dev/hda3

·Createlogicalvolumesfromvolumegroups

Lvcreate-L256M-ndatavg0

Mke2fs-j/dev/vg0/data

ResizingLogicalVolumes

·GrowingVolumes

·lvextendcangrowlogicalvolumes

·resize2fscangrowext3filesystemonlineoffline

·Shrinkingvolumes

·Mustbedoneoffline(umount)

·Requiresafilesystemcheck(e2fsck)first

·Filesystemthenreduced(resize2fs)

·Lastly,lvreducecanthenreducethevolume

·VolumeGroupscanbeenlargedwithvgextend

·VolumeGroupscanbereducedwith:

Pvmove/dev/hda3

Vgreducevg0/dev/hda3

LogicalVolumeManagerSnapshots

·SnapshotsarespecialLogicalVolumesthatareanexactcopyofanexistingLogicalVolumeatthetimethesnapshotiscreated

·Snapshotsareperfectforbackupsandotheroperationswhereatemporarycopyofanexistingdatasetisneeded

·SnapshotsonlyconsumespacewheretheyaredifferentfromtheoriginalLogicalVolume

·Snapshots

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 理学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1