Правильно ли я делаю восстановление soft raid на CentOS 7.1?

Добрый день!


Есть вопросы по soft raid на CentOS:
Правильно ли я провожу восстановление системы ?
Иногда после удаления диска и восстановления отпадает swap или иной раздел. В чем может быть дело. Ниже пример, когда swap отпал.

Стартовая конфигурация:
Виртуальная среда, два диска - sda,sdb по 10Gb. При установке CentOS 7.1 поднят RAID-1 на MD.


[root@centos7 ~]# fdisk -l

Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000953af

Device Boot Start End Blocks Id System
/dev/sdb1 2048 4200447 2099200 fd Linux raid autodetect
/dev/sdb2 * 4200448 6299647 1049600 fd Linux raid autodetect
/dev/sdb3 6299648 20971519 7335936 fd Linux raid autodetect

Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000e028d

Device Boot Start End Blocks Id System
/dev/sda1 2048 4200447 2099200 fd Linux raid autodetect
/dev/sda2 * 4200448 6299647 1049600 fd Linux raid autodetect
/dev/sda3 6299648 20971519 7335936 fd Linux raid autodetect

Disk /dev/md127: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/md126: 7507 MB, 7507804160 bytes, 14663680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/md125: 1074 MB, 1074724864 bytes, 2099072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@centos7 ~]#

