Sudhanshu Kaul
Sudhanshu Kaul

Reputation: 11

MongoDB failure using AWS Cloud9

While using mongo on the cloud9 IDE, I followed the instructions on github. everything works fine when I run ./mongod for the first time after following the instructions. But when I try repeating the same command after closing the mongo bash, I end up with the following error, and all of my databases being lost.

2020-05-15T14:13:46.120+0000 I CONTROL  [initandlisten] MongoDB starting : pid=4361 port=27017 dbpath=data 64-bit host=ip-172-31-9-233
2020-05-15T14:13:46.120+0000 I CONTROL  [initandlisten] db version v3.6.18
2020-05-15T14:13:46.120+0000 I CONTROL  [initandlisten] git version: 2005f25eed7ed88fa698d9b800fe536bb0410ba4
2020-05-15T14:13:46.120+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.0-fips 29 Mar 2010
2020-05-15T14:13:46.121+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2020-05-15T14:13:46.121+0000 I CONTROL  [initandlisten] modules: none
2020-05-15T14:13:46.121+0000 I CONTROL  [initandlisten] build environment:
2020-05-15T14:13:46.121+0000 I CONTROL  [initandlisten]     distmod: amazon
2020-05-15T14:13:46.121+0000 I CONTROL  [initandlisten]     distarch: x86_64
2020-05-15T14:13:46.121+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2020-05-15T14:13:46.121+0000 I CONTROL  [initandlisten] options: { storage: { dbPath: "data", journal: { enabled: false } } }
2020-05-15T14:13:46.121+0000 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Address already in use
2020-05-15T14:13:46.121+0000 F -        [initandlisten] Invariant failure globalStorageEngine src/mongo/db/service_context_d.cpp 272
2020-05-15T14:13:46.121+0000 F -        [initandlisten] 

***aborting after invariant() failure


2020-05-15T14:13:46.143+0000 F -        [initandlisten] Got signal: 6 (Aborted).

 0x5624cebe3891 0x5624cebe2aa9 0x5624cebe2f8d 0x7f7f389db600 0x7f7f386343a7 0x7f7f38635a98 0x5624cd2da320 0x5624cd582bd8 0x5624cea8c531 0x5624cea88617 0x5624cd351c2c 0x5624cebdec55 0x5624cd2db4f9 0x5624cd27418c 0x5624cd3595ca 0x5624cd2dc449 0x7f7f38620575 0x5624cd340e71
