Linux教程之Centos体系中软阵列(raid)的完成
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!1.创立测试的用户和修正挂载的参数#useradduser1--新建两个用户
#useradduser2
#mount-oremount,usrquota,grpquota/mnt/sdb--从新挂载,加参数
#mount-l--检查挂载选项
/dev/mapper/VolGroup-lv_rooton/typeext4(rw)
procon/proctypeproc(rw)
sysfson/systypesysfs(rw)
devptson/dev/ptstypedevpts(rw,gid=5,mode=620)
tmpfson/dev/shmtypetmpfs(rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1on/boottypeext4(rw)
noneon/proc/sys/fs/binfmt_misctypebinfmt_misc(rw)
/dev/sdb1on/mnt/sdbtypeext4(rw,usrquota,grpquota)
#quotacheck-avug-mf--生成两个quota文件
quotacheck:Yourkernelprobablysupportsjournaledquotabutyouarenotusingit.Considerswitchingtojournaledquotatoavoidrunningquotacheckafteranuncleanshutdown.
quotacheck:Scanning/dev/sdb1done
quotacheck:Cannotstatolduserquotafile:Nosuchfileordirectory
quotacheck:Cannotstatoldgroupquotafile:Nosuchfileordirectory
quotacheck:Cannotstatolduserquotafile:Nosuchfileordirectory
quotacheck:Cannotstatoldgroupquotafile:Nosuchfileordirectory
quotacheck:Checked2directoriesand0files
quotacheck:Oldfilenotfound.
quotacheck:Oldfilenotfound.
#ll/mnt/sdb--检查生成的两个文件
total26
-rw-------.1rootroot6144Jan917:59aquota.group
-rw-------.1rootroot6144Jan917:59aquota.user
drwx------.2rootroot12288Jan917:55lost+found
#quotaon-avug--开启quota功效
/dev/sdb1:groupquotasturnedon
/dev/sdb1:userquotasturnedon
#edquota-uuser1
Diskquotasforuseruser1(uid500):
Filesystemblockssofthardinodessofthard
/dev/sdb101020000
#edquota-uuser2
Diskquotasforuseruser2(uid501):
Filesystemblockssofthardinodessofthard
/dev/sdb10510000
#useradduser1--新建两个用户
#useradduser2
#mount-oremount,usrquota,grpquota/mnt/sdb--从新挂载,加参数
#mount-l--检查挂载选项
/dev/mapper/VolGroup-lv_rooton/typeext4(rw)
procon/proctypeproc(rw)
sysfson/systypesysfs(rw)
devptson/dev/ptstypedevpts(rw,gid=5,mode=620)
tmpfson/dev/shmtypetmpfs(rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1on/boottypeext4(rw)
noneon/proc/sys/fs/binfmt_misctypebinfmt_misc(rw)
/dev/sdb1on/mnt/sdbtypeext4(rw,usrquota,grpquota)
#quotacheck-avug-mf--生成两个quota文件
quotacheck:Yourkernelprobablysupportsjournaledquotabutyouarenotusingit.Considerswitchingtojournaledquotatoavoidrunningquotacheckafteranuncleanshutdown.
quotacheck:Scanning/dev/sdb1done
quotacheck:Cannotstatolduserquotafile:Nosuchfileordirectory
quotacheck:Cannotstatoldgroupquotafile:Nosuchfileordirectory
quotacheck:Cannotstatolduserquotafile:Nosuchfileordirectory
quotacheck:Cannotstatoldgroupquotafile:Nosuchfileordirectory
quotacheck:Checked2directoriesand0files
quotacheck:Oldfilenotfound.
quotacheck:Oldfilenotfound.
#ll/mnt/sdb--检查生成的两个文件
total26
-rw-------.1rootroot6144Jan917:59aquota.group
-rw-------.1rootroot6144Jan917:59aquota.user
drwx------.2rootroot12288Jan917:55lost+found
#quotaon-avug--开启quota功效
/dev/sdb1:groupquotasturnedon
/dev/sdb1:userquotasturnedon
#edquota-uuser1--用户user1应用/mnt/sdb目次不要起过20M
Diskquotasforuseruser1(uid500):
Filesystemblockssofthardinodessofthard
/dev/sdb101000020000000
#edquota-uuser2--用户user2对sdb目次不要跨越10M,年夜于5M超越指准时间删除
Diskquotasforuseruser2(uid501):
Filesystemblockssofthardinodessofthard
/dev/sdb10500010000000
2.验证配额
#su-user1
$cd/mnt/sdb
$ddif=/dev/zeroof=12bs=1Mcount=5--创立5M的文件没有正告信息,正常
5+0recordsin
5+0recordsout
5242880bytes(5.2MB)copied,0.0525754s,99.7MB/s
$ll-h12
-rw-rw-r--.1user1user15.0MJan918:1612
$ddif=/dev/zeroof=123bs=1Mcount=21--创立12M的文件有正告信息,表现掉败
sdb1:warning,userblockquotaexceeded.
sdb1:writefailed,userblocklimitreached.
dd:writing`123:Diskquotaexceeded
20+0recordsin
19+0recordsout
20475904bytes(20MB)copied,0.20094s,102MB/s
$ll-h123
-rw-rw-r--.1user1user10Jan918:17123
$exit
logout
#su-user2--用户user2测试
$cd/mnt/sdb
$ddif=/dev/zeroof=23bs=1Mcount=8--写入8M文件胜利
sdb1:warning,userblockquotaexceeded.
8+0recordsin
8+0recordsout
8388608bytes(8.4MB)copied,0.0923618s,90.8MB/s
$ll-h23--检查文件巨细
-rw-rw-r--.1user2user28.0MJan918:2323
$
$ddif=/dev/zeroof=23bs=1Mcount=11--写入11M文件掉败
sdb1:warning,userblockquotaexceeded.
sdb1:writefailed,userblocklimitreached.
dd:writing`23:Diskquotaexceeded
10+0recordsin
9+0recordsout
10235904bytes(10MB)copied,0.106298s,96.3MB/s
$
3.检查quota设置装备摆设,修正正告时光,撤消quota
#quota-vuuser1user2--查找指定的用户quota信息
Diskquotasforuseruser1(uid500):
Filesystemblocksquotalimitgracefilesquotalimitgrace
/dev/sdb101000020000000
Diskquotasforuseruser2(uid501):
Filesystemblocksquotalimitgracefilesquotalimitgrace
/dev/sdb18193*5000100006days100
#repquota-av--一切用户和quota信息
***Reportforuserquotasondevice/dev/sdb1
Blockgracetime:7days;Inodegracetime:7days
BlocklimitsFilelimits
Userusedsofthardgraceusedsofthardgrace
----------------------------------------------------------------------
root--1300200
user1--01000020000000
user2+-81935000100006days100
Statistics:
Totalblocks:7
Datablocks:1
Entries:3
Usedaverage:3.000000
#edquota-t--修正文件正告天数(Block天数Inode天数)
Graceperiodbeforeenforcingsoftlimitsforusers:
Timeunitsmaybe:days,hours,minutes,orseconds
FilesystemBlockgraceperiodInodegraceperiod
/dev/sdb17days7days
#vim/etc/warnquota.conf--检查正告信息
#quotaoff/mnt/sdb--封闭quota功效
4.磁盘分区,转换磁盘的格局做软阵列
#sfdisk-l--检查体系有若干块硬盘
Disk/dev/sda:1044cylinders,255heads,63sectors/track
Units=cylindersof8225280bytes,blocksof1024bytes,countingfrom0
DeviceBootStartEnd#cyls#blocksIdSystem
/dev/sda1*0+63-64-51200083Linux
/dev/sda263+1044-981-78755848eLinuxLVM
/dev/sda30-000Empty
/dev/sda40-000Empty
Disk/dev/sdb:74cylinders,255heads,63sectors/track--第二块硬盘
Disk/dev/sdc:79cylinders,255heads,63sectors/track--第三块硬盘
Disk/dev/sdd:74cylinders,255heads,63sectors/track--第四块硬盘
Disk/dev/mapper/VolGroup-lv_root:849cylinders,255heads,63sectors/track
Disk/dev/mapper/VolGroup-lv_swap:130cylinders,255heads,63sectors/track
#fdisk-cu/dev/sdb--分区交转换分区格局(以下分区全体这么做,这里我就不显示了)
DevicecontainsneitheravalidDOSpartitiontable,norSun,SGIorOSFdisklabel
BuildinganewDOSdisklabelwithdiskidentifier0x2255ec93.
Changeswillremaininmemoryonly,untilyoudecidetowritethem.
Afterthat,ofcourse,thepreviouscontentwontberecoverable.
Warning:invalidflag0x0000ofpartitiontable4willbecorrectedbyw(rite)
Command(mforhelp):n
Commandaction
eextended
pprimarypartition(1-4)
p
Partitionnumber(1-4):1
Firstsector(2048-1196031,default2048):
Usingdefaultvalue2048
Lastsector,+sectorsor+size{K,M,G}(2048-1196031,default1196031):+100M
Command(mforhelp):n
Commandaction
eextended
pprimarypartition(1-4)
p
Partitionnumber(1-4):2
Firstsector(206848-1196031,default206848):
Usingdefaultvalue206848
Lastsector,+sectorsor+size{K,M,G}(206848-1196031,default1196031):+100M
Command(mforhelp):n
Commandaction
eextended
pprimarypartition(1-4)
p
Partitionnumber(1-4):3
Firstsector(411648-1196031,default411648):
Usingdefaultvalue411648
Lastsector,+sectorsor+size{K,M,G}(411648-1196031,default1196031):+100M
Command(mforhelp):t
Partitionnumber(1-4):1
Hexcode(typeLtolistcodes):fd
Changedsystemtypeofpartition1tofd(Linuxraidautodetect)
Command(mforhelp):t
Partitionnumber(1-4):2
Hexcode(typeLtolistcodes):fd
Changedsystemtypeofpartition2tofd(Linuxraidautodetect)
Command(mforhelp):t
Partitionnumber(1-4):1
Hexcode(typeLtolistcodes):fd
Changedsystemtypeofpartition1tofd(Linuxraidautodetect)
Command(mforhelp):p
Disk/dev/sdb:612MB,612368384bytes
255heads,63sectors/track,74cylinders,total1196032sectors
Units=sectorsof1*512=512bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Diskidentifier:0x2255ec93
DeviceBootStartEndBlocksIdSystem
/dev/sdb12048206847102400fdLinuxraidautodetect
/dev/sdb2206848411647102400fdLinuxraidautodetect
/dev/sdd3411648616447102400fdLinuxraidautodetect
Command(mforhelp):w
Thepartitiontablehasbeenaltered!
Callingioctl()tore-readpartitiontable.
Syncingdisks.
#partx-a/dev/sdb--强迫读取分区表
BLKPG:Deviceorresourcebusy
erroraddingpartition1
BLKPG:Deviceorresourcebusy
erroraddingpartition2
BLKPG:Deviceorresourcebusy
erroraddingpartition3
#partx-a/dev/sdc--强迫读取分区表
BLKPG:Deviceorresourcebusy
erroraddingpartition1
BLKPG:Deviceorresourcebusy
erroraddingpartition2
BLKPG:Deviceorresourcebusy
erroraddingpartition3
#partx-a/dev/sdd--强迫读取分区表
BLKPG:Deviceorresourcebusy
erroraddingpartition1
BLKPG:Deviceorresourcebusy
erroraddingpartition2
BLKPG:Deviceorresourcebusy
erroraddingpartition3
5.将第二,三块硬盘的第一个分区做成raid0
#mdadm--create/dev/md0--raid-devices=2--level=0/dev/sd{b,c}1--第二,三块硬盘第一分区做raid0
mdadm:Defaultingtoversion1.2metadata
mdadm:array/dev/md0started.
#cat/proc/mdstat--检查raid信息
Personalities:
md0:activeraid0sdc1sdb1
224256blockssuper1.2512kchunks
unuseddevices:<none>
#mkfs.ext4/dev/md0--格局化
mke2fs1.41.12(17-May-2010)
Filesystemlabel=
OStype:Linux
Blocksize=1024(log=0)
Fragmentsize=1024(log=0)
Stride=512blocks,Stripewidth=1024blocks
56224inodes,224256blocks
11212blocks(5.00%)reservedforthesuperuser
Firstdatablock=1
Maximumfilesystemblocks=67371008
28blockgroups
8192blockspergroup,8192fragmentspergroup
2008inodespergroup
Superblockbackupsstoredonblocks:
8193,24577,40961,57345,73729,204801,221185
Writinginodetables:done
Creatingjournal(4096blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done
Thisfilesystemwillbeautomaticallycheckedevery38mountsor
180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
#mount/dev/md0/mnt/sdb
#
6.将第二,三块硬盘的第二个分区做raid1
#mdadm--create/dev/md1--raid-devices=2--level=1/dev/sd{b,c}2
mdadm:Note:thisarrayhasmetadataatthestartand
maynotbesuitableasabootdevice.Ifyouplanto
store/bootonthisdevicepleaseensurethat
yourboot-loaderunderstandsmd/v1.xmetadata,oruse
--metadata=0.90
Continuecreatingarray?
Continuecreatingarray?(y/n)y
mdadm:Defaultingtoversion1.2metadata
mdadm:array/dev/md1started.
#mkfs.ext4/dev/md1
mke2fs1.41.12(17-May-2010)
Filesystemlabel=
OStype:Linux
Blocksize=1024(log=0)
Fragmentsize=1024(log=0)
Stride=0blocks,Stripewidth=0blocks
28112inodes,112320blocks
5616blocks(5.00%)reservedforthesuperuser
Firstdatablock=1
Maximumfilesystemblocks=67371008
14blockgroups
8192blockspergroup,8192fragmentspergroup
2008inodespergroup
Superblockbackupsstoredonblocks:
8193,24577,40961,57345,73729
Writinginodetables:done
Creatingjournal(4096blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done
Thisfilesystemwillbeautomaticallycheckedevery35mountsor
180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
#mount/dev/md1/mnt/sdb1/
7.将第二,三,四块硬盘的第三个分区做成raid5
#mdadm--create/dev/md2--raid-devices=3--level=5/dev/sd{b,c,d}3
mdadm:Defaultingtoversion1.2metadata
mdadm:array/dev/md2started.
#mkfs.ext4/dev/md2
mke2fs1.41.12(17-May-2010)
Filesystemlabel=
OStype:Linux
Blocksize=1024(log=0)
Fragmentsize=1024(log=0)
Stride=512blocks,Stripewidth=1024blocks
56224inodes,224256blocks
11212blocks(5.00%)reservedforthesuperuser
Firstdatablock=1
Maximumfilesystemblocks=67371008
28blockgroups
8192blockspergroup,8192fragmentspergroup
2008inodespergroup
Superblockbackupsstoredonblocks:
8193,24577,40961,57345,73729,204801,221185
Writinginodetables:done
Creatingjournal(4096blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done
Thisfilesystemwillbeautomaticallycheckedevery35mountsor
180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
#mount/dev/md2/mnt/sdb2/
8.检查raid信息
#cat/proc/mdstat
Personalities:
md2:activeraid5sdd3sdc3sdb3
224256blockssuper1.2level5,512kchunk,algorithm2
md1:activeraid1sdc2sdb2
112320blockssuper1.2
md0:activeraid0sdc1sdb1
224256blockssuper1.2512kchunks
unuseddevices:<none>
#df-TH
FilesystemTypeSizeUsedAvailUse%Mountedon
/dev/mapper/VolGroup-lv_root
ext46.9G6.4G166M98%/
tmpfstmpfs262M0262M0%/dev/shm
/dev/sda1ext4508M48M435M10%/boot
/dev/md0ext4223M6.4M205M3%/mnt/sdb
/dev/md1ext4112M5.8M100M6%/mnt/sdb1
/dev/md2ext4223M6.4M205M3%/mnt/sdb2
#
9.raid毛病恢复和用raid应用逻辑卷(lvm)
#mdadm-a/dev/md2/dev/sdd1--在raid5中添加一块分区
mdadm:added/dev/sdd1
#mdadm-f/dev/md2/dev/sdd3--将raid5中的第三个分区变成生效
mdadm:set/dev/sdd3faultyin/dev/md2
#mdadm-r/dev/md2/dev/sdd3--移除raid5中的第三个分区
mdadm:hotremoved/dev/sdd3from/dev/md2
#cat/proc/mdstat
Personalities:
md2:activeraid5sdd1sdc3sdb3--检查raid5中的一切分区
224256blockssuper1.2level5,512kchunk,algorithm2
md1:activeraid1sdc2sdb2
112320blockssuper1.2
md0:activeraid0sdc1sdb1
224256blockssuper1.2512kchunks
unuseddevices:<none>
#pvcreate/dev/md2--将raid5转换成物理卷
Physicalvolume"/dev/md2"successfullycreated
#vgcreatevg0/dev/md2--物理卷构成卷组
Volumegroup"vg0"successfullycreated
#lvcreate-L150M-ntest/dev/vg0--从卷组中划分逻辑卷
Roundingupsizetofullphysicalextent152.00MiB
Logicalvolume"test"created
#mkfs.ext4/dev/vg0/test--格局化逻辑卷
mke2fs1.41.12(17-May-2010)
Filesystemlabel=
OStype:Linux
Blocksize=1024(log=0)
Fragmentsize=1024(log=0)
Stride=512blocks,Stripewidth=1024blocks
38912inodes,155648blocks
7782blocks(5.00%)reservedforthesuperuser
Firstdatablock=1
Maximumfilesystemblocks=67371008
19blockgroups
8192blockspergroup,8192fragmentspergroup
2048inodespergroup
Superblockbackupsstoredonblocks:
8193,24577,40961,57345,73729
Writinginodetables:done
Creatingjournal(4096blocks):done
Writingsuperblocksandfilesystemaccountinginformation:done
Thisfilesystemwillbeautomaticallycheckedevery36mountsor
180days,whichevercomesfirst.Usetune2fs-cor-itooverride.
#mount/dev/vg0/test/mnt/sdb2/--挂载
#df-TH
FilesystemTypeSizeUsedAvailUse%Mountedon
/dev/mapper/VolGroup-lv_root
ext46.9G6.4G166M98%/
tmpfstmpfs262M0262M0%/dev/shm
/dev/sda1ext4508M48M435M10%/boot
/dev/md0ext4223M6.4M205M3%/mnt/sdb
/dev/md1ext4112M5.8M100M6%/mnt/sdb1
/dev/mapper/vg0-test
ext4155M5.8M141M4%/mnt/sdb2
#
linux体系中对逻辑卷(lvm)的完成:http://tongcheng.blog.51cto.com/6214144/1350144
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!
Linux教程之Centos体系中软阵列(raid)的完成
放手去搞。尽量不要提问,运用搜索找答案,或者看wiki,从原理上理解操作系统的本质,而不是满足于使用几个技巧。尽量看英文资料。 选择一些适于初学者的Linux社区。 在学习linux的工程中,linux学习方法有很多种,这里是小编的学习心得,给大家拿出来分享一下。 如果你想深入学习Linux,看不懂因为文档实在是太难了。写的最好的、最全面的文档都是英语写的,最先发布的技术信息也都是用英语写的。 为了更好的学习这门课程,我不仅课上认真听讲,课下也努力学习,为此还在自己的电脑上安装了Ubuntu系统。 通过自学老师给的资料和向同学请教,掌握了一些基本的操作,比如挂载优盘,编译程序,在Linux环境下运行,转换目录等等。学了这些基础才能进行下面的模拟OS程序。? 学习Linux应具备的。[书籍+网络资源] 对我们学习操作系统有很大的帮助,加深我们对OS的理解。?
页:
[1]