

### 質問内容

以下のエラーの解決方法を教えてください。

[code]

    Data directory /data/db not found., terminating
    
[/code]

### 現状

以前mongoDBを起動したときは使えたのだが強制終了してしまったせいか、再度起動できなくなってしまいました。

[code]

    $ sudo service mongod start
    mongod: unrecognized service
    
[/code]

[code]

    $ mongod
    2020-09-17T18:10:14.072+0900 I CONTROL  [initandlisten] MongoDB starting : pid=134 port=27017 dbpath=/data/db 64-bit host=LAPTOP-LSE3HD1V
    2020-09-17T18:10:14.078+0900 I CONTROL  [initandlisten] db version v3.4.24
    2020-09-17T18:10:14.085+0900 I CONTROL  [initandlisten] git version: 865b4f6a96d0f5425e39a18337105f33e8db504d
    2020-09-17T18:10:14.086+0900 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2n  7 Dec 2017
    2020-09-17T18:10:14.087+0900 I CONTROL  [initandlisten] allocator: tcmalloc
    2020-09-17T18:10:14.092+0900 I CONTROL  [initandlisten] modules: none
    2020-09-17T18:10:14.093+0900 I CONTROL  [initandlisten] build environment:
    2020-09-17T18:10:14.101+0900 I CONTROL  [initandlisten]     distmod: ubuntu1604
    2020-09-17T18:10:14.102+0900 I CONTROL  [initandlisten]     distarch: x86_64
    2020-09-17T18:10:14.107+0900 I CONTROL  [initandlisten]     target_arch: x86_64
    2020-09-17T18:10:14.108+0900 I CONTROL  [initandlisten] options: {}
    2020-09-17T18:10:14.120+0900 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
    2020-09-17T18:10:14.121+0900 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
    2020-09-17T18:10:14.127+0900 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
    2020-09-17T18:10:14.129+0900 I CONTROL  [initandlisten] now exiting
    2020-09-17T18:10:14.135+0900 I CONTROL  [initandlisten] shutting down with code:100
    
[/code]

ここで

[code]

    2020-09-17T18:10:14.120+0900 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
    
[/code]

より、dbというディレクトリがないことがわかりました。一応見てみると、

[code]

    /data$ ls
    db
    /data$ cd db
    -bash: cd: db: No such file or directory
    
[/code]

となっていました。  
このコードの2行目に「db」とある気がするのですが、とりあえず起動できません。

ディレクトリを作れということなのかと思い、同じ階層に「db1」というものを作りました。

[code]

    /data$ mkdir db1
    /data$ ls
    db  db1
    
[/code]

その後、

