有时我们需要把从两台不同机器上输出的iSCSI硬盘输出到另一台机器,为了保证高可用,我们可以把这两块iSCSI硬盘做一个软Raid。但当我们重启 这台机器后,再运行iscsi的挂盘的时候,当login***个iSCSI Target时,刚把***块硬盘识别出来后,就发现软Raid自动重组出来的,但自动重组出来的MDRaid,因为底层只有一块硬盘,所以处于降级状态, 如下所示:
- root@ubuntu01:~# iscsiadm -m node -T iqn.2001-04.com.example:serv01 -l
- Logging in to [iface: default, target: iqn.2001-04.com.example:serv01, portal: 192.168.1.4,3260] (multiple)
- Login to [iface: default, target: iqn.2001-04.com.example:serv01, portal: 192.168.1.4,3260] successful.
- root@ubuntu01:~# cat /proc/mdstat
- Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
- md127 : inactive sdb[0](S)
- 511936 blocks
- unused devices: <none>
- root@ubuntu01:~# iscsiadm -m node -T iqn.2001-04.com.example:serv02 -l
- Logging in to [iface: default, target: iqn.2001-04.com.example:serv02, portal: 192.168.1.5,3260] (multiple)
- Login to [iface: default, target: iqn.2001-04.com.example:serv02, portal: 192.168.1.5,3260] successful.
- root@ubuntu01:~# cat /proc/mdstat
- Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
- md127 : active raid1 sdc[1] sdb[0]
- 511936 blocks [2/2] [UU]
- [===>.................] resync = 18.9% (97024/511936) finish=6.6min speed=1024K/sec
- unused devices: <none>
上面可以看出,当我们把***块iSCSI硬盘识别出来后,软Raid就重组出来了,当我们挂第二个iSCSI硬盘盘,就会出现数据同步。所以,我们需要自己重组软Raid,避免出现的降级情况和数据同步的情况。禁止MDRaid自动重组的功能。方法如下:编辑配置文件/etc/default/mdadm:
- AUTOCHECK=false
- START_DAEMON=false
在/etc/mdadm/mdadm.conf文件中增加一行:
- AUTO -all
这时,我们手工重组软Raid,就不会出现降级和数据同步的情况了:
- root@ubuntu01:~# iscsiadm -m discovery -t st -p 192.168.1.4
- 192.168.1.4:3260,1 iqn.2001-04.com.example:serv01
- root@ubuntu01:~# iscsiadm -m discovery -t st -p 192.168.1.5
- 192.168.1.5:3260,1 iqn.2001-04.com.example:serv02
- root@ubuntu01:~# iscsiadm -m node -T iqn.2001-04.com.example:serv01 -l
- Logging in to [iface: default, target: iqn.2001-04.com.example:serv01, portal: 192.168.1.4,3260] (multiple)
- Login to [iface: default, target: iqn.2001-04.com.example:serv01, portal: 192.168.1.4,3260] successful.
- root@ubuntu01:~# cat /proc/mdstat
- Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
- unused devices: <none>
- root@ubuntu01:~# iscsiadm -m node -T iqn.2001-04.com.example:serv02 -l
- Logging in to [iface: default, target: iqn.2001-04.com.example:serv02, portal: 192.168.1.5,3260] (multiple)
- Login to [iface: default, target: iqn.2001-04.com.example:serv02, portal: 192.168.1.5,3260] successful.
- root@ubuntu01:~# cat /proc/mdstat
- Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
- unused devices: <none>
- root@ubuntu01:~# mdadm -A /dev/md/mdtest /dev/sdb /dev/sdc
- mdadm: /dev/md/mdtest has been started with 2 drives.
- root@ubuntu01:~# cat /proc/mdstat
- Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
- md127 : active raid1 sdb[0] sdc[1]
- 511936 blocks [2/2] [UU]
- unused devices: <none>