在国产芯片服务器(海之舟服务器+操作系统)上建立软Raid

本次在海之舟服务器上建立raid 1,sda+sdb
root@bigdataA:/home/zs# fdisk -l //列出磁盘。

Disk /dev/sda: 7.5 GiB, 8069677056 bytes, 15761088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 15761087 15759040 7.5G fd Linux raid autodetect

Disk /dev/md2: 15 GiB, 16128147456 bytes, 31500288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 524288 bytes / 1048576 bytes

Disk /dev/sdb: 7.5 GiB, 8069677056 bytes, 15761088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00018971

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 15761087 15759040 7.5G 7 HPFS/NTFS/exFAT
root@bigdataA:/home/zs#fdisk /dev/sda

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sda: 7.5 GiB, 8069677056 bytes, 15761088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 15761087 15759040 7.5G fd Linux raid autodetect

Command (m for help): d //删除分区
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n //新建分区
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-15761087, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-15761087, default 15761087):

Created a new partition 1 of type ‘Linux’ and of size 7.5 GiB.

Command (m for help): m

Help:

DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag

Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition

Misc
m print this menu
u change display/entry units
x extra functionality (experts only)

Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file

Save & Exit
w write table to disk and exit
q quit without saving changes

Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table

Command (m for help): t //改变分区属性为fd
Selected partition 1
Partition type (type L to list all types): fd
Changed type of partition ‘Linux’ to ‘Linux raid autodetect’.

Command (m for help): w //保存
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

root@bigdataA:/home/zs#
root@bigdataA:/home/zs# fdisk /dev/sdb //对三sdb进行分区,详细略.

root@bigdataA:/home/zs# mdadm --create --verbose /dev/md1 -l 1 -n 2 -x 0 /dev/sdb /dev/sda
mdadm: /dev/sda appears to be part of a raid array:
level=raid0 devices=2 ctime=Sat Sep 21 17:24:12 2019
mdadm: partition table exists on /dev/sda but will be lost or
meaningless after creating array
mdadm: /dev/sdb appears to be part of a raid array:
level=raid0 devices=2 ctime=Sat Sep 21 17:24:12 2019
mdadm: partition table exists on /dev/sdb but will be lost or
meaningless after creating array
Continue creating array? y
mdadm: Fail create md1 when using /sys/module/md_mod/parameters/new_array
mdadm: Defaulting to version 1.2 metadata

root@bigdataA:/home/zs# mkfs -t ext4 /dev/md1 //格式化md1
mke2fs 1.43.4 (31-Jan-2017)
/dev/md1 contains a ext4 file system
last mounted on /md2 on Sat Sep 21 22:37:45 2019
Proceed anyway? (y,N) y
Creating filesystem with 3937536 4k blocks and 985424 inodes
Filesystem UUID: 41c965ce-3deb-45fb-be12-c7f29a05e5b3
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information:
done

root@bigdataA:/home/zs#

root@bigdataA:/home/zs# mkdis /md1
root@bigdataA:/home/zs# mkdir md1
root@bigdataA:/home/zs# mdadm -Ds >/etc/mdadm.conf //设置开机自动挂载
root@bigdataA:/home/zs# tail -n 1 /etc/mtab >> /etc/fstab
root@bigdataA:/home/zs#fdisk -l
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 196608 3137535 2940928 1.4G 83 Linux
/dev/mmcblk0p2 3137536 250085375 246947840 117.8G 83 Linux

Disk /dev/sdb: 7.5 GiB, 8069677056 bytes, 15761088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00018971

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 15761087 15759040 7.5G 7 HPFS/NTFS/exFAT

Disk /dev/sda: 7.5 GiB, 8069677056 bytes, 15761088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 15761087 15759040 7.5G fd Linux raid autodetect

Disk /dev/md1: 7.5 GiB, 8064401408 bytes, 15750784 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@bigdataA:/home/zs#
root@bigdataA:/home/zs# cd /md1
root@bigdataA:/md1# touch aa
root@bigdataA:/md1# ls
aa
常用命令:
mdadm -Ds 查看阵列
mdadm -D /dev/md0 查看阵列
组件raid时,如显示mdadm: ddf: Cannot use /dev/sdb1: Device or resource busy,则需先停闭
mdadm -S /dev/md0 停止阵列,停止前,需先执行umount
mdadm -A /dev/md0 /dev/sdb1 /dev/sda1 重新装配阵列
mdadm /dev/md0 -f /dev/sda1 模拟损坏
mdadm /dev/md0 -r /dev/sda1 移除损坏的磁盘:
mdadm /dev/md0 -a /dev/sda1 添加新的硬盘到已有阵列,时间较长。
root@bigdataA:/home/zs# lsblk //查看磁盘

你可能感兴趣的:(在国产芯片服务器(海之舟服务器+操作系统)上建立软Raid)