接上一篇(測試--mdadm用iscsi硬碟和本機硬碟建立raid)

tonykorn97發表於2007-10-26
正常情況下模擬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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章