扫描期间缺少 mdam RAID1 阵列

扫描期间缺少 mdam RAID1 阵列

我已经构建了一个带有 4 个 HDD 的新服务器(Ubuntu 18.04.1)。

我的计划是整体使用RAID1,经过调查后得出了这种布局:

星展银行安全数据库四个主分区(全部为 fd),sda1/sdb1作为/启动sda2/sdb2作为/sda3/sdb3作为/varsda4/sdb4作为...的一部分/家

南达科他州安全数据表两个主分区(全部作为 fd),sdc1/sdd1作为其余的/家sdc2/sdd2用作交换

目前交换文件位于 /

~$ ls -lart /swapfile 
-rw------- 1 root root 2147483648 aug 17 08:50 /swapfile

我的预期是这个交换文件应该在 md2 上(缺少)。

问题是:我可以用 mdadm 创建一个新阵列并以某种方式让操作系统使用该区域进行交换而不是交换文件吗?

在我的第一次尝试中,我试图在安装期间准备好所有配置,但失败了,而在我的最后一次尝试中,我只在 raid 配置中设置了 /boot 和 /,而没有设置 LVM 配置。

计划的部分按预期工作,但不知何故,以前的尝试留下的残留让我缺少交换分区。

我的意思是 mdadm.conf 中有 swap 条目(此外md0/启动md1/):

ARRAY /dev/md/2  metadata=1.2 UUID=4b13781e:ea3a8209:74173443:77c65a9d name=LOPEZSRV:2

检查 blkid:

~$ sudo blkid
/dev/sdc2: UUID="4b13781e-ea3a-8209-7417-344377c65a9d" UUID_SUB="6ee8ecac-1e75-f5dc-3def-508cba28a512" LABEL="LOPEZSRV:2" TYPE="linux_raid_member" PARTUUID="f260af1c-02"
/dev/sdd2: UUID="4b13781e-ea3a-8209-7417-344377c65a9d" UUID_SUB="3efa76ad-3662-87e6-ed4d-b072cb0e7274" LABEL="LOPEZSRV:2" TYPE="linux_raid_member" PARTUUID="3bce6013-02"

显示它们是数组的成员

还检查细节

~$ sudo mdadm -E /dev/sdc2
/dev/sdc2:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x1
     Array UUID : 4b13781e:ea3a8209:74173443:77c65a9d
           Name : LOPEZSRV:2  (local to host LOPEZSRV)
  Creation Time : Thu Aug 16 14:08:06 2018
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 3906762752 (1862.89 GiB 2000.26 GB)
     Array Size : 1953381376 (1862.89 GiB 2000.26 GB)
    Data Offset : 264192 sectors
   Super Offset : 8 sectors
   Unused Space : before=264112 sectors, after=18446744073701738496 sectors
          State : active
    Device UUID : 6ee8ecac:1e75f5dc:3def508c:ba28a512

Internal Bitmap : 8 sectors from superblock
    Update Time : Thu Aug 16 14:40:25 2018
  Bad Block Log : 512 entries available at offset 16 sectors
       Checksum : 19220d93 - correct
         Events : 393


   Device Role : Active device 0
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)

~$ sudo mdadm -E /dev/sdd2
/dev/sdd2:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x1
     Array UUID : 4b13781e:ea3a8209:74173443:77c65a9d
           Name : LOPEZSRV:2  (local to host LOPEZSRV)
  Creation Time : Thu Aug 16 14:08:06 2018
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 3906762752 (1862.89 GiB 2000.26 GB)
     Array Size : 1953381376 (1862.89 GiB 2000.26 GB)
    Data Offset : 264192 sectors
   Super Offset : 8 sectors
   Unused Space : before=264112 sectors, after=18446744073701738496 sectors
          State : active
    Device UUID : 3efa76ad:366287e6:ed4db072:cb0e7274

Internal Bitmap : 8 sectors from superblock
    Update Time : Thu Aug 16 14:40:25 2018
  Bad Block Log : 512 entries available at offset 16 sectors
       Checksum : 6b6a513d - correct
         Events : 393


   Device Role : Active device 1
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)

但进行扫描时:

~$ sudo mdadm --detail --scan
ARRAY /dev/md/1 metadata=1.2 name=LOPEZSRV:1 UUID=5c7e415a:fe060391:ae611987:474558ec
ARRAY /dev/md/0 metadata=1.2 name=LOPEZSRV:0 UUID=e6a5ed7b:c613d763:e8e6c8a3:8a13ecb1

