仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 440|回复: 8
打印 上一主题 下一主题

[CentOS(社区)] Linux教程之Centos体系中软阵列(raid)的完成

[复制链接]
逍遥一派 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-14 20:48:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!1.创立测试的用户和修正挂载的参数

[root@localhost~]#useradduser1--新建两个用户
[root@localhost~]#useradduser2
[root@localhost~]#mount-oremount,usrquota,grpquota/mnt/sdb--从新挂载,加参数
[root@localhost~]#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)
[root@localhost~]#quotacheck-avug-mf--生成两个quota文件
quotacheck:Yourkernelprobablysupportsjournaledquotabutyouarenotusingit.Considerswitchingtojournaledquotatoavoidrunningquotacheckafteranuncleanshutdown.
quotacheck:Scanning/dev/sdb1[/mnt/sdb]done
quotacheck:Cannotstatolduserquotafile:Nosuchfileordirectory
quotacheck:Cannotstatoldgroupquotafile:Nosuchfileordirectory
quotacheck:Cannotstatolduserquotafile:Nosuchfileordirectory
quotacheck:Cannotstatoldgroupquotafile:Nosuchfileordirectory
quotacheck:Checked2directoriesand0files
quotacheck:Oldfilenotfound.
quotacheck:Oldfilenotfound.
[root@localhost~]#ll/mnt/sdb--检查生成的两个文件
total26
-rw-------.1rootroot6144Jan917:59aquota.group
-rw-------.1rootroot6144Jan917:59aquota.user
drwx------.2rootroot12288Jan917:55lost+found
[root@localhost~]#quotaon-avug--开启quota功效
/dev/sdb1[/mnt/sdb]:groupquotasturnedon
/dev/sdb1[/mnt/sdb]:userquotasturnedon
[root@localhost~]#edquota-uuser1
Diskquotasforuseruser1(uid500):
Filesystemblockssofthardinodessofthard
/dev/sdb101020000
[root@localhost~]#edquota-uuser2
Diskquotasforuseruser2(uid501):
Filesystemblockssofthardinodessofthard
/dev/sdb10510000




[root@localhost~]#useradduser1--新建两个用户
[root@localhost~]#useradduser2
[root@localhost~]#mount-oremount,usrquota,grpquota/mnt/sdb--从新挂载,加参数
[root@localhost~]#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)
[root@localhost~]#quotacheck-avug-mf--生成两个quota文件
quotacheck:Yourkernelprobablysupportsjournaledquotabutyouarenotusingit.Considerswitchingtojournaledquotatoavoidrunningquotacheckafteranuncleanshutdown.
quotacheck:Scanning/dev/sdb1[/mnt/sdb]done
quotacheck:Cannotstatolduserquotafile:Nosuchfileordirectory
quotacheck:Cannotstatoldgroupquotafile:Nosuchfileordirectory
quotacheck:Cannotstatolduserquotafile:Nosuchfileordirectory
quotacheck:Cannotstatoldgroupquotafile:Nosuchfileordirectory
quotacheck:Checked2directoriesand0files
quotacheck:Oldfilenotfound.
quotacheck:Oldfilenotfound.
[root@localhost~]#ll/mnt/sdb--检查生成的两个文件
total26
-rw-------.1rootroot6144Jan917:59aquota.group
-rw-------.1rootroot6144Jan917:59aquota.user
drwx------.2rootroot12288Jan917:55lost+found
[root@localhost~]#quotaon-avug--开启quota功效
/dev/sdb1[/mnt/sdb]:groupquotasturnedon
/dev/sdb1[/mnt/sdb]:userquotasturnedon
[root@localhost~]#edquota-uuser1--用户user1应用/mnt/sdb目次不要起过20M
Diskquotasforuseruser1(uid500):
Filesystemblockssofthardinodessofthard
/dev/sdb101000020000000
[root@localhost~]#edquota-uuser2--用户user2对sdb目次不要跨越10M,年夜于5M超越指准时间删除
Diskquotasforuseruser2(uid501):
Filesystemblockssofthardinodessofthard
/dev/sdb10500010000000



2.验证配额

[root@localhost~]#su-user1
[user1@localhost~]$cd/mnt/sdb
[user1@localhostsdb]$ddif=/dev/zeroof=12bs=1Mcount=5--创立5M的文件没有正告信息,正常
5+0recordsin
5+0recordsout
5242880bytes(5.2MB)copied,0.0525754s,99.7MB/s
[user1@localhostsdb]$ll-h12
-rw-rw-r--.1user1user15.0MJan918:1612
[user1@localhostsdb]$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
[user1@localhostsdb]$ll-h123
-rw-rw-r--.1user1user10Jan918:17123
[user1@localhostsdb]$exit
logout
[root@localhost~]#su-user2--用户user2测试
[user2@localhost~]$cd/mnt/sdb
[user2@localhostsdb]$ddif=/dev/zeroof=23bs=1Mcount=8--写入8M文件胜利
sdb1:warning,userblockquotaexceeded.
8+0recordsin
8+0recordsout
8388608bytes(8.4MB)copied,0.0923618s,90.8MB/s
[user2@localhostsdb]$ll-h23--检查文件巨细
-rw-rw-r--.1user2user28.0MJan918:2323
[user2@localhostsdb]$
[user2@localhostsdb]$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
[user2@localhostsdb]$



3.检查quota设置装备摆设,修正正告时光,撤消quota

[root@localhost~]#quota-vuuser1user2--查找指定的用户quota信息
Diskquotasforuseruser1(uid500):
Filesystemblocksquotalimitgracefilesquotalimitgrace
/dev/sdb101000020000000
Diskquotasforuseruser2(uid501):
Filesystemblocksquotalimitgracefilesquotalimitgrace
/dev/sdb18193*5000100006days100
[root@localhost~]#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
[root@localhost~]#edquota-t--修正文件正告天数(Block天数Inode天数)
Graceperiodbeforeenforcingsoftlimitsforusers:
Timeunitsmaybe:days,hours,minutes,orseconds
FilesystemBlockgraceperiodInodegraceperiod
/dev/sdb17days7days
[root@localhost~]#vim/etc/warnquota.conf--检查正告信息
[root@localhost~]#quotaoff/mnt/sdb--封闭quota功效



4.磁盘分区,转换磁盘的格局做软阵列

[root@localhost~]#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
[root@localhost~]#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.
[root@localhost~]#partx-a/dev/sdb--强迫读取分区表
BLKPG:Deviceorresourcebusy
erroraddingpartition1
BLKPG:Deviceorresourcebusy
erroraddingpartition2
BLKPG:Deviceorresourcebusy
erroraddingpartition3
[root@localhost~]#partx-a/dev/sdc--强迫读取分区表
BLKPG:Deviceorresourcebusy
erroraddingpartition1
BLKPG:Deviceorresourcebusy
erroraddingpartition2
BLKPG:Deviceorresourcebusy
erroraddingpartition3
[root@localhost~]#partx-a/dev/sdd--强迫读取分区表
BLKPG:Deviceorresourcebusy
erroraddingpartition1
BLKPG:Deviceorresourcebusy
erroraddingpartition2
BLKPG:Deviceorresourcebusy
erroraddingpartition3



5.将第二,三块硬盘的第一个分区做成raid0

[root@localhost~]#mdadm--create/dev/md0--raid-devices=2--level=0/dev/sd{b,c}1--第二,三块硬盘第一分区做raid0
mdadm:Defaultingtoversion1.2metadata
mdadm:array/dev/md0started.
[root@localhost~]#cat/proc/mdstat--检查raid信息
Personalities:[raid0]
md0:activeraid0sdc1[1]sdb1[0]
224256blockssuper1.2512kchunks
unuseddevices:<none>
[root@localhost~]#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.
[root@localhost~]#mount/dev/md0/mnt/sdb
[root@localhost~]#



6.将第二,三块硬盘的第二个分区做raid1

[root@localhost~]#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.
[root@localhost~]#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.
[root@localhost~]#mount/dev/md1/mnt/sdb1/



7.将第二,三,四块硬盘的第三个分区做成raid5

[root@localhost~]#mdadm--create/dev/md2--raid-devices=3--level=5/dev/sd{b,c,d}3
mdadm:Defaultingtoversion1.2metadata
mdadm:array/dev/md2started.
[root@localhost~]#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.
[root@localhost~]#mount/dev/md2/mnt/sdb2/



8.检查raid信息

