日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

怎么对XFS进行备份、恢复、修复

發布時間:2023/12/19 综合教程 32 生活家
生活随笔 收集整理的這篇文章主要介紹了 怎么对XFS进行备份、恢复、修复 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這篇文章將為大家詳細講解有關怎么對XFS進行備份、恢復、修復,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

XFS是高性能文件系統,由于它的高性能,XFS成為了許多企業級系統的首選,特別是有大量數據,需要結構化伸縮性和穩定性的。例如,RHEL/CentOS 7 和Oracle Linux將XFS作為默認文件系統,SUSE/openSUSE已經為XFS做了長期支持。

一、XFS文件系統的備份與恢復

XFS文件系統提供了整個分區備份的工具xfsdump供用戶使用,用戶可以在不借助第三方軟件的情況下對XFS文件系統上的數據實施備份。

創建XFS分區及測試文件

[root@localhost~]#ls/dev/sd*/dev/sda/dev/sda1/dev/sda2/dev/sdb
[root@localhost~]#fdisk/dev/sdbWelcometofdisk(util-linux2.23.2).

Changeswillremaininmemoryonly,untilyoudecidetowritethem.
Becarefulbeforeusingthewritecommand.


Command(mforhelp):p

Disk/dev/sdb:21.5GB,21474836480bytes,41943040sectors
Units=sectorsof1*512=512bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Disklabeltype:dos
Diskidentifier:0x08a5199d

DeviceBootStartEndBlocksIdSystem

Command(mforhelp):n
Partitiontype:
pprimary(0primary,0extended,4free)
eextended
Select(defaultp):p
Firstsector(2048-41943039,default2048):
Usingdefaultvalue2048
Lastsector,+sectorsor+size{K,M,G}(2048-41943039,default41943039):+1G
Partition1oftypeLinuxandofsize1GiBissetCommand(mforhelp):p

Disk/dev/sdb:21.5GB,21474836480bytes,41943040sectors
Units=sectorsof1*512=512bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Disklabeltype:dos
Diskidentifier:0x08a5199d

DeviceBootStartEndBlocksIdSystem
/dev/sdb120482099199104857683Linux

Command(mforhelp):w
Thepartitiontablehasbeenaltered!

Callingioctl()tore-readpartitiontable.
Syncingdisks.
[root@localhost~]#partprobeWarning:Unabletoopen/dev/sr0read-write(Read-onlyfilesystem)./dev/sr0hasbeenopenedread-only.
[root@localhost~]#ls/dev/sd*/dev/sda/dev/sda1/dev/sda2/dev/sdb/dev/sdb1
[root@localhost~]#mkfs.xfs-f/dev/sdb1meta-data=/dev/sdb1isize=512agcount=4,agsize=65536blks
=sectsz=512attr=2,projid32bit=1
=crc=1finobt=0,sparse=0
data=bsize=4096blocks=262144,imaxpct=25
=sunit=0swidth=0blks
naming=version2bsize=4096ascii-ci=0ftype=1log=internallogbsize=4096blocks=2560,version=2
=sectsz=512sunit=0blks,lazy-count=1
realtime=noneextsz=4096blocks=0,rtextents=0
[root@localhost~]#blkid/dev/sdb1/dev/sdb1:UUID="61a5e59d-92d3-458d-ac09-7d945469cda6"TYPE="xfs"[root@localhost~]#mkdir/file[root@localhost~]#echo"/dev/sdb1/filexfsdefaults00">>/etc/fstab[root@localhost~]#mount-a[root@localhost~]#df-hFilesystemSizeUsedAvailUse%Mountedon
/dev/mapper/rhel-root17G1.9G16G12%/
devtmpfs901M0901M0%/dev
tmpfs912M0912M0%/dev/shm
tmpfs912M8.7M903M1%/run
tmpfs912M0912M0%/sys/fs/cgroup
/dev/sr03.8G3.8G0100%/yum
/dev/sda11014M143M872M15%/boot
tmpfs183M0183M0%/run/user/0
/dev/sdb11014M33M982M4%/file
[root@localhost~]#cd/file/[root@localhostfile]#ls[root@localhostfile]#touchfile{1..100}[root@localhostfile]#lsfile1file16file23file30file38file45file52file6file67file74file81file89file96
file10file17file24file31file39file46file53file60file68file75file82file9file97
file100file18file25file32file4file47file54file61file69file76file83file90file98
file11file19file26file33file40file48file55file62file7file77file84file91file99
file12file2file27file34file41file49file56file63file70file78file85file92
file13file20file28file35file42file5file57file64file71file79file86file93
file14file21file29file36file43file50file58file65file72file8file87file94
file15file22file3file37file44file51file59file66file73file80file88file95

備份XFS分區

