在國產晶片伺服器(海之舟伺服器+作業系統)上建立軟Raid

wxh585發表於2019-10-12

本次在海之舟伺服器上建立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  //檢視磁碟
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    1   7.5G  0 disk
└─sda1        8:1    1   7.5G  0 part
  └─md0       9:0    0   7.5G  0 raid1 /mnt
sdb           8:16   1   7.5G  0 disk
└─sdb1        8:17   1   7.5G  0 part
  └─md0       9:0    0   7.5G  0 raid1 /mnt
sdc           8:32   1   7.5G  0 disk
└─sdc1        8:33   1   7.5G  0 part
  └─md0       9:0    0   7.5G  0 raid1 /mnt
mmcblk0     179:0    0 119.3G  0 disk
├─mmcblk0p1 179:1    0   1.4G  0 part
└─mmcblk0p2 179:2    0 117.8G  0 part



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23102655/viewspace-2659668/,如需轉載,請註明出處,否則將追究法律責任。

相關文章