[code]

    $ mongod -dbpath /data/db1
    2020-09-17T18:09:20.877+0900 I CONTROL  [initandlisten] MongoDB starting : pid=126 port=27017 dbpath=/data/db1 64-bit host=LAPTOP-LSE3HD1V
    2020-09-17T18:09:20.882+0900 I CONTROL  [initandlisten] db version v3.4.24
    2020-09-17T18:09:20.883+0900 I CONTROL  [initandlisten] git version: 865b4f6a96d0f5425e39a18337105f33e8db504d
    2020-09-17T18:09:20.890+0900 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2n  7 Dec 2017
    2020-09-17T18:09:20.891+0900 I CONTROL  [initandlisten] allocator: tcmalloc
    2020-09-17T18:09:20.892+0900 I CONTROL  [initandlisten] modules: none
    2020-09-17T18:09:20.897+0900 I CONTROL  [initandlisten] build environment:
    2020-09-17T18:09:20.902+0900 I CONTROL  [initandlisten]     distmod: ubuntu1604
    2020-09-17T18:09:20.903+0900 I CONTROL  [initandlisten]     distarch: x86_64
    2020-09-17T18:09:20.904+0900 I CONTROL  [initandlisten]     target_arch: x86_64
    2020-09-17T18:09:20.905+0900 I CONTROL  [initandlisten] options: { storage: { dbPath: "/data/db1" } }
    2020-09-17T18:09:20.969+0900 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=7569M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),verbose=(recovery_progress),
    2020-09-17T18:09:21.035+0900 E STORAGE  [initandlisten] WiredTiger error (22) [1600333761:35092][126:0x7fe7bed81180], connection: /data/db1/: directory-sync: fdatasync: Invalid argument
    2020-09-17T18:09:21.038+0900 E STORAGE  [initandlisten] WiredTiger error (-31804) [1600333761:38949][126:0x7fe7bed81180], connection: the process must exit and restart: WT_PANIC: WiredTiger library panic
    2020-09-17T18:09:21.046+0900 I -        [initandlisten] Fatal Assertion 28558 at src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp 365
    2020-09-17T18:09:21.052+0900 I -        [initandlisten]
    
    ***aborting after fassert() failure
    
    
    2020-09-17T18:09:21.113+0900 F -        [initandlisten] Got signal: 6 (Aborted).
    
     0x7fe7c03610b1 0x7fe7c03602c9 0x7fe7c03607ad 0x7fe7bd7528a0 0x7fe7bd37ef47 0x7fe7bd3808b1 0x7fe7bf5f39f1 0x7fe7c0068f86 0x7fe7bf5fe0a8 0x7fe7bf5fe2cd 0x7fe7bf5fe52f 0x7fe7c0d17857 0x7fe7c0d179f2 0x7fe7c0d1837b 0x7fe7c0d14581 0x7fe7c0c72b06 0x7fe7c0d3489f 0x7fe7c0d1242b 0x7fe7c0cc109a 0x7fe7c004d3af 0x7fe7c0045aa2 0x7fe7bff386e0 0x7fe7bf5deaf3 0x7fe7bf5ff926 0x7fe7bd361b97 0x7fe7bf660379
    ----- BEGIN BACKTRACE -----
    {"backtrace":[{"b":"7FE7BEDAE000","o":"15B30B1","s":"_ZN5mongo15printStackTraceERSo"},{"b":"7FE7BEDAE000","o":"15B22C9"},{"b":"7FE7BEDAE000","o":"15B27AD"},{"b":"7FE7BD740000","o":"128A0"},{"b":"7FE7BD340000","o":"3EF47","s":"gsignal"},{"b":"7FE7BD340000","o":"408B1","s":"abort"},{"b":"7FE7BEDAE000","o":"8459F1","s":"_ZN5mongo32fassertFailedNoTraceWithLocationEiPKcj"},{"b":"7FE7BEDAE000","o":"12BAF86"},{"b":"7FE7BEDAE000","o":"8500A8","s":"__wt_eventv"},{"b":"7FE7BEDAE000","o":"8502CD","s":"__wt_err"},{"b":"7FE7BEDAE000","o":"85052F","s":"__wt_panic"},{"b":"7FE7BEDAE000","o":"1F69857"},{"b":"7FE7BEDAE000","o":"1F699F2"},{"b":"7FE7BEDAE000","o":"1F6A37B"},{"b":"7FE7BEDAE000","o":"1F66581","s":"__wt_open"},{"b":"7FE7BEDAE000","o":"1EC4B06","s":"__wt_block_manager_create"},{"b":"7FE7BEDAE000","o":"1F8689F","s":"__wt_schema_create"},{"b":"7FE7BEDAE000","o":"1F6442B","s":"__wt_turtle_init"},{"b":"7FE7BEDAE000","o":"1F1309A","s":"wiredtiger_open"},{"b":"7FE7BEDAE000","o":"129F3AF","s":"_ZN5mongo18WiredTigerKVEngineC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_PNS_11ClockSourceES8_mbbbb"},{"b":"7FE7BEDAE000","o":"1297AA2"},{"b":"7FE7BEDAE000","o":"118A6E0","s":"_ZN5mongo20ServiceContextMongoD29initializeGlobalStorageEngineEv"},{"b":"7FE7BEDAE000","o":"830AF3"},{"b":"7FE7BEDAE000","o":"851926","s":"main"},{"b":"7FE7BD340000","o":"21B97","s":"__libc_start_main"},{"b":"7FE7BEDAE000","o":"8B2379","s":"_start"}],"processInfo":{ "mongodbVersion" : "3.4.24", "gitVersion" : "865b4f6a96d0f5425e39a18337105f33e8db504d", "compiledModules" : [], "uname" : { "sysname" : "Linux", "release" : "4.4.0-18362-Microsoft", "version" : "#1049-Microsoft Thu Aug 14 12:01:00 PST 2020", "machine" : "x86_64" }, "somap" : [ { "b" : "7FE7BEDAE000", "elfType" : 3, "buildId" : "2D1022085B581BB8C5C09845FF38D62AB6F14607" }, { "b" : "7FFFE394D000", "path" : "linux-vdso.so.1", "elfType" : 3 }, { "b" : "7FE7BE790000", "path" : "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0", "elfType" : 3, "buildId" : "0D054641049B9747C05D030262295DFDFDD3055D" }, { "b" : "7FE7BE340000", "path" : "/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0", "elfType" : 3, "buildId" : "9C228817BA6E0730F4FCCFAC6E033BD1E0C5620A" }, { "b" : "7FE7BE130000", "path" : "/lib/x86_64-linux-gnu/librt.so.1", "elfType" : 3, "buildId" : "3F29B196C7C124797473113FD2D0833881BF0DE5" }, { "b" : "7FE7BDF20000", "path" : "/lib/x86_64-linux-gnu/libdl.so.2", "elfType" : 3, "buildId" : "B22BAF34FB22284EC8E3818961CDF01CCAB3441C" }, { "b" : "7FE7BDB80000", "path" : "/lib/x86_64-linux-gnu/libm.so.6", "elfType" : 3, "buildId" : "9EF1967ED985A60AC2288C3E1D8C8375F48B841D" }, { "b" : "7FE7BD960000", "path" : "/lib/x86_64-linux-gnu/libgcc_s.so.1", "elfType" : 3, "buildId" : "679F3AE11120EC7C483BC9295345D836F5C104F7" }, { "b" : "7FE7BD740000", "path" : "/lib/x86_64-linux-gnu/libpthread.so.0", "elfType" : 3, "buildId" : "BC3C06107774266C5F7DB3F1F380A3DA68AF90FA" }, { "b" : "7FE7BD340000", "path" : "/lib/x86_64-linux-gnu/libc.so.6", "elfType" : 3, "buildId" : "D3CF764B2F97AC3EFE366DDD07AD902FB6928FD7" }, { "b" : "7FE7BEA00000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3, "buildId" : "C93445FE9506EEE727E6F04F1AC8F460E49EB366" } ] }}
     mongod(_ZN5mongo15printStackTraceERSo+0x41) [0x7fe7c03610b1]
     mongod(+0x15B22C9) [0x7fe7c03602c9]
     mongod(+0x15B27AD) [0x7fe7c03607ad]
     libpthread.so.0(+0x128A0) [0x7fe7bd7528a0]
     libc.so.6(gsignal+0xC7) [0x7fe7bd37ef47]
     libc.so.6(abort+0x141) [0x7fe7bd3808b1]
     mongod(_ZN5mongo32fassertFailedNoTraceWithLocationEiPKcj+0x0) [0x7fe7bf5f39f1]
     mongod(+0x12BAF86) [0x7fe7c0068f86]
     mongod(__wt_eventv+0x3D7) [0x7fe7bf5fe0a8]
     mongod(__wt_err+0x9D) [0x7fe7bf5fe2cd]
     mongod(__wt_panic+0x2E) [0x7fe7bf5fe52f]
     mongod(+0x1F69857) [0x7fe7c0d17857]
     mongod(+0x1F699F2) [0x7fe7c0d179f2]
     mongod(+0x1F6A37B) [0x7fe7c0d1837b]
     mongod(__wt_open+0x491) [0x7fe7c0d14581]
     mongod(__wt_block_manager_create+0x66) [0x7fe7c0c72b06]
     mongod(__wt_schema_create+0x4EF) [0x7fe7c0d3489f]
     mongod(__wt_turtle_init+0x36B) [0x7fe7c0d1242b]
     mongod(wiredtiger_open+0x194A) [0x7fe7c0cc109a]
     mongod(_ZN5mongo18WiredTigerKVEngineC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_PNS_11ClockSourceES8_mbbbb+0x70F) [0x7fe7c004d3af]
     mongod(+0x1297AA2) [0x7fe7c0045aa2]
     mongod(_ZN5mongo20ServiceContextMongoD29initializeGlobalStorageEngineEv+0x6B0) [0x7fe7bff386e0]
     mongod(+0x830AF3) [0x7fe7bf5deaf3]
     mongod(main+0x966) [0x7fe7bf5ff926]
     libc.so.6(__libc_start_main+0xE7) [0x7fe7bd361b97]
     mongod(_start+0x29) [0x7fe7bf660379]
    -----  END BACKTRACE  -----
    Aborted (core dumped)
    
[/code]

と表示されました。

ここまでやってもmongodbは起動できませんでした。  
どういう直し方をすればよいのかわからないので、投稿させていただきました。  
宜しくお願いいたします。


CC BY-SA 4.0
2020-09-17T09:40:43.300
70489
2020-09-19T18:43:25.780
2020-09-17T11:31:18.983
3060
41950
question
ubuntu mongodb
mongoDBのパスの通し方を教えてください


エラーログのうち、

[code]

    "uname" : { "sysname" : "Linux", "release" : "4.4.0-18362-Microsoft", "version" : "#1049-Microsoft Thu Aug 14 12:01:00 PST 2020", "machine" : "x86_64" }
    
[/code]

の部分からすると、WSL: Windows Sybsystem for Linuxを使っていると思います。

しかしMongoDBは公式にはWSLをサポートしていません。マニュアルの[Supported
Platforms](https://docs.mongodb.com/manual/administration/production-
notes/#supported-platforms)に記載がありません。クラッシュしているのはこのためだと思われます。

まずは普通のLinux環境でやり直すか、もしくはWindowsを使うのであればWindows版のMongoDBをインストールしてみてください。


CC BY-SA 4.0
2020-09-19T18:43:25.780
70546
2020-09-19T18:43:25.780
20119
70489
answer