1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Window 11 virtualboxでmongoDBが起動できない: mongod.service: Failed with result 'core-dump'.

Posted at

問題背景

AMD製CPU Windows 11マシンのVirtualBox instanceをexportして、Intel製CPUのWindows 11マシンでimportした時、MongoDBが起動失敗のエラーが出てきた。

前にAMD製CPUのマシンでも、MongoDBが起動失敗したこともあり、その時はWindows のHyper-Vなど仮想関係機能を無効化にしたことで、解決した。今度は同じようなことをしても、なかなか解決できなかった。

環境

OS:Windows 11 pro
VirtualBox:7.0.6
guetsOS:Almalinux 8

エラー

$ sudo systemctl status mongod
● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: failed (Result: core-dump) since Fri 2023-09-29 20:37:20 JST; 3s ago
     Docs: https://docs.mongodb.org/manual
  Process: 10371 ExecStart=/usr/bin/mongod $OPTIONS (code=dumped, signal=ILL)
 Main PID: 10371 (code=dumped, signal=ILL)

 9月 29 20:37:20 local systemd[1]: Started MongoDB Database Server.
 9月 29 20:37:20 local systemd[1]: mongod.service: Main process exited, code=dumped, status=4/ILL
 9月 29 20:37:20 local systemd[1]: mongod.service: Failed with result 'core-dump'.

結論

最初はCPU環境の互換性に問題があったかと思ったが、実は今度もWindows Hyper-V機能とvirtualboxが共存できないことが原因だった。

だた今度はHyper-V機能を完全無効化にできなかったせいで、最初は解決できなかった。

Windows 11 でたくさんのサービスがHyper-V機能を使っていて、それらのサービスを全部無効化するまで、[Windowsの機能の有効化または無効化]からHyper-Vなどをチェック外すことだけで、なかなか完全無効化にできないそうだ。

原因

MongoDB Communityでの回答によると、

通常、Hyper-VはVirtualboxをブロックする。Hyper-Vはタイプ1のハイパーバイザーで、OSが動作する前にまずハードウェアにアクセスするため、タイプ2のハイパーバイザーであるVirtualboxのような「仮想化技術」を必要とする他のプログラムを妨げる。

Virtualboxが妨害された証拠としては、VBox.logの中に、VT-x is not availableNo hardware-virtualization capability detectedというログが入っていること。

00:00:00.735901 ********************* End of CFGM dump **********************
00:00:00.736113 HM: HMR3Init: Attempting fall back to NEM: VT-x is not available
00:00:00.806370 NEM:  info: Found optional import WinHvPlatform.dll!WHvQueryGpaRangeDirtyBitmap.

00:00:00.807567 NEM: NEMR3Init: Snail execution mode is active!
00:00:00.807567 NEM: Note! VirtualBox is not able to run at its full potential in this execution mode.
00:00:00.807567 NEM:       To see VirtualBox run at max speed you need to disable all Windows features
00:00:00.807567 NEM:       making use of Hyper-V.  That is a moving target, so google how and carefully
00:00:00.807567 NEM:       consider the consequences of disabling these features.
00:00:00.807567 NEM:
00:00:00.807583 CPUM: No hardware-virtualization capability detected

VT-x は Intelの仮想化技術で、つまりログでは、VirtualboxがCPUの仮想化技術が使えないということが記載されている。さらに、VirtualBoxを最高速度で実行するには、Hyper-Vを使用するすべてのWindows機能を無効にする必要がある。という提示も入っている。

なぜそれが必要というと、AVXを有効化する必要があるため。
AVXはCPUの演算処理を高速化する拡張命令セットで、MongoDB 5.0以降の環境配置はAVXを必須とする。

本来であれば、Intel(VT-x)でもAMD(AMD-x)でもAVXをサポートしているはず、Windows Hyper-Vの存在でVirutalboxがVT-xを使えなくなった。

VT-xが使えないことで、cat /proc/cpuinfoで出力したCPU情報のflagsの中にはAVXが入っていないことも確認した。

それでMongoDB起動が失敗している。

解決方法

解決方法は、VBox.logでも提示したように、Hyper-Vを使用するすべてのWindows機能を無効にすること

ただ完全無効化した後の影響などをちゃんと確認する必要がある。例えば、Windows セキュリティからWindows Defender ウイルス対策などのサービスも含めて無効化する必要がある。

とりあえず、下記記事の説明を参照して、Hyper-Vを無効化するため、一通り実施した。

参照:HMR3Init: Attempting fall back to NEM (Hyper-V is active)

  1. 起動中にアプリを全部shut downする。
  2. 下記機能が実行しているかどうかを確認する。実行しているであれば、無効化する。
    Windows Defender デバイス のセキュリティ のコア分離、メモリ整合性
    ウイルスと脅威の防止のリアルタイム保護
    Hypervisor protected Code Integrity
    Secure Coreなど
  3. 管理者権限でターミナルを起動
    下記コマンドを実行
# Hyper-Vを無効化
bcdedit /set hypervisorlaunchtype off
DISM /Online /Disable-Feature:Microsoft-Hyper-V

# shutdown 
shutdown -s -t 2

シャットダウンして、20秒ほどを待ってから、再起動する。

ほかの投稿者も言っているように、一回でダメだった場合は、上記のステップを2~3繰り返してみる。

私の場合は、GUIで[Windowsの機能の有効化または無効化]からHyper-Vなど関係機能を一度チェックして、またチェック外してみた。そして再起動したら、MongoDBが問題なく動いた。

参照記事

VirtualBox上のcentosにインストールしたmongodbが起動しない
Could not start MongoDB 5.0 running Oracle Linux on VirtualBox
WindowsでVirtualBoxとDockerを併用するときに気をつけること(AVX)
Windows 11 upgrade issue with Mongodb in virtualbox
I have a 64bit host, but can't install 64bit guests
HMR3Init: Attempting fall back to NEM (Hyper-V is active)
How to enable AVX / AVX2 in VirtualBox 6.1.16 with Ubuntu 20.04 64bit?
mongod.service Failed with result core-dump

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?