RAID的创建
第一步:先查看我们系统的磁盘情况
[root@station40 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
└─sda3 8:3 0 17.8G 0 part /
sdb 8:16 0 200G 0 disk
├─sdb1 8:17 0 1G 0 part
├─sdb2 8:18 0 1G 0 part
├─sdb3 8:19 0 1G 0 part
├─sdb4 8:20 0 1K 0 part
├─sdb5 8:21 0 1G 0 part
└─sdb6 8:22 0 1G 0 part
sdc 8:32 0 100G 0 disk
sr0 11:0 1 3.7G 0 rom
第二步:删掉一些不用的磁盘
[root@station40 ~]# dd if=/dev/zero of=/dev/sdb bs=1 count=512
512+0 records in
512+0 records out
512 bytes (512 B) copied, 0.376112 s, 1.4 kB/s
第三步:同步一下内存信息
[root@station40 ~]# partx -d --nr 1-6 /dev/sdb
[root@station40 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
└─sda3 8:3 0 17.8G 0 part /
sdb 8:16 0 200G 0 disk
sdc 8:32 0 100G 0 disk
sr0 11:0 1 3.7G 0 rom
第四步:现在我们创建一个RAID-0
A:创建分区(最少三个)
[root@station40 ~]# fdisk /dev/sdb
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x4a846ad4.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-26108, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-26108, default 26108): +2G
Command (m for help): P
Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4a846ad4
Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FS data
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto (raid标签,也可以不选则,但是不方便后期查找)
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
创建的过程中,需要特别注意的是选择磁盘的RAID的型号这个动作一定要记得
b:创建一块RAID磁盘后可以检查;
[root@station40 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
└─sda3 8:3 0 17.8G 0 part /
sdb 8:16 0 200G 0 disk
└─sdb1 8:17 0 2G 0 part
sdc 8:32 0 100G 0 disk
sr0 11:0 1 3.7G 0 rom
c:相同的步骤可以继续分出3个相同的分区
[root@station40 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
└─sda3 8:3 0 17.8G 0 part /
sdb 8:16 0 200G 0 disk
├─sdb1 8:17 0 2G 0 part
├─sdb2 8:18 0 2G 0 part
├─sdb3 8:19 0 2G 0 part
├─sdb4 8:20 0 1K 0 part
└─sdb5 8:21 0 2G 0 part
sdc 8:32 0 100G 0 disk
sr0 11:0 1 3.7G 0 rom
d:分区OK后我们现在需要确认一下系统中是否有RAID磁盘
例:[root@station40 ~]# ll /dev/md*
ls: cannot access /dev/md*: No such file or directory
e:我们先分一个RIAD-0阵列
[root@station40 ~]# mdadm -C /dev/md0 -a yes -l 0 -n 2 /dev/sdb1 /dev/sdb2
mdadm: /dev/sdb1 appears to contain an ext2fs file system 提醒的错误显示之前sdb这个磁盘有以前实验ext2格式,不用在意直接y选项
size=1060256K mtime=Thu Jan 1 08:00:00 1970
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
现在可以查看一下创建的过程
[root@station40 ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Mon Apr 24 10:09:02 2017
Raid Level : raid0 (RAID级别)
Array Size : 4204544 (4.01 GiB 4.31 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Mon Apr 24 10:09:02 2017
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Chunk Size : 512K (默认大小)
Name : station40.magelinux.com:0 (local to host station40.magelinux.com)
UUID : b08b2229:03516277:61d40ba7:0c5be81b (此处的UUID和之前的分区的UUID不是一样)
Events : 0
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1 (两个设备组成)
1 8 18 1 active sync /dev/sdb2
f:下面我们将它格式化(需要注意的是我们格式化是放在创建RAID之后进行统一格式化处理)
[root@station40 ~]# mkfs.ext4 /dev/md0
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=128 blocks, Stripe width=256 blocks
262944 inodes, 1051136 blocks
52556 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1077936128
33 block groups
32768 blocks per group, 32768 fragments per group
7968 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override
接着查看磁盘情况:
root@station40 ~]# blkid
/dev/sda3: UUID="953e4427-c667-41a4-9bee-b8c4ab55ce42" TYPE="ext4"
/dev/sda1: UUID="18e40da7-01ac-483c-a427-566276b7fbcd" TYPE="ext4"
/dev/sda2: UUID="af50c30e-5861-4125-ad83-bc74b88b2c6a" TYPE="swap"
/dev/sdb1: UUID="88cadd96-353c-4b02-bf7b-3c4eea28adc1" TYPE="ext4"
/dev/sdb2: UUID="b08b2229-0351-6277-61d4-0ba70c5be81b" UUID_SUB="a6244ed9-665b-2474-a3ea-60bf2458bd8b" LABEL="station40.magelinux.com:0" TYPE="linux_raid_member"
/dev/md0: UUID="dabc8242-0315-4987-9ec6-7e5b652ec77d" TYPE="ext4"
g:格式化之后我们就可以进行挂载了;
[root@station40 ~]# mkdir -p /mut/raid0
[root@station40 ~]# mount /dev/md0 /mut/raid0/
h:现在可以测试一下写性能:
root@station40 /mut/raid0]# dd if=/dev/zero of=file bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 18.0445 s, 59.5 MB/s
现在测试写的性能:
[root@station40 /mut/raid0]# dd if=file of=/dev/null
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB) copied, 3.67849 s, 584 MB/s
第五步:现在我们创建一个RAID-5
a:因为考虑到目前没有备用磁盘sparedisk,所以需要加一块;
b;添加OK后就可以开始raid-5的创建
[root@station40 /mut/raid0]# mdadm -C /dev/md5 -a yes -l 5 -n 3 -x 1 /dev/sdb3 /dev/sdb5 /dev/sdb6 /dev/sdb7 (红色为增加的备用磁盘为1块磁盘为/dev/sdb7)
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.
c.创建OK后可以检查
[root@station40 /mut/raid0]# mdadm -D /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Mon Apr 24 11:21:44 2017
Raid Level : raid5
Array Size : 4204544 (4.01 GiB 4.31 GB)
Used Dev Size : 2102272 (2.00 GiB 2.15 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Mon Apr 24 11:22:07 2017
State : clean
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 512K
Name : station40.magelinux.com:5 (local to host station40.magelinux.com)
UUID : 45fad8bb:492498b4:7a0adc06:19f0a544
Events : 18
Number Major Minor RaidDevice State
0 8 19 0 active sync /dev/sdb3
1 8 21 1 active sync /dev/sdb5
4 8 22 2 active sync /dev/sdb6
3 8 23 - spare /dev/sdb7
d:接着进行格式化处理
[root@station40 /mut/raid0]# mkfs.ext4 /dev/md5
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=128 blocks, Stripe width=256 blocks
262944 inodes, 1051136 blocks
52556 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1077936128
33 block groups
32768 blocks per group, 32768 fragments per group
7968 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
e:现在可以查看系统中的raid的情况
[root@station40 ~]# mdadm -Ds
ARRAY /dev/md0 metadata=1.2 name=station40.magelinux.com:0 UUID=b08b2229:03516277:61d40ba7:0c5be81b
ARRAY /dev/md5 metadata=1.2 spares=1 name=station40.magelinux.com:5 UUID=45fad8bb:492498b4:7a0adc06:19f0a544
f:现在我们可以检查raid-5的容错性先
[root@station40 ~]# mdadm -Ds > /etc/mdadm.conf (我们需要将系统中的raid设备加载至其配置文件中,这样就不会影响开关机)
同时我们取消raid的挂载
[root@station40 ~]# umount /mut/raid0
然后我们就可以禁用raid设备了
[root@station40 ~]# mdadm -S /dev/md0 stop
mdadm: stopped /dev/md0
mdadm: Cannot open stop
禁用后我们查看该设备是看不到的
root@station40 ~]# ll /dev/md0
ls: cannot access /dev/md0: No such file or directory
现在可以启用该设备了(这里如果开始没有写配置文件的那一步则这次就无法启动的)
[root@station40 ~]# mdadm -A /dev/md0
mdadm: /dev/md0 has been started with 2 drives
g:现在可以模拟将RAID-5中的sdb3损坏
[root@station40 ~]# mdadm /dev/md5 -f /dev/sdb3
mdadm: set /dev/sdb3 faulty in /dev/md5
现在可以看下系统中raid-5的情况
[root@station40 ~]# mdadm -D /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Mon Apr 24 11:21:44 2017
Raid Level : raid5
Array Size : 4204544 (4.01 GiB 4.31 GB)
Used Dev Size : 2102272 (2.00 GiB 2.15 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Mon Apr 24 17:30:21 2017
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 1 (一块损坏状态)
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Name : station40.magelinux.com:5 (local to host station40.magelinux.com)
UUID : 45fad8bb:492498b4:7a0adc06:19f0a544
Events : 37
Number Major Minor RaidDevice State
3 8 23 0 active sync /dev/sdb7 (备用的磁盘挂上去了)
1 8 21 1 active sync /dev/sdb5
4 8 22 2 active sync /dev/sdb6
0 8 19 - faulty /dev/sdb3
h:现在我们把损坏的硬盘移除掉
[root@station40 ~]# mdadm /dev/md5 -r /dev/sdb3
mdadm: hot removed /dev/sdb3 from /dev/md5
[root@station40 ~]# mdadm -D /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Mon Apr 24 11:21:44 2017
Raid Level : raid5
Array Size : 4204544 (4.01 GiB 4.31 GB)
Used Dev Size : 2102272 (2.00 GiB 2.15 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Mon Apr 24 17:45:48 2017
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Name : station40.magelinux.com:5 (local to host station40.magelinux.com)
UUID : 45fad8bb:492498b4:7a0adc06:19f0a544
Events : 38
Number Major Minor RaidDevice State
3 8 23 0 active sync /dev/sdb7
1 8 21 1 active sync /dev/sdb5
4 8 22 2 active sync /dev/sdb6
可以看到/dev/sdb3已经被移除。
现在我们再追加一个磁盘
[root@station40 ~]# mdadm /dev/md5 -a /dev/sdb3
mdadm: added /dev/sdb3
[root@station40 ~]# mdadm -D /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Mon Apr 24 11:21:44 2017
Raid Level : raid5
Array Size : 4204544 (4.01 GiB 4.31 GB)
Used Dev Size : 2102272 (2.00 GiB 2.15 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent
Update Time : Mon Apr 24 17:49:13 2017
State : clean
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 512K
Name : station40.magelinux.com:5 (local to host station40.magelinux.com)
UUID : 45fad8bb:492498b4:7a0adc06:19f0a544
Events : 39
Number Major Minor RaidDevice State
3 8 23 0 active sync /dev/sdb7
1 8 21 1 active sync /dev/sdb5
4 8 22 2 active sync /dev/sdb6
5 8 19 - spare /dev/sdb3
同时我们需要知道当我们增加raid磁盘阵列需要增加成员的的时候可以使用
将磁盘增加至4块
[root@station40 ~]# mdadm -G /dev/md5 -n 4 -a /dev/sdb3
增加的磁盘因为没有文件系统所以需要在添加OK后同步一下RAID的文件格式
[root@station40 ~]# resize3fs /dev/md5
- megacli在线raid构建详解(转载自用)
版权声明:本文为博主原创文章,未经博主允许不得转载,转载附上原文链接即可. https://blog.csdn.net/GX_1_11_real/article/details/83213959 ht ...
- CentOS 6.3下配置软RAID(Software RAID)
一.RAID 简介 RAID 是英文Redundant Array of Independent Disks 的缩写,翻译成中文意思是“独立磁盘冗余阵列”,有时也简称磁盘阵列(Disk Array). ...
- 【linux相识相知】独立硬盘冗余阵列-RAID
独立硬盘冗余阵列(RAID,Redundant Array of Independant Disks),旧称为廉价磁盘冗余阵列(Redundant Array of Inexpensive Disks ...
- (转)CentOS 6下配置软RAID图文详解
CentOS 6下配置软RAID图文详解 原文:http://blog.51cto.com/hujiangtao/1929620 一.RAID 简介 RAID 是英文Redundant Array o ...
- 运维知识体系v0.5
http://www.90qj.com/?post=318http://ixdba.blog.51cto.com/2895551/1751377 运维知识体系v0.5-(运维社区-赵班长出品,欢迎 ...
- 我要为运维说一句,我们不是网管,好不!!Are you know?
运维 运维,这里指互联网运维,通常属于技术部门,与研发.测试.系统管理同为互联网产品技术支撑的4大部门,这个划分在国内和国外以及大小公司间都会多少有一些不同. 一个互联网产品的生成一般经历的过程是:产 ...
- [转] 运维知识体系 -v3.1 作者:赵舜东(赵班长)转载请注明来自于-新运维社区:https://www.unixhot.com
[From]https://www.unixhot.com/page/ops [运维知识体系]-v3.1 作者:赵舜东(赵班长) (转载请注明来自于-新运维社区:https://www.unixhot ...
- 【原】Linux Raid 实验
本文参照以下两个链接,将实验重做了一遍,目的就是加深印象及提升实操能力 参照链接:http://www.opsers.org/base/learning-linux-the-day-that-the- ...
- RAID选项
RAID:Redundant Array Independent Disk(独立磁盘构成的具有冗余能力的阵列) 最常见的为RAID类型为:0,1,5和10:3和6很少见,但在某些环境中仍然有用. RA ...
随机推荐
- 201521123044 《Java程序设计》第11周学习总结
1. 本章学习总结 2. 书面作业 本次PTA作业题集多线程 1.互斥访问与同步访问 完成题集4-4(互斥访问)与4-5(同步访问) 1.1 除了使用synchronized修饰方法实现互斥同步访问, ...
- 201521123045 《JAVA程序设计》 第14周学习总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多数据库相关内容. 2. 书面作业 1. MySQL数据库基本操作 建立数据库,将自己的姓名.学号作为一条记录插入.(截图,需出现自 ...
- smarty文件夹,第一个smarty实例总结
主要是libs里面的smarty类,和init.inc.php配置文件 剩下的是php文件夹.模板文件夹,临时文件夹.缓存文件夹.配置文件夹.插件文件夹 调用main文件夹中的php文件,通过 ...
- 设置文件opendilag、savedilog默认路径和文件类型
dlgSave1.Filter:='文件.txt|*.txt;|word文件|*.doc,*.docx'; dlgSave1.InitialDir:=GetCurrentDir; //设置为当前路径 ...
- Download the Hibernate Tools
首先去官网上下载最新版本的Hibernate Tools JBoss Tools 4.5.0.Final Requirements: Java 8 and Eclipse Oxygen 4.7 有 4 ...
- String类的常见面试题(3)
1.判断定义为String类型的s1和s2是否相等 String s1 = "abc"; //这个"abc"对象首先会进常量池 String s2 = &quo ...
- oracle 数据库管理--管理表空间和数据文件
一.概念表空间是数据库的逻辑组成部分.从物理上讲,数据库数据存放在数据文件中:从逻辑上讲,数据库数据则是存放在表空间中,表空间由一个或多个数据文件组成. 二.数据库的逻辑结构oracle中逻辑结构包括 ...
- Https系列之四:https的SSL证书在Android端基于okhttp,Retrofit的使用
Https系列会在下面几篇文章中分别作介绍: 一:https的简单介绍及SSL证书的生成二:https的SSL证书在服务器端的部署,基于tomcat,spring boot三:让服务器同时支持http ...
- 【Linux笔记(002) 】-- centos7 文档操作基本命令
一.cd -- ChangeDirectory a) 切换到 /DemoLM/ 文件夹 b) 回到用户 Home 根目录:是哪个账户登录的就会进入哪个用户的根目录 二.pwd -- PrintWork ...
- Linux入门之常用命令(8)上传下载
[什么是rz/sz (lsz/lrz)] 简单说就是,可以很方便地用这两个sz/rz工具,实现Linux下和Windows之间的文件传输(发送和接收),速度大概为10KB/s,适合中小文件.rz/s ...