[root@localhostfile]#mkdir/backup[root@localhostfile]#yuminstall-yxfsdump[root@localhostfile]#xfsdump-f/backup/file.bak/file#利用xfsdump備份掛載點/file對應的分區xfsdump:usingfiledump(drive_simple)strategy
xfsdump:version3.1.4(dumpformat3.0)-type^Cforstatusandcontrol

=============================dumplabeldialog==============================#輸入dump會話標簽pleaseenterlabelforthisdumpsession(timeoutin300sec)
->file.bak
sessionlabelentered:"file.bak"---------------------------------enddialog---------------------------------

xfsdump:level0dumpoflocalhost.localdomain:/file
xfsdump:dumpdate:ThuOct3122:16:022019
xfsdump:sessionid:02a1445f-5ff3-4518-ab2c-888d9e2a4c44
xfsdump:sessionlabel:"file.bak"xfsdump:inomapphase1:constructinginitialdumplist
xfsdump:inomapphase2:skipping(nopruningnecessary)
xfsdump:inomapphase3:skipping(onlyonedumpstream)
xfsdump:inomapconstructioncomplete
xfsdump:estimateddumpsize:52800bytes

=============================medialabeldialog=============================#輸入媒體標簽pleaseenterlabelformediaindrive0(timeoutin300sec)
->file
medialabelentered:"file"---------------------------------enddialog---------------------------------

xfsdump:creatingdumpsessionmediafile0(media0,file0)
xfsdump:dumpinginomap
xfsdump:dumpingdirectories
xfsdump:dumpingnon-directoryfiles
xfsdump:endingmediafile
xfsdump:mediafilesize86544bytes
xfsdump:dumpsize(non-dirfiles):0bytes
xfsdump:dumpcomplete:27secondselapsed
xfsdump:DumpSummary:
xfsdump:stream0/backup/file.bakOK(success)
xfsdump:DumpStatus:SUCCESS
[root@localhostfile]#ls/backup/#已經成功創建備份文件file.bak

恢復過程

[root@localhostfile]#lsfile1file16file23file30file38file45file52file6file67file74file81file89file96
file10file17file24file31file39file46file53file60file68file75file82file9file97
file100file18file25file32file4file47file54file61file69file76file83file90file98
file11file19file26file33file40file48file55file62file7file77file84file91file99
file12file2file27file34file41file49file56file63file70file78file85file92
file13file20file28file35file42file5file57file64file71file79file86file93
file14file21file29file36file43file50file58file65file72file8file87file94
file15file22file3file37file44file51file59file66file73file80file88file95
[root@localhostfile]#rm-rf*[root@localhostfile]#ls[root@localhostfile]#xfsrestore-f/backup/file.bak/filexfsrestore:usingfiledump(drive_simple)strategy
xfsrestore:version3.1.4(dumpformat3.0)-type^Cforstatusandcontrol
xfsrestore:searchingmediafordump
xfsrestore:examiningmediafile0
xfsrestore:dumpdescription:
xfsrestore:hostname:localhost.localdomain
xfsrestore:mountpoint:/file
xfsrestore:volume:/dev/sdb1
xfsrestore:sessiontime:ThuOct3122:16:022019
xfsrestore:level:0
xfsrestore:sessionlabel:"file.bak"xfsrestore:medialabel:"file"xfsrestore:filesystemid:61a5e59d-92d3-458d-ac09-7d945469cda6
xfsrestore:sessionid:02a1445f-5ff3-4518-ab2c-888d9e2a4c44
xfsrestore:mediaid:2d1d9f33-dff3-4cfa-a2f6-bf65bd8f242b
xfsrestore:usingonlinesessioninventory
xfsrestore:searchingmediafordirectorydump
xfsrestore:readingdirectories
xfsrestore:1directoriesand100entriesprocessed
xfsrestore:directorypost-processing
xfsrestore:restoringnon-directoryfiles
xfsrestore:restorecomplete:0secondselapsed
xfsrestore:RestoreSummary:
xfsrestore:stream0/backup/file.bakOK(success)
xfsrestore:RestoreStatus:SUCCESS
[root@localhostfile]#ls#已經成功恢復被刪除的文件file1file16file23file30file38file45file52file6file67file74file81file89file96
file10file17file24file31file39file46file53file60file68file75file82file9file97
file100file18file25file32file4file47file54file61file69file76file83file90file98
file11file19file26file33file40file48file55file62file7file77file84file91file99
file12file2file27file34file41file49file56file63file70file78file85file92
file13file20file28file35file42file5file57file64file71file79file86file93
file14file21file29file36file43file50file58file65file72file8file87file94
file15file22file3file37file44file51file59file66file73file80file88file95

二、XFS文件系統的檢查和修復

