栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

raid配置(详解)

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

raid配置(详解)

1、首先添加一块磁盘,步骤如下:

点击虚拟机,选择设置

 直接下一步下一步,到这里选择“将虚拟磁盘存储为单个文件”,最后点击完成。

 2、添加了磁盘因为系统不能直接识别到,所以需要重启虚拟机,或者使用以下命令来扫描磁盘。

完了使用"fdisk -l"来查看一下新添加的磁盘。

[root@localhost user]# echo " - - -" >> /sys/class/scsi_host/host0/scan
[root@localhost user]# echo " - - -" >> /sys/class/scsi_host/host1/scan
[root@localhost user]# echo " - - -" >> /sys/class/scsi_host/host2/scan
[root@localhost user]# 

3、添加好之后使用以下命令编辑一下磁盘分区。

 4、创建raid0

专用选项: - l : 指定级别 - n: 设备个数 - a: {yes|no} 自动为其创建设备文件 - c: chunk 大小,默认为 64k , ( 数据块 ) 2 的 N 次方 - x: 指定空闲盘的个数
[root@localhost user]# mdadm -C /dev/md0 -a yes -l 0 -n 2 /dev/sdc{1,2}
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
// 查看当前系统上所有启用 了 Raid 的设备
[root@localhost user]# cat /proc/mdstat
Personalities : [raid0] 
md0 : active raid0 sdc2[1] sdc1[0]
      2095104 blocks super 1.2 512k chunks
      
unused devices: 
[root@localhost user]# 

接下来格式化raid硬盘

[root@localhost user]# mkfs.xfs /dev/md0
meta-data=/dev/md0               isize=512    agcount=8, agsize=65408 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=523264, imaxpct=25
         =                       sunit=128    swidth=256 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
这里可以查看到我们刚才创建的硬盘信息,我们也格式化过了,然后就可以直接挂在使用了。
[root@localhost user]# mkdir /mnt/raid0
[root@localhost user]# mount /dev/md0 /mnt/raid0
[root@localhost user]# df -hT /mnt/raid0
文件系统       类型  容量  已用  可用 已用% 挂载点
/dev/md0       xfs   2.0G   33M  2.0G    2% /mnt/raid0

注:当然这个是临时挂载,也可以加入开机自动挂载,编辑/etc/fstab文件即可。

上面是创建了一个raid0,下面在创建一个raid1。

1、和上面一样,先创建两个磁盘分区,如果没有的话则使用以下命令手动同步磁盘,一次不行就多试几次。

[root@localhost user]# partprobe /dev/sdc
[root@localhost user]# partprobe /dev/sdc
[root@localhost user]# partprobe /dev/sdc

2、直接用命令创建。

[root@localhost user]# mdadm -C /dev/md1 -a yes -l 1 -n 2 /dev/sdc{3,4}
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: largest drive (/dev/sdc3) exceeds size (1046528K) by more than 1%
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
[root@localhost user]# cat /proc/mdstat
Personalities : [raid0] [raid1] 
md1 : active raid1 sdc4[1] sdc3[0]
      1046528 blocks super 1.2 [2/2] [UU]
      
md0 : active raid0 sdc2[1] sdc1[0]
      2095104 blocks super 1.2 512k chunks
      
unused devices: 

3、跟创建raid0一样,格式化完了挂载。

[root@localhost user]# mkdir /mnt/raid1
[root@localhost user]# mkfs.xfs /dev/md1
meta-data=/dev/md1               isize=512    agcount=4, agsize=65408 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=261632, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost user]# mount /dev/md1 /mnt/raid1/
[root@localhost user]# df -hT /mnt/raid1/
文件系统       类型  容量  已用  可用 已用% 挂载点
/dev/md1       xfs  1019M   33M  987M    4% /mnt/raid1

本次的文章到这里就结束了。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/827015.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号