我只得到数组/启动/

查看 /proc/mdstat:

~$ cat /proc/mdstat 
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md0 : active raid1 sda1[0] sdb1[1]
      1949696 blocks super 1.2 [2/2] [UU]

md1 : active raid1 sdb2[1] sda2[0]
      97589248 blocks super 1.2 [2/2] [UU]

也只显示两个数组/启动/

添加输出:

~$ sudo mdadm --assemble --scan  --verbose 
mdadm: looking for devices for /dev/md/0
mdadm: No super block found on /dev/md/0 (Expected magic a92b4efc, got 000000ef)
mdadm: no RAID superblock on /dev/md/0
mdadm: No super block found on /dev/md/1 (Expected magic a92b4efc, got 0000040d)
mdadm: no RAID superblock on /dev/md/1
mdadm: /dev/sdd2 has wrong uuid.
mdadm: No super block found on /dev/sdd1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdd1
mdadm: No super block found on /dev/sdd (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdd
mdadm: /dev/sdc2 has wrong uuid.
mdadm: No super block found on /dev/sdc1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdc1
mdadm: No super block found on /dev/sdc (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdc
mdadm: No super block found on /dev/sdb4 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdb4
mdadm: No super block found on /dev/sdb3 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdb3
mdadm: /dev/sdb2 has wrong uuid.
mdadm: /dev/sdb1 is busy - skipping
mdadm: No super block found on /dev/sdb (Expected magic a92b4efc, got a0ddb71c)
mdadm: no RAID superblock on /dev/sdb
mdadm: No super block found on /dev/sda4 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sda4
mdadm: No super block found on /dev/sda3 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sda3
mdadm: /dev/sda2 has wrong uuid.
mdadm: /dev/sda1 is busy - skipping
mdadm: No super block found on /dev/sda (Expected magic a92b4efc, got a0ddb71c)
mdadm: no RAID superblock on /dev/sda
mdadm: cannot open device /dev/sr0: No medium found
mdadm: looking for devices for /dev/md/1
mdadm: No super block found on /dev/md/0 (Expected magic a92b4efc, got 000000ef)
mdadm: no RAID superblock on /dev/md/0
mdadm: No super block found on /dev/md/1 (Expected magic a92b4efc, got 0000040d)
mdadm: no RAID superblock on /dev/md/1
mdadm: /dev/sdd2 has wrong uuid.
mdadm: No super block found on /dev/sdd1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdd1
mdadm: No super block found on /dev/sdd (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdd
mdadm: /dev/sdc2 has wrong uuid.
mdadm: No super block found on /dev/sdc1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdc1
mdadm: No super block found on /dev/sdc (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdc
mdadm: No super block found on /dev/sdb4 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdb4
mdadm: No super block found on /dev/sdb3 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdb3
mdadm: /dev/sdb2 is busy - skipping
mdadm: /dev/sdb1 has wrong uuid.
mdadm: No super block found on /dev/sdb (Expected magic a92b4efc, got a0ddb71c)
mdadm: no RAID superblock on /dev/sdb
mdadm: No super block found on /dev/sda4 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sda4
mdadm: No super block found on /dev/sda3 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sda3
mdadm: /dev/sda2 is busy - skipping
mdadm: /dev/sda1 has wrong uuid.
mdadm: No super block found on /dev/sda (Expected magic a92b4efc, got a0ddb71c)
mdadm: no RAID superblock on /dev/sda
mdadm: cannot open device /dev/sr0: No medium found
mdadm: looking for devices for /dev/md/2
mdadm: No super block found on /dev/md/0 (Expected magic a92b4efc, got 000000ef)
mdadm: no RAID superblock on /dev/md/0
mdadm: No super block found on /dev/md/1 (Expected magic a92b4efc, got 0000040d)
mdadm: no RAID superblock on /dev/md/1
mdadm: No super block found on /dev/sdd1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdd1
mdadm: No super block found on /dev/sdd (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdd
mdadm: No super block found on /dev/sdc1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdc1
mdadm: No super block found on /dev/sdc (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdc
mdadm: No super block found on /dev/sdb4 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdb4
mdadm: No super block found on /dev/sdb3 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdb3
mdadm: /dev/sdb2 has wrong uuid.
mdadm: /dev/sdb1 has wrong uuid.
mdadm: No super block found on /dev/sdb (Expected magic a92b4efc, got a0ddb71c)
mdadm: no RAID superblock on /dev/sdb
mdadm: No super block found on /dev/sda4 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sda4
mdadm: No super block found on /dev/sda3 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sda3
mdadm: /dev/sda2 has wrong uuid.
mdadm: /dev/sda1 has wrong uuid.
mdadm: No super block found on /dev/sda (Expected magic a92b4efc, got a0ddb71c)
mdadm: no RAID superblock on /dev/sda
mdadm: cannot open device /dev/sr0: No medium found
mdadm: /dev/sdd2 is identified as a member of /dev/md/2, slot 1.
mdadm: /dev/sdc2 is identified as a member of /dev/md/2, slot 0.
mdadm: failed to add /dev/sdd2 to /dev/md/2: Invalid argument
mdadm: failed to add /dev/sdc2 to /dev/md/2: Invalid argument
mdadm: failed to RUN_ARRAY /dev/md/2: Invalid argument

~$ sudo mdadm --assemble /dev/md2 --uuid=4b13781e:ea3a8209:74173443:77c65a9d --verbose
mdadm: looking for devices for /dev/md2
mdadm: no recogniseable superblock on /dev/md/0
mdadm: no recogniseable superblock on /dev/md/1
mdadm: No super block found on /dev/sdd1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdd1
mdadm: No super block found on /dev/sdd (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdd
mdadm: No super block found on /dev/sdc1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdc1
mdadm: No super block found on /dev/sdc (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdc
mdadm: No super block found on /dev/sdb4 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdb4
mdadm: No super block found on /dev/sdb3 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdb3
mdadm: /dev/sdb2 has wrong uuid.
mdadm: /dev/sdb1 has wrong uuid.
mdadm: No super block found on /dev/sdb (Expected magic a92b4efc, got a0ddb71c)
mdadm: no RAID superblock on /dev/sdb
mdadm: No super block found on /dev/sda4 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sda4
mdadm: No super block found on /dev/sda3 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sda3
mdadm: /dev/sda2 has wrong uuid.
mdadm: /dev/sda1 has wrong uuid.
mdadm: No super block found on /dev/sda (Expected magic a92b4efc, got a0ddb71c)
mdadm: no RAID superblock on /dev/sda
mdadm: cannot open device /dev/sr0: No medium found
mdadm: /dev/sdd2 is identified as a member of /dev/md2, slot 1.
mdadm: /dev/sdc2 is identified as a member of /dev/md2, slot 0.
mdadm: failed to add /dev/sdd2 to /dev/md2: Invalid argument
mdadm: failed to add /dev/sdc2 to /dev/md2: Invalid argument
mdadm: failed to RUN_ARRAY /dev/md2: Invalid argument

~$ cat /proc/mdstat 
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md0 : active raid1 sda1[0] sdb1[1]
      1949696 blocks super 1.2 [2/2] [UU]

md1 : active raid1 sdb2[1] sda2[0]
      97589248 blocks super 1.2 [2/2] [UU]

unused devices: <none>

~$ sudo modprobe raid1
~$ sudo mdadm --assemble /dev/md2 --uuid=4b13781e:ea3a8209:74173443:77c65a9d --verbose --force --update=summaries
mdadm: looking for devices for /dev/md2
mdadm: no recogniseable superblock on /dev/md/0
mdadm: no recogniseable superblock on /dev/md/1
mdadm: No super block found on /dev/sdd1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdd1
mdadm: No super block found on /dev/sdd (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdd
mdadm: No super block found on /dev/sdc1 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdc1
mdadm: No super block found on /dev/sdc (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdc
mdadm: No super block found on /dev/sdb4 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdb4
mdadm: No super block found on /dev/sdb3 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sdb3
mdadm: /dev/sdb2 has wrong uuid.
mdadm: /dev/sdb1 has wrong uuid.
mdadm: No super block found on /dev/sdb (Expected magic a92b4efc, got a0ddb71c)
mdadm: no RAID superblock on /dev/sdb
mdadm: No super block found on /dev/sda4 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sda4
mdadm: No super block found on /dev/sda3 (Expected magic a92b4efc, got 00000000)
mdadm: no RAID superblock on /dev/sda3
mdadm: /dev/sda2 has wrong uuid.
mdadm: /dev/sda1 has wrong uuid.
mdadm: No super block found on /dev/sda (Expected magic a92b4efc, got a0ddb71c)
mdadm: no RAID superblock on /dev/sda
mdadm: cannot open device /dev/sr0: No medium found
mdadm: --update=summaries not understood for 1.x metadata
double free or corruption (!prev)
Avbruten (SIGABRT)

~$ dmesg    
[lör aug 18 08:35:54 2018] md: md2 stopped.
[lör aug 18 08:35:54 2018] md: sdd2 does not have a valid v1.2 superblock, not importing!
[lör aug 18 08:35:54 2018] md: md_import_device returned -22
[lör aug 18 08:35:54 2018] md: md2 stopped.

答案1

要组装不在 /etc/mdadm.conf 中的驱动器,可以使用mdadm --assemble --scan。此命令将让 mdam 查看 mdadm 阵列中未激活的所有驱动器并搜索 mdadm 超级块。如果发现 mdadm 超级块,并且具有相同的 UUID,mdadm 将尝试自动组装阵列。正如 blkid 的输出显示 uuid 相同一样,此过程应该可以解决您的问题。

你试过了mdadm --assemble --scan吗 ?

答案2

要禁用交换文件,您可以执行以下操作而无需重新启动: swapoff /your/path/to/swapfile并从中删除交换条目/etc/fstab。如果您的机器负载过大并使用交换,则在运行之前必须小心swapoff。根据交换的使用率和可用内存量swapoff可能会引起麻烦。

重新启动:删除相应的行/etc/fstab并重新启动。

要添加新的交换驱动器,您需要mkswap /dev/yourswapdriveswapon /dev/yourswapdrive以及一行/etc/fstab以在启动时启用交换。

(对于您来说,只需在 /etc/fstab 中将 /your/path/to/swapfile 替换为 /dev/yourswapdrive 即可。)

答案3

现在,在 hargut 的帮助下,无法重新组装阵列的问题已经得到解决。

必须删除 /dev/sdc2、/dev/sdd2 中的旧超级块,然后继续创建新的阵列。

~$ sudo mdadm --zero-superblock /dev/sdc2
~$ sudo mdadm --zero-superblock /dev/sdd2
~$ sudo mdadm --create /dev/md2 --level=mirror --raid-devices=2 /dev/sd[c-d]1
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.
~$ sudo mdadm --create /dev/md3 --level=mirror --raid-devices=2 /dev/sd[c-d]2
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md3 started.
~$ sudo mdadm --detail --scan
ARRAY /dev/md/1 metadata=1.2 name=LOPEZSRV:1 UUID=5c7e415a:fe060391:ae611987:474558ec
ARRAY /dev/md/0 metadata=1.2 name=LOPEZSRV:0 UUID=e6a5ed7b:c613d763:e8e6c8a3:8a13ecb1
ARRAY /dev/md2 metadata=1.2 name=LOPEZSRV:2 UUID=73164a72:102df9c1:7a67a2f1:024f733d
ARRAY /dev/md3 metadata=1.2 name=LOPEZSRV:3 UUID=1aeb2b00:f47e62bb:add9da71:60799799
~$ cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md3 : active raid1 sdd2[1] sdc2[0]
      1949474816 blocks super 1.2 [2/2] [UU]
      [===>.................]  resync = 16.8% (328936512/1949474816) finish=216.5min speed=124710K/sec
      bitmap: 15/15 pages [60KB], 65536KB chunk

md2 : active raid1 sdd1[1] sdc1[0]
      3903488 blocks super 1.2 [2/2] [UU]

md0 : active raid1 sda1[0] sdb1[1]
      1949696 blocks super 1.2 [2/2] [UU]

md1 : active raid1 sdb2[1] sda2[0]
      97589248 blocks super 1.2 [2/2] [UU]

unused devices: <none>

因为我是新手,所以我对不同的 ARRAY 路径一无所知。

从安装我得到了

  • 数组 /dev/md/0 表示 dev/md0

  • 数组 /dev/md/1 代表 /dev/md1

但在手动创建数组时我得到了

  • 数组 /dev/md2 代表 /dev/md2

  • 数组 /dev/md3 代表 /dev/md3

但我认为这并不重要。

我将使用新的阵列更新 mdadm.conf。

现在我只需要再等待 216 分钟,然后才能进行 swapoff/swapon 操作。

相关内容