[root@localhost~]#cat/proc/mdstat
Personalities:[raid0][raid1][raid6][raid5][raid4]
md2:activeraid5sdd3[3]sdc3[1]sdb3[0]
224256blockssuper1.2level5,512kchunk,algorithm2[3/3][UUU]
md1:activeraid1sdc2[1]sdb2[0]
112320blockssuper1.2[2/2][UU]
md0:activeraid0sdc1[1]sdb1[0]
224256blockssuper1.2512kchunks
unuseddevices:<none>
[root@localhost~]#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
[root@localhost~]#



9.raid毛病恢复和用raid应用逻辑卷(lvm)

[root@localhost~]#mdadm-a/dev/md2/dev/sdd1--在raid5中添加一块分区
mdadm:added/dev/sdd1
[root@localhost~]#mdadm-f/dev/md2/dev/sdd3--将raid5中的第三个分区变成生效
mdadm:set/dev/sdd3faultyin/dev/md2
[root@localhost~]#mdadm-r/dev/md2/dev/sdd3--移除raid5中的第三个分区
mdadm:hotremoved/dev/sdd3from/dev/md2
[root@localhost~]#cat/proc/mdstat
Personalities:[raid0][raid1][raid6][raid5][raid4]
md2:activeraid5sdd1[4]sdc3[1]sdb3[0]--检查raid5中的一切分区
224256blockssuper1.2level5,512kchunk,algorithm2[3/3][UUU]
md1:activeraid1sdc2[1]sdb2[0]
112320blockssuper1.2[2/2][UU]
md0:activeraid0sdc1[1]sdb1[0]
224256blockssuper1.2512kchunks
unuseddevices:<none>
[root@localhost~]#pvcreate/dev/md2--将raid5转换成物理卷
Physicalvolume"/dev/md2"successfullycreated
[root@localhost~]#vgcreatevg0/dev/md2--物理卷构成卷组
Volumegroup"vg0"successfullycreated
[root@localhost~]#lvcreate-L150M-ntest/dev/vg0--从卷组中划分逻辑卷
Roundingupsizetofullphysicalextent152.00MiB
Logicalvolume"test"created
[root@localhost~]#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.
[root@localhost~]#mount/dev/vg0/test/mnt/sdb2/--挂载
[root@localhost~]#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
[root@localhost~]#





linux体系中对逻辑卷(lvm)的完成:http://tongcheng.blog.51cto.com/6214144/1350144
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!
小魔女 该用户已被删除
沙发
发表于 2015-1-16 23:10:22 | 只看该作者

Linux教程之Centos体系中软阵列(raid)的完成

放手去搞。尽量不要提问,运用搜索找答案,或者看wiki,从原理上理解操作系统的本质,而不是满足于使用几个技巧。尽量看英文资料。
小妖女 该用户已被删除
板凳
发表于 2015-1-26 07:41:42 | 只看该作者
选择一些适于初学者的Linux社区。
柔情似水 该用户已被删除
地板
发表于 2015-2-4 20:31:21 | 只看该作者
在学习linux的工程中,linux学习方法有很多种,这里是小编的学习心得,给大家拿出来分享一下。
精灵巫婆 该用户已被删除
5#
发表于 2015-2-10 08:39:00 | 只看该作者
如果你想深入学习Linux,看不懂因为文档实在是太难了。写的最好的、最全面的文档都是英语写的,最先发布的技术信息也都是用英语写的。
乐观 该用户已被删除
6#
发表于 2015-3-1 10:11:07 | 只看该作者
为了更好的学习这门课程,我不仅课上认真听讲,课下也努力学习,为此还在自己的电脑上安装了Ubuntu系统。
爱飞 该用户已被删除
7#
发表于 2015-3-10 18:51:20 | 只看该作者
通过自学老师给的资料和向同学请教,掌握了一些基本的操作,比如挂载优盘,编译程序,在Linux环境下运行,转换目录等等。学了这些基础才能进行下面的模拟OS程序。?
飘灵儿 该用户已被删除
8#
发表于 2015-3-17 12:26:52 | 只看该作者
学习Linux应具备的。[书籍+网络资源]
因胸联盟 该用户已被删除
9#
发表于 2015-3-24 16:21:42 | 只看该作者
对我们学习操作系统有很大的帮助,加深我们对OS的理解。?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-6-17 06:51

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表