Ubuntu Server 12.04,MDADM 设备号突然变了?

raz*_*or7 4 server raid mdadm

我遇到了一个非常烦人的错误,我已经用 mdadm 设置了一个软件 RAID1,并且设置结果很好

/dev/md/lucas.mgscreativa.com.ar:0

我也像这样配置了 mdadm.conf

DEVICE /dev/sda /dev/sdb

# auto-create devices with Debian standard permissions CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts MAILADDR root

# definitions of existing MD arrays ARRAY /dev/md/lucas.mgscreativa.com.ar:0 metadata=1.2
name=lucas.mgscreativa.com.ar:0
UUID=c913486a:e62c7ea1:cfb98b6b:253d1f62
Run Code Online (Sandbox Code Playgroud)

和 fstab 这样配置

/dev/md/lucas.mgscreativa.com.ar:0 /media/data     ext4
defaults,noatime      0       0
Run Code Online (Sandbox Code Playgroud)

但是,有一天,我的数组名称突然从 /dev/md/lucas.mgscreativa.com.ar:0 更改为 /dev/md0,因此我对 fstab 和 mdadm.conf 进行了一些更改(当然,在几小时后和数小时的尝试和错误),一切顺利,但今天,再次,MD 编号从 /dev/md0 更改为 /dev/md127 !!!

这里发生了什么?我猜这是一个错误吗。

有什么方法可以修复 MD 编号,以便我的服务器可以正常工作而没有缺陷?

谢谢!

Jim*_*ter 5

第一:您的阵列中可能有错误。 您需要立即检查其状态。

例子:

root@locutus:~# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Fri Jun  1 15:30:31 2012
     Raid Level : raid10
     Array Size : 1953119232 (1862.64 GiB 1999.99 GB)
  Used Dev Size : 976559616 (931.32 GiB 1000.00 GB)
   Raid Devices : 4
  Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Sun Nov 25 21:39:44 2012
          State : clean 
 Active Devices : 4
Working Devices : 4
 Failed Devices : 0
  Spare Devices : 0

         Layout : near=2
     Chunk Size : 512K

           Name : locutus:0  (local to host locutus)
           UUID : b81ac63a:51a9b01c:c01812ec:86c534c4
         Events : 182

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       49        1      active sync   /dev/sdd1
       2       8       17        2      active sync   /dev/sdb1
       3       8       33        3      active sync   /dev/sdc1
Run Code Online (Sandbox Code Playgroud)

你很可能会发现你有错误……那些需要得到解决。

继续,您应该更改 fstab 的设置方式,以使用 UUID 而不是使用设备名称。使用blkid阵列(或阵列下的分区)上的命令获取其 UUID,然后使用该 UUID 将其挂载到 /etc/fstab 中。

例子:

root@locutus:~# blkid /dev/mapper/vg0-root
/dev/mapper/vg0-root: UUID="61998221-7b39-49cd-83f7-62fda973218c" TYPE="ext4" 
Run Code Online (Sandbox Code Playgroud)

有了这些信息,我会将 root 的 /etc/fstab 条目设置为如下所示:

UUID=61998221-7b39-49cd-83f7-62fda973218c    /    ext4    defaults,errors=remount-ro    0    1
Run Code Online (Sandbox Code Playgroud)

完成此操作后,您的系统将找到您的分区,无论它们的设备名称是否更改(例如,如果驱动器电缆被交换)。

您还应该设置/etc/mdadm/mdadm.conf自动查找内容,而无需任何特定驱动器位于任何特定位置:

# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays
ARRAY /dev/md/0 metadata=1.2 UUID=c913486a:e62c7ea1:cfb98b6b:253d1f62 name=lucas.mgscreativa.com.ar:0
Run Code Online (Sandbox Code Playgroud)

请注意,此 CONF 文件中未指定任何设备。 这是一个功能,而不是一个错误。以这种方式设置 mdadm.conf 后,您的系统将自动扫描所有连接的驱动器以查找属于您的阵列的任何内容,并将它们全部组装为 /dev/md0。