[root@centos7 ~]# cat /proc/mdstat
Personalities : [raid1]
md125 : active raid1 sdb2[1] sda2[0]
1049536 blocks super 1.0 [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk

md126 : active raid1 sdb3[1] sda3[0]
7331840 blocks super 1.2 [2/2] [UU]
bitmap: 1/1 pages [4KB], 65536KB chunk

md127 : active raid1 sdb1[1] sda1[0]
2097152 blocks super 1.2 [2/2] [UU]

unused devices:

[root@centos7 ~]# mount | grep md1
/dev/md126 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/md125 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
[root@centos7 ~]#

/dev/md126 - swap.


Отключаем в гипервизоре диск sdb, делаем find . / , swapoff -a , swapon чтобы изобразить дисковый обмен и видим:

[root@centos7 var]# cat /proc/mdstat
Personalities : [raid1]
md125 : active raid1 sdb2[1](F) sda2[0]
1049536 blocks super 1.0 [2/1] [U_]
bitmap: 1/1 pages [4KB], 65536KB chunk

md126 : active raid1 sdb3[1](F) sda3[0]
7331840 blocks super 1.2 [2/1] [U_]
bitmap: 1/1 pages [4KB], 65536KB chunk

md127 : active raid1 sdb1[1](F) sda1[0]
2097152 blocks super 1.2 [2/1] [U_]

unused devices:
[root@centos7 var]#
[root@centos7 var]#


Вроде бы все хорошо, везде пропали диски sdb, кроме swap

Делаем shutdown машины, опять добавляем sdb и включаем ее.

[root@centos7 ~]# fdisk -l | grep sd
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
/dev/sda1 2048 4200447 2099200 fd Linux raid autodetect
/dev/sda2 * 4200448 6299647 1049600 fd Linux raid autodetect
/dev/sda3 6299648 20971519 7335936 fd Linux raid autodetect
[root@centos7 ~]#


Видно, что появился неразмеченный диск /dev/sdb
Копирую файловую систему:

[root@centos7 ~]# sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdb: 1305 cylinders, 255 heads, 63 sectors/track
sfdisk: /dev/sdb: unrecognized partition table type

Old situation:
sfdisk: No partitions found

New situation:
Units: sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System
/dev/sdb1 2048 4200447 4198400 fd Linux raid autodetect
/dev/sdb2 * 4200448 6299647 2099200 fd Linux raid autodetect
/dev/sdb3 6299648 20971519 14671872 fd Linux raid autodetect
/dev/sdb4 0 - 0 0 Empty
Warning: partition 1 does not end at a cylinder boundary
Warning: partition 2 does not start at a cylinder boundary
Warning: partition 2 does not end at a cylinder boundary
Warning: partition 3 does not start at a cylinder boundary
Warning: partition 3 does not end at a cylinder boundary
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
[root@centos7 ~]#

Добавляем резервные разделы к массиву:
[root@centos7 ~]# mdadm /dev/md125 -a /dev/sdb3
mdadm: added /dev/sdb3
[root@centos7 ~]# mdadm /dev/md126 -a /dev/sdb2
mdadm: added /dev/sdb2
[root@centos7 ~]# mdadm /dev/md127 -a /dev/sdb1
mdadm: added /dev/sdb1
[root@centos7 ~]#

Начинается синхронизация:
[root@centos7 ~]# cat /proc/mdstat
Personalities : [raid1]
md125 : active raid1 sdb3[2] sda3[0]
7331840 blocks super 1.2 [2/1] [U_]
[=====>...............] recovery = 25.3% (1858432/7331840) finish=3.3min speed=27190K/sec
bitmap: 1/1 pages [4KB], 65536KB chunk

md126 : active raid1 sdb2[2] sda2[0]
1049536 blocks super 1.0 [2/1] [U_]
resync=DELAYED
bitmap: 1/1 pages [4KB], 65536KB chunk

md127 : active raid1 sdb1[2] sda1[0]
2097152 blocks super 1.2 [2/1] [U_]
resync=DELAYED

unused devices:
[root@centos7 ~]#

Все закончилось успешно:
[root@centos7 ~]# cat /proc/mdstat
Personalities : [raid1]
md125 : active raid1 sdb3[2] sda3[0]
7331840 blocks super 1.2 [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk

md126 : active raid1 sdb2[2] sda2[0]
1049536 blocks super 1.0 [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk

md127 : active raid1 sdb1[2] sda1[0]
2097152 blocks super 1.2 [2/2] [UU]

unused devices:
[root@centos7 ~]#

Обновляем загрузчики
[root@centos7 ~]# grub2-install /dev/sda
Installing for i386-pc platform.
grub2-install: warning: Couldn't find physical volume ‘(null)’. Some modules may be missing from core image..
grub2-install: warning: Couldn't find physical volume ‘(null)’. Some modules may be missing from core image..
Installation finished. No error reported.
[root@centos7 ~]# grub2-install /dev/sdb
Installing for i386-pc platform.
grub2-install: warning: Couldn't find physical volume ‘(null)’. Some modules may be missing from core image..
grub2-install: warning: Couldn't find physical volume ‘(null)’. Some modules may be missing from core image..
Installation finished. No error reported.
[root@centos7 ~]#


Останавливаем систему, отключаем удаляем первый диск и пробуем загрузиться. Грузится, но не 5-7 сек, а более 1 минуты, долго ползет полоса внизу.
Грузится dracut-033.. и т.д. (Initramfs)

После загрузки делаем reboot и получаем:


[root@centos7 ~]# cat /proc/mdstat
Personalities : [raid1]
md125 : active raid1 sda3[2]
7331840 blocks super 1.2 [2/1] [_U]
bitmap: 1/1 pages [4KB], 65536KB chunk

md126 : active raid1 sda2[2]
1049536 blocks super 1.0 [2/1] [_U]
bitmap: 1/1 pages [4KB], 65536KB chunk

md127 : inactive sda1[2](S)
2097152 blocks super 1.2

unused devices:
[root@centos7 ~]#
[root@centos7 ~]#


Т.е. swap отъехал... Напомню, я удалил первый диск... И диск, который мы сейчас видим как sda, ранее был sdb.
  • Вопрос задан
  • 2363 просмотра
Пригласить эксперта
Ответы на вопрос 2
Frankenstine
@Frankenstine
Сисадмин
Не очень понятно что вы тут творите, но у меня ощущение, что вы забыли
1) пометить отключаемый диск как нерабочий
mdadm --manage /dev/md125 --fail /dev/sdb2
2) удалить его из массива
mdadm --manage /dev/md125 --remove /dev/sdb2
перед тем, как подключать "новый" диск.

Хотя возможно что у вас проблема совсем не в том, а в том что при отключении диска в гипервизоре, на нём рушится таблица разделов (чего не должно быть в случае физического отключения реального диска).
Ответ написан
@Linevo Автор вопроса
А вот тут на что grub2-mkconfig и grub2-install ругаются ? Насколько это критично ?

При этом sda висит на SCSI 0:0 , а sdb на 0:1 - загрузка происходит быстро и нормально. FS на месте.
Если остановить машину и поменять диски местами, то тоже все хорошо.
В этом примере уже другая машина - / - 2G , swap - 1G.

[root@centos7 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
/usr/sbin/grub2-probe: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
Found linux image: /boot/vmlinuz-3.10.0-327.13.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.13.1.el7.x86_64.img
/usr/sbin/grub2-probe: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
/usr/sbin/grub2-probe: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
/usr/sbin/grub2-probe: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-fc6a64c41e2e4536b262a8c9cf31abd0
Found initrd image: /boot/initramfs-0-rescue-fc6a64c41e2e4536b262a8c9cf31abd0.img
/usr/sbin/grub2-probe: warning: Couldn't find physical volume `(null)'. Some modules may be missing from core image..
done
[root@centos7 ~]# grub2-install /dev/sda
Installing for i386-pc platform.
grub2-install: warning: Couldn't find physical volume ‘(null)’. Some modules may be missing from core image..
grub2-install: warning: Couldn't find physical volume ‘(null)’. Some modules may be missing from core image..
Installation finished. No error reported.
[root@centos7 ~]# grub2-install /dev/sdb
Installing for i386-pc platform.
grub2-install: warning: Couldn't find physical volume ‘(null)’. Some modules may be missing from core image..
grub2-install: warning: Couldn't find physical volume ‘(null)’. Some modules may be missing from core image..
Installation finished. No error reported.
[root@centos7 ~]#

[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]# fdisk -l

Disk /dev/sdb: 3221 MB, 3221225472 bytes, 6291456 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 4200447 2099200 fd Linux raid autodetect
/dev/sdb2 4200448 6291455 1045504 fd Linux raid autodetect

Disk /dev/sda: 3221 MB, 3221225472 bytes, 6291456 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 4200447 2099200 fd Linux raid autodetect
/dev/sda2 4200448 6291455 1045504 fd Linux raid autodetect

Disk /dev/md127: 1070 MB, 1070006272 bytes, 2089856 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/md126: 2149 MB, 2149515264 bytes, 4198272 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@centos7 ~]#
[root@centos7 ~]# cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sdb1[2] sda1[3]
2099136 blocks super 1.0 [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk

md127 : active raid1 sdb2[2] sda2[3]
1044928 blocks super 1.2 [2/2] [UU]

unused devices:
[root@centos7 ~]#
[root@centos7 ~]# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=932904k,nr_inodes=233226,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/md126 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=30,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=188440k,mode=700)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
[root@centos7 ~]#
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы