VirtualBoxで動かしていた旧いサーバをディスクエラーから救出する
出張中に、旧いサーバが動かなくなったということで復旧の依頼がありました。
何も機材が無かったのですが、ありあわせの機材で何とかなりました。
久しぶりにストレージ障害を ddrescue で復旧したのでまとめ。
環境
- ホストOS Debian GNU/Linux 7
- VirtualBox
- ゲストOS Scientific Linux 6
- PostgreSQL
障害ストレージは 1TBytes の SATA HDD (Seagate ST1000DM003) 。 単一のストレージで運用していました。
救出用ストレージとして、2TBytes の HDD (TOSHIBA DT01ACA2) を用意。
診断
ホストOSは起動するけれどもゲストOSがVirtualBox上で起動しない。
ゲストOS上で /var/log/messages に記録されていました。
同様に、ホストOSにも記録がされていました。
Nov 20 07:17:01 penguinoffice /USR/SBIN/CRON[23461]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Nov 20 08:17:01 penguinoffice /USR/SBIN/CRON[23483]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Nov 20 08:51:14 penguinoffice kernel: [19251136.414265] ata6.00: exception Emask 0x0 SAct 0x180000 SErr 0x0 action 0x0
Nov 20 08:51:14 penguinoffice kernel: [19251136.414268] ata6.00: irq_stat 0x40000008
Nov 20 08:51:14 penguinoffice kernel: [19251136.414271] ata6.00: failed command: READ FPDMA QUEUED
Nov 20 08:51:14 penguinoffice kernel: [19251136.414275] ata6.00: cmd 60/20:98:90:fd:62/00:00:01:00:00/40 tag 19 ncq 16384 in
Nov 20 08:51:14 penguinoffice kernel: [19251136.414275] res 41/40:20:a0:fd:62/00:00:01:00:00/00 Emask 0x409 (media error) <F>
Nov 20 08:51:14 penguinoffice kernel: [19251136.414277] ata6.00: status: { DRDY ERR }
Nov 20 08:51:14 penguinoffice kernel: [19251136.414278] ata6.00: error: { UNC }
Nov 20 08:51:14 penguinoffice kernel: [19251136.414979] ata6.00: supports DRM functions and may not be fully accessible
Nov 20 08:51:14 penguinoffice kernel: [19251136.415923] ata6.00: supports DRM functions and may not be fully accessible
Nov 20 08:51:14 penguinoffice kernel: [19251136.416098] ata6.00: configured for UDMA/133
Nov 20 08:51:14 penguinoffice kernel: [19251136.416103] ata6: EH complete
Nov 20 08:51:18 penguinoffice kernel: [19251140.067322] ata6.00: exception Emask 0x0 SAct 0x400000 SErr 0x0 action 0x0
Nov 20 08:51:18 penguinoffice kernel: [19251140.067325] ata6.00: irq_stat 0x40000008
Nov 20 08:51:18 penguinoffice kernel: [19251140.067328] ata6.00: failed command: READ FPDMA QUEUED
Nov 20 08:51:18 penguinoffice kernel: [19251140.067332] ata6.00: cmd 60/20:b0:90:fd:62/00:00:01:00:00/40 tag 22 ncq 16384 in
Nov 20 08:51:18 penguinoffice kernel: [19251140.067333] res 41/40:20:a0:fd:62/00:00:01:00:00/00 Emask 0x409 (media error) <F>
Nov 20 08:51:18 penguinoffice kernel: [19251140.067334] ata6.00: status: { DRDY ERR }
Nov 20 08:51:18 penguinoffice kernel: [19251140.067335] ata6.00: error: { UNC }
Nov 20 08:51:18 penguinoffice kernel: [19251140.068045] ata6.00: supports DRM functions and may not be fully accessible
Nov 20 08:51:18 penguinoffice kernel: [19251140.068972] ata6.00: supports DRM functions and may not be fully accessible
Nov 20 08:51:18 penguinoffice kernel: [19251140.069148] ata6.00: configured for UDMA/133
Nov 20 08:51:18 penguinoffice kernel: [19251140.069153] ata6: EH complete
Nov 20 09:10:01 penguinoffice kernel: [19252262.806139] EXT4-fs (sda2): Unaligned AIO/DIO on inode 51904712 by AioMgr0-N; performance will be poor.
Nov 20 09:17:01 penguinoffice /USR/SBIN/CRON[23504]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Nov 20 10:17:01 penguinoffice /USR/SBIN/CRON[23526]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Nov 20 11:17:01 penguinoffice /USR/SBIN/CRON[23548]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Nov 20 12:17:01 penguinoffice /USR/SBIN/CRON[23580]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Nov 20 13:01:07 penguinoffice kernel: [19266123.424239] ata6.00: exception Emask 0x0 SAct 0xe000 SErr 0x0 action 0x0
Nov 20 13:01:07 penguinoffice kernel: [19266123.424242] ata6.00: irq_stat 0x40000008
Nov 20 13:01:07 penguinoffice kernel: [19266123.424245] ata6.00: failed command: READ FPDMA QUEUED
Nov 20 13:01:07 penguinoffice kernel: [19266123.424249] ata6.00: cmd 60/08:68:78:a1:a7/00:00:01:00:00/40 tag 13 ncq 4096 in
Nov 20 13:01:07 penguinoffice kernel: [19266123.424250] res 41/40:08:78:a1:a7/00:00:01:00:00/00 Emask 0x409 (media error) <F>
Nov 20 13:01:07 penguinoffice kernel: [19266123.424251] ata6.00: status: { DRDY ERR }
Nov 20 13:01:07 penguinoffice kernel: [19266123.424252] ata6.00: error: { UNC }
Nov 20 13:01:07 penguinoffice kernel: [19266123.425006] ata6.00: supports DRM functions and may not be fully accessible
Nov 20 13:01:07 penguinoffice kernel: [19266123.425940] ata6.00: supports DRM functions and may not be fully accessible
Nov 20 13:01:07 penguinoffice kernel: [19266123.426124] ata6.00: configured for UDMA/133
Nov 20 13:01:07 penguinoffice kernel: [19266123.426130] ata6: EH complete
Nov 20 13:01:15 penguinoffice kernel: [19266132.009225] ata6.00: qc timeout (cmd 0x2f)
Nov 20 13:01:15 penguinoffice kernel: [19266132.009232] ata6: failed to read log page 10h (errno=-5)
Nov 20 13:01:15 penguinoffice kernel: [19266132.009236] ata6.00: exception Emask 0x1 SAct 0x7c0000 SErr 0x0 action 0x6 frozen
Nov 20 13:01:15 penguinoffice kernel: [19266132.009238] ata6.00: irq_stat 0x40000008
Nov 20 13:01:15 penguinoffice kernel: [19266132.009241] ata6.00: failed command: READ FPDMA QUEUED
Nov 20 13:01:15 penguinoffice kernel: [19266132.009245] ata6.00: cmd 60/08:90:78:a1:a7/00:00:01:00:00/40 tag 18 ncq 4096 in
Nov 20 13:01:15 penguinoffice kernel: [19266132.009245] res 40/00:90:78:a1:a7/00:00:01:00:00/40 Emask 0x1 (device error)
Nov 20 13:01:15 penguinoffice kernel: [19266132.009247] ata6.00: status: { DRDY }
Nov 20 13:01:15 penguinoffice kernel: [19266132.009248] ata6.00: failed command: WRITE FPDMA QUEUED
Nov 20 13:01:15 penguinoffice kernel: [19266132.009251] ata6.00: cmd 61/08:98:78:f5:16/00:00:63:00:00/40 tag 19 ncq 4096 out
Nov 20 13:01:15 penguinoffice kernel: [19266132.009252] res 40/00:90:78:a1:a7/00:00:01:00:00/40 Emask 0x1 (device error)
Nov 20 13:01:15 penguinoffice kernel: [19266132.009254] ata6.00: status: { DRDY }
Nov 20 13:01:15 penguinoffice kernel: [19266132.009255] ata6.00: failed command: WRITE FPDMA QUEUED
Nov 20 13:01:15 penguinoffice kernel: [19266132.009258] ata6.00: cmd 61/08:a0:40:45:bf/00:00:01:00:00/40 tag 20 ncq 4096 out
Nov 20 13:01:15 penguinoffice kernel: [19266132.009258] res 40/00:90:78:a1:a7/00:00:01:00:00/40 Emask 0x1 (device error)
Nov 20 13:01:15 penguinoffice kernel: [19266132.009260] ata6.00: status: { DRDY }
Nov 20 13:01:15 penguinoffice kernel: [19266132.009261] ata6.00: failed command: WRITE FPDMA QUEUED
救出用マシンを作成
Ubuntu 20.04 を適当なマシンにインストール、障害ストレージと救出用ストレージを接続しました。
また、以下をインストールしています。
- VirtualBox
- ddrescue ( gddrescue )
イメージコピー
ddrescue を使用しました。Ubuntu のパッケージに入っているのは gddrescue です。
# export SOURCE=/dev/sdb
# export DIST=/dev/sdc
# ddrescue $SOURCE $DIST 20201129.map --force
操作ミス防止のために一旦環境変数に入れて操作しています。
リードエラー1628を伴ってコピーできました。
実は、これより先に同様のやりかたでコピー先をイメージファイルにして操作しましたが、 loopback マウントがうまくいかなかったので、物理デバイス同士で取り直しました。
必要なファイルの退避
リードオンリーとしてマウントして、必要なファイルをコピー
# mount /dev/sdc2 /mnt/sdc2 -o ro
コピーしたもの
- "VirtualBox VMs" フォルダ
- SL-65-x86_64_2014-01-17-Install-DVD.iso
VirtualBox 操作
まず、コピーした SL-65-x86_64_2014-01-17-Install-DVD.iso を使って Scientifix Linux の仮想マシンを新たに作ります。
ここで、ありあわせの機材だったのでBIOSを以下のように設定し直す必要がありました。
これを確認せずに起動しようとして以下のようにエラーが出たりしてあれれ?? と戸惑いました。
上記を修正し、無事インストールできました。
新ゲストマシンに必要なプログラムをインストール
VboxGuestAdditionとそれに必要なプログラムをインストール
- yum install gcc kernel-devel kernel-headers dkms make bzip2
- yum update kernel*
- reboot
- CD内のインストーラを起動
旧サーバのサービスに必要なプログラムをインストール
# yum install nkf httpd
# yum install postgresql
# yum install php-pgsql php php-mbstring
# yum install postgresql-server
上記プログラムの設定は適宜しておきます。
VirtualBox 上で仮想ディスクを mount する
$ mount /dev/VolGroup2014/lv_root /mnt/lv_root
必要なファイルを救出
# cd /mnt/lv_root/var
# cp -a www/html /var/www
# cp -a lib/pgsql /var/lib
postgresql のデータの損傷
# /etc/init.d/postgresql start
$ mount /dev/VolGroup2014/lv_root /mnt/lv_root
# cd /mnt/lv_root/var
# cp -a www/html /var/www
# cp -a lib/pgsql /var/lib
postgresql のデータの損傷
# /etc/init.d/postgresql start
# /etc/init.d/postgresql start
とするとエラーが起こる。
# su - postgres
として、
$ postmaster -p 5432
とするとサービスが起動した。
$ psql
としてもエラーとなるが、
$ psql -d [データベース名]
とすると接続できたのでダンプ。
データベースを退避してたオリジナルに切り替えて、ダンプを取り込むと復旧できた。
運の良いことに、データベースデータは問題がありませんでした。
Author And Source
この問題について(VirtualBoxで動かしていた旧いサーバをディスクエラーから救出する), 我々は、より多くの情報をここで見つけました https://qiita.com/nanbuwks/items/59e96d2921f6f70aaa41著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .