博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
接上一篇(测试--mdadm用iscsi硬盘和本机硬盘建立raid)
阅读量:2452 次
发布时间:2019-05-10

本文共 20473 字,大约阅读时间需要 68 分钟。

正常情况下模拟rac1关机,然后rac2接管后在里面写的有文件,等rac1可以启动的时候,查看是否可以看到在rac2机器中写的资料

关闭rac1机器;

[root@rac1 /]# shutdown -g0 -y

rac2 启动iscsi服务(iscsi配置的和rac1一样,也就是说,rac2这个时候既是服务端,又是客户端)

[root@rac2 ~]# /etc/init.d/iscsi start

Checking iscsi config: [ OK ]
Loading iscsi driver: [ OK ]
mknod: `/dev/iscsictl': File exists
Starting iscsid: [ OK ]
[root@rac2 ~]# fdisk -l
...
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536 MB, 536870912 bytes

17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes

Disk /dev/sdc doesn't contain a valid partition table

[root@rac2 ~]#

dmesg信息:
scsi3 : SFNet iSCSI driver
Vendor: IET Model: VIRTUAL-DISK Rev: 0
Type: Direct-Access ANSI SCSI revision: 04
SCSI device sdc: 1048576 512-byte hdwr sectors (537 MB)
SCSI device sdc: drive cache: write through
SCSI device sdc: 1048576 512-byte hdwr sectors (537 MB)
SCSI device sdc: drive cache: write through
sdc: unknown partition table
Attached scsi disk sdc at scsi3, channel 0, id 0, lun 4
[root@rac2 ~]#

sdc就是新增加的硬盘,挂载设备,写文件测试:

[root@rac2 ~]# mkdir /mnt/sdc
[root@rac2 ~]# mount /dev/sdc /mnt/sdc
[root@rac2 ~]# cd /mnt/sdc
[root@rac2 sdc]# ls
lost+found nohup.out rac120071026 test
[root@rac2 sdc]# touch rac2_20071026
[root@rac2 sdc]# ls
lost+found nohup.out rac120071026 rac2_20071026 test
[root@rac2 sdc]# cd /
[root@rac2 /]# umount /dev/sdc
[root@rac2 /]# /etc/init.d/iscsi stop
Searching for iscsi-based multipath maps
Found 0 maps
Stopping iscsid: [ OK ]
Removing iscsi driver: [ OK ]
[root@rac2 /]#

启动rac1
fdisk -l状态:
[root@rac1 ~]# fdisk -l
......
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/md0: 536 MB, 536805376 bytes

2 heads, 4 sectors/track, 131056 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn't contain a valid partition table

Disk /dev/sdc: 536 MB, 536870912 bytes

17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes

Disk /dev/sdc doesn't contain a valid partition table

mdadm状态:
[root@rac1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb[0]
524224 blocks [2/1] [U_]
unused devices:
[root@rac1 ~]# mdadm --detail /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Thu Oct 25 15:28:07 2007
Raid Level : raid1
Array Size : 524224 (511.94 MiB 536.81 MB)
Device Size : 524224 (511.94 MiB 536.81 MB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Fri Oct 26 01:10:11 2007

State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 0 0 -1 removed
UUID : 081c04ac:6cb9278e:35bade9d:49098be4
Events : 0.190
[root@rac1 ~]#

停止阵列:

[root@rac1 /]# mdadm -S /dev/md0
[root@rac1 /]# fdisk -l
......
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536 MB, 536870912 bytes

17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes

Disk /dev/sdc doesn't contain a valid partition table

启动阵列的时候只启动了一个盘

[root@rac1 /]# mdadm -A /dev/md0 /dev/sdb /dev/sdc
mdadm: /dev/md0 has been started with 1 drive (out of 2).
[root@rac1 /]# mount /dev/md0 /mnt/md0
[root@rac1 /]# cd /mnt/md0
[root@rac1 md0]# ls
lost+found nohup.out rac120071026 test

从上面可以看到在rac2机器上写的文件不存在

查看raid状态:
[root@rac1 md0]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb[0]
524224 blocks [2/1] [U_]
unused devices:
[root@rac1 md0]# mdadm --detail /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Thu Oct 25 15:28:07 2007
Raid Level : raid1
Array Size : 524224 (511.94 MiB 536.81 MB)
Device Size : 524224 (511.94 MiB 536.81 MB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Fri Oct 26 09:17:11 2007

State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 0 0 -1 removed
UUID : 081c04ac:6cb9278e:35bade9d:49098be4
Events : 0.196
[root@rac1 md0]#

在阵列中增加新的硬盘:

[root@rac1 md0]# mdadm /dev/md0 --add /dev/sdc
mdadm: hot added /dev/sdc

察看raid状态

[root@rac1 md0]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc[2] sdb[0]
524224 blocks [2/1] [U_]
[==>..................] recovery = 12.6% (66688/524224) finish=1.5min speed=4763K/sec
unused devices:
[root@rac1 md0]# mdadm --detail /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Thu Oct 25 15:28:07 2007
Raid Level : raid1
Array Size : 524224 (511.94 MiB 536.81 MB)
Device Size : 524224 (511.94 MiB 536.81 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Fri Oct 26 09:19:08 2007

State : clean, degraded, recovering
Active Devices : 1
Working Devices : 2
Failed Devices : 0
Spare Devices : 1

Rebuild Status : 30% complete

Number Major Minor RaidDevice State

0 8 16 0 active sync /dev/sdb
1 0 0 -1 removed
2 8 32 1 spare /dev/sdc
UUID : 081c04ac:6cb9278e:35bade9d:49098be4
Events : 0.197
[root@rac1 md0]#

重新测试:

rac1上操作,卸载硬盘,禁用raid,停止iscsi。
[root@rac1 /]# umount /dev/md0
[root@rac1 /]# mdadm -S /dev/md0
[root@rac1 /]# /etc/init.d/iscsi stop
Searching for iscsi-based multipath maps
Found 0 maps
Stopping iscsid: [ OK ]
Removing iscsi driver: [ OK ]
[root@rac1 /]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 892 7164958+ 83 Linux
/dev/sda2 893 1274 3068415 82 Linux swap
/dev/sda3 1275 2610 10731420 83 Linux

Disk /dev/sdb: 536 MB, 536870912 bytes

64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

[root@rac1 /]#

rac2上启动iscsi,加载硬盘,写入数据,停止硬盘,停止iscsi
[root@rac2 /]# /etc/init.d/iscsi start
Checking iscsi config: [ OK ]
Loading iscsi driver: [ OK ]
mknod: `/dev/iscsictl': File exists
Starting iscsid: [ OK ]
[root@rac2 /]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 892 7164958+ 83 Linux
/dev/sda2 893 1274 3068415 82 Linux swap
/dev/sda3 1275 2610 10731420 83 Linux

Disk /dev/sdb: 536 MB, 536870912 bytes

64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536 MB, 536870912 bytes

17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes

Disk /dev/sdc doesn't contain a valid partition table

[root@rac2 /]# mount /dev/sdc /mnt/sdc
[root@rac2 /]# cd /mnt/sdc
[root@rac2 sdc]# ls
lost+found nohup.out rac120071026 test
[root@rac2 sdc]# touch rac2_20071026
[root@rac2 sdc]# cd /
[root@rac2 /]# umount /dev/sdc
[root@rac2 /]# /etc/init.d/iscsi stop
Searching for iscsi-based multipath maps
Found 0 maps
Stopping iscsid: [ OK ]
Removing iscsi driver: [ OK ]
[root@rac2 /]#

rac1上启动iscsi,

[root@rac1 /]# /etc/init.d/iscsi start
Checking iscsi config: [ OK ]
Loading iscsi driver: [ OK ]
mknod: `/dev/iscsictl': File exists
Starting iscsid: [ OK ]
[root@rac1 /]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 892 7164958+ 83 Linux
/dev/sda2 893 1274 3068415 82 Linux swap
/dev/sda3 1275 2610 10731420 83 Linux

Disk /dev/sdb: 536 MB, 536870912 bytes

64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536 MB, 536870912 bytes

17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes

Disk /dev/sdc doesn't contain a valid partition table

[root@rac1 /]#

[root@rac1 /]# mdadm -As /dev/md0
mdadm: /dev/md0 has been started with 2 drives.
[root@rac1 /]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb[0] sdc[1]
524224 blocks [2/2] [UU]
unused devices:
[root@rac1 /]# mdadm -D /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Thu Oct 25 15:28:07 2007
Raid Level : raid1
Array Size : 524224 (511.94 MiB 536.81 MB)
Device Size : 524224 (511.94 MiB 536.81 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Fri Oct 26 09:25:21 2007

State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
UUID : 081c04ac:6cb9278e:35bade9d:49098be4
Events : 0.208
[root@rac1 /]#

[root@rac1 /]# mount /dev/md0 /mnt/md0

[root@rac1 /]# cd /mnt/md0
[root@rac1 md0]# ls -al
total 21
drwxr-xr-x 3 root root 1024 Oct 26 03:42 .
drwxr-xr-x 3 root root 4096 Oct 25 14:55 ..
drwx------ 2 root root 12288 Oct 25 15:31 lost+found
-rw------- 1 root root 0 Oct 26 01:01 nohup.out
-rw-r--r-- 1 root root 0 Oct 26 01:08 rac120071026
?--------- ? ? ? ? ? rac2_20071026
-rw-r--r-- 1 root root 0 Oct 25 15:32 test

[root@rac1 mnt]# mdadm /dev/md0 -f /dev/sdb

mdadm: set /dev/sdb faulty in /dev/md0
[root@rac1 mnt]# mdadm /dev/md0 -r /dev/sdb
mdadm: hot removed /dev/sdb
[root@rac1 mnt]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc[1]
524224 blocks [2/1] [_U]
unused devices:
[root@rac1 mnt]# mdadm /dev/md0 -a /dev/sdb
mdadm: hot added /dev/sdb
[root@rac1 mnt]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb[2] sdc[1]
524224 blocks [2/1] [_U]
[=>...................] recovery = 8.3% (44032/524224) finish=2.1min speed=3669K/sec
unused devices:
[root@rac1 mnt]#

重新卸载设备后,再重新加载,加载后文件如下:

[root@rac1 md0]# ls -al
total 21
drwxr-xr-x 3 root root 1024 Oct 26 03:42 .
drwxr-xr-x 3 root root 4096 Oct 25 14:55 ..
drwx------ 2 root root 12288 Oct 25 15:31 lost+found
-rw------- 1 root root 0 Oct 26 01:01 nohup.out
-rw-r--r-- 1 root root 0 Oct 26 01:08 rac120071026
-rw-r--r-- 1 root root 0 Oct 26 03:42 rac2_20071026
-rw-r--r-- 1 root root 0 Oct 25 15:32 test
[root@rac1 md0]#

正常。

再模拟rac1关机。

rac2操作:
[root@rac2 /]# /etc/init.d/iscsi start
Checking iscsi config: [ OK ]
Loading iscsi driver: [ OK ]
mknod: `/dev/iscsictl': File exists
Starting iscsid: [ OK ]
[root@rac2 /]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 892 7164958+ 83 Linux
/dev/sda2 893 1274 3068415 82 Linux swap
/dev/sda3 1275 2610 10731420 83 Linux

Disk /dev/sdb: 536 MB, 536870912 bytes

64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536 MB, 536870912 bytes

17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes

Disk /dev/sdc doesn't contain a valid partition table

[root@rac2 /]# mount /dev/sdc /mnt/sdc
[root@rac2 /]# cd /mnt/sdc
[root@rac2 sdc]# ls
lost+found nohup.out rac120071026 rac2_20071026 test
[root@rac2 sdc]# vi rac2

aaaaaaaaaaaaaaaa

wq
"rac2" [New] 1L, 17C written
[root@rac2 sdc]# ls
lost+found nohup.out rac120071026 rac2 rac2_20071026 test
[root@rac2 sdc]# cd /
[root@rac2 /]# umount /dev/sdc
[root@rac2 /]# /etc/init.d/iscsi stop
Searching for iscsi-based multipath maps
Found 0 maps
Stopping iscsid: [ OK ]
Removing iscsi driver: [ OK ]
[root@rac2 /]#

启动rac1

[root@rac1 ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 892 7164958+ 83 Linux
/dev/sda2 893 1274 3068415 82 Linux swap
/dev/sda3 1275 2610 10731420 83 Linux

Disk /dev/sdb: 536 MB, 536870912 bytes

64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/md0: 536 MB, 536805376 bytes

2 heads, 4 sectors/track, 131056 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn't contain a valid partition table

Disk /dev/sdc: 536 MB, 536870912 bytes

17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes

Disk /dev/sdc doesn't contain a valid partition table

[root@rac1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb[0]
524224 blocks [2/1] [U_]
unused devices:
[root@rac1 ~]# mdadm -D /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Thu Oct 25 15:28:07 2007
Raid Level : raid1
Array Size : 524224 (511.94 MiB 536.81 MB)
Device Size : 524224 (511.94 MiB 536.81 MB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Fri Oct 26 09:39:43 2007

State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 0 0 -1 removed
UUID : 081c04ac:6cb9278e:35bade9d:49098be4
Events : 0.334
[root@rac1 ~]# mdadm /dev/md0 -f /dev/sdb
mdadm: set /dev/sdb faulty in /dev/md0
[root@rac1 ~]# mdadm /dev/md0 -r /dev/sdb
mdadm: hot remove failed for /dev/sdb: Device or resource busy
[root@rac1 ~]# mdadm /dev/md0 -a /dev/sdc
mdadm: hot added /dev/sdc
[root@rac1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc[2] sdb[0]
524224 blocks [2/1] [U_]
[=>...................] recovery = 7.6% (40704/524224) finish=1.7min speed=4522K/sec
unused devices:
[root@rac1 ~]# mdadm -D /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Thu Oct 25 15:28:07 2007
Raid Level : raid1
Array Size : 524224 (511.94 MiB 536.81 MB)
Device Size : 524224 (511.94 MiB 536.81 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Fri Oct 26 09:59:02 2007

State : clean, degraded, recovering
Active Devices : 1
Working Devices : 2
Failed Devices : 0
Spare Devices : 1

Rebuild Status : 37% complete

Number Major Minor RaidDevice State

0 8 16 0 active sync /dev/sdb
1 0 0 -1 removed
2 8 32 1 spare /dev/sdc
UUID : 081c04ac:6cb9278e:35bade9d:49098be4
Events : 0.335
[root@rac1 ~]#

不成功。/dev/sdc资料丢失。

重新测试:

[root@rac1 ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 892 7164958+ 83 Linux
/dev/sda2 893 1274 3068415 82 Linux swap
/dev/sda3 1275 2610 10731420 83 Linux

Disk /dev/sdb: 536 MB, 536870912 bytes

64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/md0: 536 MB, 536805376 bytes

2 heads, 4 sectors/track, 131056 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn't contain a valid partition table

Disk /dev/sdc: 536 MB, 536870912 bytes

17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes

Disk /dev/sdc doesn't contain a valid partition table

[root@rac1 ~]# mdadm -S /dev/md0

[root@rac1 ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 892 7164958+ 83 Linux
/dev/sda2 893 1274 3068415 82 Linux swap
/dev/sda3 1275 2610 10731420 83 Linux

Disk /dev/sdb: 536 MB, 536870912 bytes

64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536 MB, 536870912 bytes

17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes

Disk /dev/sdc doesn't contain a valid partition table

[root@rac1 ~]# mdadm -As /dev/md0
mdadm: /dev/md0 has been started with 1 drive (out of 2).
[root@rac1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb[0]
524224 blocks [2/1] [U_]
unused devices:
[root@rac1 ~]# mdadm -D /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Thu Oct 25 15:28:07 2007
Raid Level : raid1
Array Size : 524224 (511.94 MiB 536.81 MB)
Device Size : 524224 (511.94 MiB 536.81 MB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Fri Oct 26 10:01:53 2007

State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 0 0 -1 removed
UUID : 081c04ac:6cb9278e:35bade9d:49098be4
Events : 0.448

正确的操作应该是:
关闭阵列:
[root@rac1 ~]# mdadm -S /dev/md0

启动阵列只启动一个硬盘报错:

[root@rac1 ~]# mdadm -A /dev/md0 /dev/sdc
mdadm: /dev/md0 assembled from 1 drive - need all 2 to start it (use --run to insist).

查看帮助:

[root@rac1 ~]# mdadm -A --help
Usage: mdadm --assemble device options...
mdadm --assemble --scan options...
Options that are valid with --assemble (-A) are:
--uuid= -u : uuid of array to assemble. Devices which don't
have this uuid are excluded
--super-minor= -m : minor number to look for in super-block when
choosing devices to use.
--config= -c : config file
--scan -s : scan config file for missing information
--run -R : Try to start the array even if not enough devices
for a full array are present
--force -f : Assemble the array even if some superblocks appear
: out-of-date. This involves modifying the superblocks.
--update= -U : Update superblock: one of sparc2.2, super-minor or summaries

启动阵列:

[root@rac1 ~]# mdadm -AR /dev/md0 /dev/sdc
mdadm: /dev/md0 has been started with 1 drive (out of 2).
[root@rac1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc[1]
524224 blocks [2/1] [_U]
unused devices:
[root@rac1 ~]# mdadm -D /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Thu Oct 25 15:28:07 2007
Raid Level : raid1
Array Size : 524224 (511.94 MiB 536.81 MB)
Device Size : 524224 (511.94 MiB 536.81 MB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Fri Oct 26 10:01:02 2007

State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0

Number Major Minor RaidDevice State
0 0 0 -1 removed
1 8 32 1 active sync /dev/sdc
UUID : 081c04ac:6cb9278e:35bade9d:49098be4
Events : 0.342

加入新硬盘:

[root@rac1 ~]# mdadm /dev/md0 -a /dev/sdb
mdadm: hot added /dev/sdb
[root@rac1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb[2] sdc[1]
524224 blocks [2/1] [_U]
[>....................] recovery = 3.7% (19904/524224) finish=2.5min speed=3317K/sec
unused devices:
[root@rac1 ~]# mdadm -D /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Thu Oct 25 15:28:07 2007
Raid Level : raid1
Array Size : 524224 (511.94 MiB 536.81 MB)
Device Size : 524224 (511.94 MiB 536.81 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Fri Oct 26 10:15:04 2007

State : clean, degraded, recovering
Active Devices : 1
Working Devices : 2
Failed Devices : 0
Spare Devices : 1

Rebuild Status : 12% complete

Number Major Minor RaidDevice State

0 0 0 -1 removed
1 8 32 1 active sync /dev/sdc
2 8 16 0 spare /dev/sdb
UUID : 081c04ac:6cb9278e:35bade9d:49098be4
Events : 0.343
[root@rac1 ~]#

进入目录查看状态:
[root@rac1 ~]# cd /
[root@rac1 /]# mount /dev/md0 /mnt/md0
[root@rac1 /]# cd /mnt/md0
[root@rac1 md0]# ls
lost+found nohup.out rac120071026 rac2 rac2_20071026 test
[root@rac1 md0]# cat rac2
aaaaaaaaaaaaa
[root@rac1 md0]#

一切正常了。

其他命令:

mdadm /dev/md0 -f /dev/sdax
set faulty for sdax

mdadm /dev/md0 -r /dev/sdax

hot remove /dev/sdax from /dev/md0

mdadm /dev/md0 -a /dev/sdax

hot add /dev/sdax to /dev/md0

if the array is full ,new added /dev/sdax will be a spare device

it'll be auto added when a device in array is down

删除已有的software raid:
1.stop /dev/mdX:
mdadm -S /dev/mdX
or
rm /dev/mdX
2.del /etc/mdadm.conf
3.del raid mount in /etc/fstab and autofs
4.del raid part use fdisk or parted

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/312079/viewspace-245789/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/312079/viewspace-245789/

你可能感兴趣的文章
浙江省高考志愿填报志愿文档_成为freeCodeCamp的志愿者编辑的一年如何改变了我的生活
查看>>
批量删除推文_如何批量(免费)删除过去的推文,以及如何摆脱过去的自我
查看>>
Elasticsearch初学者教程
查看>>
初学者应该学c++与c#_面向初学者的完整C#课程
查看>>
vue.js快速入门_Vue.js快速介绍
查看>>
web前端的发展简史_前端框架简史
查看>>
this 上下文_当“ this”失去上下文时该怎么办
查看>>
kubernetes 介绍_Kubernetes的友好介绍
查看>>
bug探索_探索一流功能的力量
查看>>
如何避免您的网站在Twitter和Facebook上的可耻外观
查看>>
导入样机_如何开始构建Android应用程序:创建样机,UI和XML布局
查看>>
最先进的深度学习:Mask R-CNN简介
查看>>
css参考手册css3手册_CSS手册:面向开发人员CSS便捷指南
查看>>
react 中国际化_从头到尾如何在React中设置国际化
查看>>
自学真的很难成才吗_对于自学成才的开发人员而言真正有用的职业资源
查看>>
bulma.css_在5分钟内学习Bulma CSS-初学者教程
查看>>
如何快速设置您的ES6环境
查看>>
深圳哪个区的it工作多_如何创建虚拟IT工作区
查看>>
组件和高阶组件区别_高阶组件:终极指南
查看>>
如何知道Kubernetes是否适合您的SaaS
查看>>