----- BEGIN BACKTRACE -----
{"backtrace":[{"b":"5624CC93D000","o":"22A6891","s":"_ZN5mongo15printStackTraceERSo"},{"b":"5624CC93D000","o":"22A5AA9"},{"b":"5624CC93D000","o":"22A5F8D"},{"b":"7F7F389CC000","o":"F600"},{"b":"7F7F385FE000","o":"363A7","s":"gsignal"},{"b":"7F7F385FE000","o":"37A98","s":"abort"},{"b":"5624CC93D000","o":"99D320","s":"_ZN5mongo22invariantFailedWithMsgEPKcS1_S1_j"},{"b":"5624CC93D000","o":"C45BD8","s":"_ZN5mongo20ServiceContextMongoD9_newOpCtxEPNS_6ClientEj"},{"b":"5624CC93D000","o":"214F531","s":"_ZN5mongo14ServiceContext20makeOperationContextEPNS_6ClientE"},{"b":"5624CC93D000","o":"214B617","s":"_ZN5mongo6Client20makeOperationContextEv"},{"b":"5624CC93D000","o":"A14C2C"},{"b":"5624CC93D000","o":"22A1C55"},{"b":"5624CC93D000","o":"99E4F9","s":"_ZN5mongo8shutdownENS_8ExitCodeERKNS_16ShutdownTaskArgsE"},{"b":"5624CC93D000","o":"93718C","s":"_ZZN5mongo13duration_castINS_8DurationISt5ratioILl1ELl1000EEEES2_ILl1ELl1EEEET_RKNS1_IT0_EEENKUlvE_clEv"},{"b":"5624CC93D000","o":"A1C5CA","s":"_ZN5mongo11mongoDbMainEiPPcS1_"},{"b":"5624CC93D000","o":"99F449","s":"main"},{"b":"7F7F385FE000","o":"22575","s":"__libc_start_main"},{"b":"5624CC93D000","o":"A03E71"}],"processInfo":{ "mongodbVersion" : "3.6.18", "gitVersion" : "2005f25eed7ed88fa698d9b800fe536bb0410ba4", "compiledModules" : [], "uname" : { "sysname" : "Linux", "release" : "4.14.177-107.254.amzn1.x86_64", "version" : "#1 SMP Thu May 7 18:30:14 UTC 2020", "machine" : "x86_64" }, "somap" : [ { "b" : "5624CC93D000", "elfType" : 3, "buildId" : "BFF2746BD1982D6569D4870654128D11148441FF" }, { "b" : "7FFD53718000", "elfType" : 3, "buildId" : "FCDA16E475615B36B646D5639C780F22F648405D" }, { "b" : "7F7F39BDC000", "path" : "/lib64/libresolv.so.2", "elfType" : 3, "buildId" : "9CBEE9AA7ED85AD5BE053B483993D677420A765E" }, { "b" : "7F7F3977D000", "path" : "/lib64/libcrypto.so.10", "elfType" : 3, "buildId" : "CEC0EE1141809208648C0C3B1ACB43C3CD8D485E" }, { "b" : "7F7F3950C000", "path" : "/lib64/libssl.so.10", "elfType" : 3, "buildId" : "398164A11688E492630B353F96B4C0486C141264" }, { "b" : "7F7F39308000", "path" : "/lib64/libdl.so.2", "elfType" : 3, "buildId" : "4663D1734EAE35F43F257D29615C1AFF5E060AE0" }, { "b" : "7F7F39100000", "path" : "/lib64/librt.so.1", "elfType" : 3, "buildId" : "C07056C6DA664000A4DAAF8960AB182A8602E910" }, { "b" : "7F7F38DFE000", "path" : "/lib64/libm.so.6", "elfType" : 3, "buildId" : "08C69C7E15BA7B4E199D2FDC1DC29B1CC1996BC1" }, { "b" : "7F7F38BE8000", "path" : "/lib64/libgcc_s.so.1", "elfType" : 3, "buildId" : "A03C9A80E995ED5F43077AB754A258FA0E34C3CD" }, { "b" : "7F7F389CC000", "path" : "/lib64/libpthread.so.0", "elfType" : 3, "buildId" : "383B229C0E6E99B4E3BA6FC8B8C096C103226984" }, { "b" : "7F7F385FE000", "path" : "/lib64/libc.so.6", "elfType" : 3, "buildId" : "8BDBE5043577FC2EA218FAFD7EDF175D219698FB" }, { "b" : "7F7F39DF5000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3, "buildId" : "405C4E6374AAAB00F3A7F7986679078870DC2460" }, { "b" : "7F7F383E8000", "path" : "/lib64/libz.so.1", "elfType" : 3, "buildId" : "89C6AF118B6B4FB6A73AE1813E2C8BDD722956D1" }, { "b" : "7F7F3819B000", "path" : "/usr/lib64/libgssapi_krb5.so.2", "elfType" : 3, "buildId" : "D99D708ED949CDD8C415E101385BCD4B7E55C703" }, { "b" : "7F7F37EB2000", "path" : "/usr/lib64/libkrb5.so.3", "elfType" : 3, "buildId" : "FC76FD92303FA56FC5D600EA7AB8A6D526C3A7C1" }, { "b" : "7F7F37CAF000", "path" : "/usr/lib64/libcom_err.so.2", "elfType" : 3, "buildId" : "AB007F5DF96C66E515542598F5BE1429ED63D86F" }, { "b" : "7F7F37A94000", "path" : "/usr/lib64/libk5crypto.so.3", "elfType" : 3, "buildId" : "17F45835B4BB8649628DC476A8940F7F8D978B4B" }, { "b" : "7F7F37885000", "path" : "/usr/lib64/libkrb5support.so.0", "elfType" : 3, "buildId" : "CB655C972CCCD844E292069A5D7DAEBA0ADF4922" }, { "b" : "7F7F37682000", "path" : "/lib64/libkeyutils.so.1", "elfType" : 3, "buildId" : "37A58210FA50C91E09387765408A92909468D25B" }, { "b" : "7F7F37461000", "path" : "/usr/lib64/libselinux.so.1", "elfType" : 3, "buildId" : "F5054DC94443326819FBF3065CFDF5E4726F57EE" } ] }}
 mongod(_ZN5mongo15printStackTraceERSo+0x41) [0x5624cebe3891]
 mongod(+0x22A5AA9) [0x5624cebe2aa9]
 mongod(+0x22A5F8D) [0x5624cebe2f8d]
 libpthread.so.0(+0xF600) [0x7f7f389db600]
 libc.so.6(gsignal+0x37) [0x7f7f386343a7]
 libc.so.6(abort+0x148) [0x7f7f38635a98]
 mongod(_ZN5mongo22invariantFailedWithMsgEPKcS1_S1_j+0x0) [0x5624cd2da320]
 mongod(_ZN5mongo20ServiceContextMongoD9_newOpCtxEPNS_6ClientEj+0x158) [0x5624cd582bd8]
 mongod(_ZN5mongo14ServiceContext20makeOperationContextEPNS_6ClientE+0x41) [0x5624cea8c531]
 mongod(_ZN5mongo6Client20makeOperationContextEv+0x27) [0x5624cea88617]
 mongod(+0xA14C2C) [0x5624cd351c2c]
 mongod(+0x22A1C55) [0x5624cebdec55]
 mongod(_ZN5mongo8shutdownENS_8ExitCodeERKNS_16ShutdownTaskArgsE+0x364) [0x5624cd2db4f9]
 mongod(_ZZN5mongo13duration_castINS_8DurationISt5ratioILl1ELl1000EEEES2_ILl1ELl1EEEET_RKNS1_IT0_EEENKUlvE_clEv+0x0) [0x5624cd27418c]
 mongod(_ZN5mongo11mongoDbMainEiPPcS1_+0x87A) [0x5624cd3595ca]
 mongod(main+0x9) [0x5624cd2dc449]
 libc.so.6(__libc_start_main+0xF5) [0x7f7f38620575]
 mongod(+0xA03E71) [0x5624cd340e71]
-----  END BACKTRACE  -----
./mongod: line 1:  4361 Aborted                 mongod --dbpath=data --nojournal

I'm following "the complete web development bootcamp" course by Colt Steele on Udemy. The stack I'm using is NodeJS, express, and mongo. Please help.

Upvotes: 1

Views: 347

Answers (2)

Mali Gautam H
Mali Gautam H

Reputation: 21

if you still getting error then run this command line by line

first, remove MongoDB

[1] sudo yum erase -y mongodb-org*

[2] create fill using command

touch mongodb-org-3.6.repo

[3] copy the code beloved and past into that created file

[mongodb-org-3.6]
name=MongoDB Repository

baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/

gpgcheck=1

enabled=1

gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc

[4] sudo mv mongodb-org-3.6.repo /etc/yum.repos.d

[5]sudo yum install -y mongodb-org

[6]sudo service mongod start

if you are getting an error about

Error — /var/run/mongodb/mongod.pid exists

[7] run this command

sudo rm /var/run/mongodb/mongod.pid

[8] than again run sudo service mongod start

[9]now run mongod

Upvotes: 1

Mali Gautam H
Mali Gautam H

Reputation: 21

there is a problem when you start the mongo but not stop the server before closing the tab so there is a process to set up this

step 1: remove the preinstall MongoDB in AWS cloud9 and other IDE is use code

sudo yum erase -y mongodb-org*

step 2: then install mongodb from : https://github.com/nax3t/aws-cloud9-instructions

note: when you close the tab make sure you stop the mongo use command

sudo service mongod stop

Upvotes: 0

Related Questions