創建XFS測試分區

[root@localhostfile]#fdisk/dev/sdbWelcometofdisk(util-linux2.23.2).

Changeswillremaininmemoryonly,untilyoudecidetowritethem.
Becarefulbeforeusingthewritecommand.


Command(mforhelp):p

Disk/dev/sdb:21.5GB,21474836480bytes,41943040sectors
Units=sectorsof1*512=512bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Disklabeltype:dos
Diskidentifier:0x08a5199d

DeviceBootStartEndBlocksIdSystem
/dev/sdb120482099199104857683Linux

Command(mforhelp):n
Partitiontype:
pprimary(1primary,0extended,3free)
eextended
Select(defaultp):p
Partitionnumber(2-4,default2):
Firstsector(2099200-41943039,default2099200):
Usingdefaultvalue2099200
Lastsector,+sectorsor+size{K,M,G}(2099200-41943039,default41943039):+1G
Partition2oftypeLinuxandofsize1GiBissetCommand(mforhelp):p

Disk/dev/sdb:21.5GB,21474836480bytes,41943040sectors
Units=sectorsof1*512=512bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Disklabeltype:dos
Diskidentifier:0x08a5199d

DeviceBootStartEndBlocksIdSystem
/dev/sdb120482099199104857683Linux
/dev/sdb220992004196351104857683Linux

Command(mforhelp):w
Thepartitiontablehasbeenaltered!

Callingioctl()tore-readpartitiontable.

WARNING:Re-readingthepartitiontablefailedwitherror16:Deviceorresourcebusy.
Thekernelstillusestheoldtable.Thenewtablewillbeusedat
thenextrebootorafteryourunpartprobe(8)orkpartx(8)
Syncingdisks.
[root@localhostfile]#partprobeWarning:Unabletoopen/dev/sr0read-write(Read-onlyfilesystem)./dev/sr0hasbeenopenedread-only.
[root@localhostfile]#ls/dev/sd*/dev/sda/dev/sda1/dev/sda2/dev/sdb/dev/sdb1/dev/sdb2
[root@localhostfile]#mkfs.xfs/dev/sdb2meta-data=/dev/sdb2isize=512agcount=4,agsize=65536blks
=sectsz=512attr=2,projid32bit=1
=crc=1finobt=0,sparse=0
data=bsize=4096blocks=262144,imaxpct=25
=sunit=0swidth=0blks
naming=version2bsize=4096ascii-ci=0ftype=1log=internallogbsize=4096blocks=2560,version=2
=sectsz=512sunit=0blks,lazy-count=1
realtime=noneextsz=4096blocks=0,rtextents=0

檢查XFS文件系統,如果檢查過程中發現問題將會列出

[root@localhostfile]#xfs_repair-n/dev/sdb2Phase1-findandverifysuperblock...
Phase2-usinginternallog-zerolog...
-scanfilesystemfreespaceandinodemaps...
-foundrootinodechunk
Phase3-foreachAG...
-scan(butdon'tclear)agiunlinkedlists...
-processknowninodesandperforminodediscovery...
-agno=0
-agno=1
-agno=2
-agno=3
-processnewlydiscoveredinodes...
Phase4-checkforduplicateblocks...
-settingupduplicateextentlist...
-checkforinodesclaimingduplicateblocks...
-agno=0
-agno=1
-agno=2
-agno=3
Nomodifyflagset,skippingphase5
Phase6-checkinodeconnectivity...
-traversingfilesystem...
-traversalfinished...
-movingdisconnectedinodestolost+found...
Phase7-verifylinkcounts...
Nomodifyflagset,skippingfilesystemflushandexiting.

自動檢查并修復XFS文件系統

[root@localhostfile]#xfs_repair/dev/sdb2Phase1-findandverifysuperblock...
Phase2-usinginternallog-zerolog...
-scanfilesystemfreespaceandinodemaps...
-foundrootinodechunk
Phase3-foreachAG...
-scanandclearagiunlinkedlists...
-processknowninodesandperforminodediscovery...
-agno=0
-agno=1
-agno=2
-agno=3
-processnewlydiscoveredinodes...
Phase4-checkforduplicateblocks...
-settingupduplicateextentlist...
-checkforinodesclaimingduplicateblocks...
-agno=0
-agno=1
-agno=2
-agno=3
Phase5-rebuildAGheadersandtrees...
-resetsuperblock...
Phase6-checkinodeconnectivity...
-resettingcontentsofrealtimebitmapandsummaryinodes
-traversingfilesystem...
-traversalfinished...
-movingdisconnectedinodestolost+found...
Phase7-verifyandcorrectlinkcounts...done

總結

以上是生活随笔為你收集整理的怎么对XFS进行备份、恢复、修复的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。