raid配置

先添加一块磁盘

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

 先分两个分区,每个分区大小为1G

[root@localhost tmp]# gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-4194270, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-4194270, default = 4194270) or {+-}size{KMGTP}: +1G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): n
Partition number (2-128, default 2): 
First sector (34-4194270, default = 2099200) or {+-}size{KMGTP}: 
Last sector (2099200-4194270, default = 4194270) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

 创建raid0

[root@localhost tmp]# mdadm -C /dev/md0 -a yes -l 0 -n 2 /dev/sdb{1,2}
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

查看当前系统上所有启用了Raid的设备

[root@localhost tmp]# cat /proc/mdstat
Personalities : [raid0] 
md0 : active raid0 sdb2[1] sdb1[0]
      2093568 blocks super 1.2 512k chunks
      
unused devices: <none>
[root@localhost tmp]# 

格式化raid硬盘

[root@localhost tmp]# 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 tmp]# 

现在挂载

[root@localhost ~]# df -hT /mnt/radi0
文件系统       类型  容量  已用  可用 已用% 挂载点
/dev/md0       xfs   2.0G   33M  2.0G    2% /mnt/radi0
[root@localhost ~]# 

再来分两个分区

[root@localhost ~]# gdisk /dev/sdc
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-2097118, default = 2048) or {+-}size{KMGTP}: +500m
Last sector (1026048-2097118, default = 2097118) or {+-}size{KMGTP}: +500m
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): n
Partition number (2-128, default 2): 
First sector (34-2097118, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-1026047, default = 1026047) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'

Command (? for help): 

直接用命令创建

[root@localhost ~]# mdadm -C /dev/md1 -a yes -l 1 -n 2 /dev/sdc{1,2}
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
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
[root@localhost ~]# 

创建raid1,挂载

[root@localhost ~]# mkdir /mnt/raid1
[root@localhost ~]# mkfs.xfs /dev/md1
meta-data=/dev/md1               isize=512    agcount=4, agsize=31980 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=127920, 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 ~]# 
[root@localhost ~]# mount /dev/md1 /mnt/raid1
[root@localhost ~]# mount | tail -1
/dev/md1 on /mnt/raid1 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
[root@localhost ~]# 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值