microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.44k stars 822 forks source link

Install MongoDB in Windows Linux Subsystem #796

Closed carpet92 closed 6 years ago

carpet92 commented 8 years ago

I try to install MongoDB with this instructions from official website https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org

After installation is complete I try to run mongodb with

sudo service mongod start

but have follow error

User@DESKTOP-TPQIRNP:/mnt/c/Users/User$ sudo service mongod start
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
mongod: unrecognized service

But If I install MongoDB with sudo apt-get install mongodb I can run it with sudo service mongodb start and this work. But with sudo apt-get install mongodb will be installed old 2.x.x version of MongoDB

How to install the latest stable version of MongoDB (3.x.x) without errors on Windows Linux Subsystem ?

carpet92 commented 8 years ago

@XSmeets services are unimplemented for now but if I install mongodb with sudo apt-get install mongodb sudo service mongod start will work

carpet92 commented 8 years ago

@XSmeets I wrote in my issue that everything is working fine (with install mongodb with sudo apt-get install mongodb and run sudo service mongodb start). You can check it yourself if you have Windows 10 with Linux Subsystem. And if you try to connect to MongoDB with Mongoose It will also work well. And about Upstart https://github.com/Microsoft/BashOnWindows/issues/791#issuecomment-238027584 I have problem only with install latest stable MongoDB from official instructions

aseering commented 8 years ago

@XSmeets -- you are technically correct that Upstart is responsible for starting applications, but not in the way that you imply here. The service command doesn't call Upstart. Quite the opposite -- Upstart calls the service command when your machine boots.

The absence of Upstart means that mongodb will not automatically start on reboot; @Zx-EvM will have to re-run sudo service mongodb start to start using MongoDB again. However, it works just fine otherwise.

nginx and OpenSSH both do fail currently, but not because of Upstart. nginx fails due to an issue related to IPv6 support; see #68 for details and a workaround. OpenSSH fails due to lack of chroot support among other issues; there's discussion on #300 , and the workaround is documented on this forum post. In both cases, the failures are not due to issues involving Upstart.

carpet92 commented 8 years ago

@aseering

will have to re-run sudo service mongodb start to start using MongoDB again

Yes. I understand it. but my issue is that for some reason does not work correctly MongoDB (not run) after install as here https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

rodrymbo commented 8 years ago

If you get the initctl error message about not being able to talk to upstart, and the service doesn't start, you might want to look for the script in /etc/init.d, which is (usually) a standard bash script. Run it like any other bash script, with start as a parameter. In other words, remove the word "service" from the command and call the script by its full path. Then it won't matter if upstart or service isn't implemented fully.

I've been doing that with sshd, sudo /etc/init.d/ssh start rather than sudo service ssh start . Note that the script is not called sshd, as you might expect.

Your mileage may vary, and there may not be a bash script in /etc/init.d you can run.

If you run the script and then it reports an error, you can be sure it is an error in that script or in the way your service runs. Right now, invoking it with the service command, before services are supported, it's hard to say where the problem is.

The other option is to find the executable for the service/daemon's executable. Frequently there is a way to make it run from a command line (usually for testing, or special applications). That's even more simple than running it from a bash script. If you can get the executable running that way, you can work from there to getting a script working.

Just a comment: right now we are using WSL when many things are broken or not yet implemented. Yes, we all know sudo service mongodb start is the proper way to start it, but since services aren't yet implemented, and we want to get some work done, we look for workarounds. Similarly, if there is a problem getting mongodb runniing in its barest, cleanest implementation, it may be helpful for it to be reported to the WSL folks separate from the issue of not being able to run it as a service.

carpet92 commented 8 years ago

@rodrymbo thanks. If I run MongoDB (which installed using sudo apt-get install mongodb not latest) with sudo /etc/init.d/mongodb start this work without initctl error message. Hm. But if I install MongoDB using official instruction

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org

I don't even have any file related mongodb in /etc/init.d directory.

rodrymbo commented 8 years ago

I'm not familiar enough with upstart or mongodb (yet) to speculate too much.

If you use the first method (sudo apt-get install mongodb, without implementing the repository at repo.mongodb.org), and you do get the mongodb script in /etc/init.d, you could save a copy of it somewhere like your home directory. It will include a line somewhere that does the actual starting of the mongod daemon (most likely). Then if you install from the repo.mongodb.org repository, there's a chance the script you saved may work. If not it may give you clues as to where to find the executable, or what to use in man to learn about it, for example, how to run it without it detaching or becoming a daemon (perhaps -D). I'd guess the daemon executable is mongod, but it's only a guess.

aseering commented 8 years ago

@Zx-EvM -- ah, sorry, I confused your two recent posts.

It looks like the new package really is an Upstart-specific script. That means that you don't start it using sudo service mongod start; you start it with sudo /sbin/start mongod. Which doesn't appear to work right now.

Oddly, though, if I install the old version and then (without removing it) I install the new version, then sudo service mongodb start (which is a script installed by the old package) seems to detect the new version of mongodb instead of the old one, and start it correctly.

$ sudo service mongodb start
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
 * Starting database mongodb                                                                                     [ OK ]
$ mongo
MongoDB shell version: 3.2.8
connecting to: test
2016-08-06T17:01:59.123-0400 E NETWORK  [thread1] can't get TCP_KEEPIDLE: errno:22 Invalid argument
2016-08-06T17:01:59.123-0400 E NETWORK  [thread1] can't get TCP_KEEPINTVL: errno:22 Invalid argument
> db.version()
3.2.8
>
carpet92 commented 8 years ago

@aseering oh. Thanks! It's work for me

KEMDAK commented 8 years ago

@aseering That worked :D thanks.

aseering commented 8 years ago

Incidentally, if anyone reading this wants to start mongodb at system start, I've posted a comment on these sshd instructions that I think explains how to do so:

http://wsl-forum.qztc.io/viewtopic.php?f=6&t=10

bschwartz757 commented 8 years ago

Hey! Sorry, but I'm a bit of a noob and I'm not quite able to to follow all of the instructions you guys have laid out. Is there any way one of you can post an exact set of commands for downloading and getting MongoDb running on WSL? I tried this: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list sudo apt-get update sudo apt-get install -y mongodb-org

which threw an error, so I tried again with: sudo service mongodb start

and it's still failing to install. Here's the output of that command: Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.wjm2zfd5JA --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 echo deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse gpg: "echo" not a key ID: skipping gpg: "deb" not a key ID: skipping gpg: "http://repo.mongodb.org/apt/ubuntu" not a key ID: skipping gpg: "trusty/mongodb-org/3.2" not a key ID: skipping gpg: "multiverse" not a key ID: skipping gpg: requesting key EA312927 from hkp server keyserver.ubuntu.com gpg: key EA312927: public key "MongoDB 3.2 Release Signing Key <packaging@mongodb.com>" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)

Many thanks!!

acezard commented 8 years ago

@bschwartz757 the only way I managed to make MongoDB works on WSL was to install an old version. sudo apt-get install mongodb on a clean installation. Then just launching sudo mongod. I was unable to use the latest version due to wiredTiger issues

bschwartz757 commented 8 years ago

Ah, dang, that's too bad. I'm doing the Mongo University course right now and thought it might be useful to have a working Mongo instance on WSL, but it wouldn't really make sense to do so with an old version.

I guess I'll have to stick with Git Bash for now. Thanks for the response!

bschwartz757 commented 8 years ago

@aseering how did you actually manage to install the new version, if I might ask? I was able to install using the apt-get command others referenced, but I have version 2.4.9 now. Interested in trying out the solution you mentioned.

Thanks @acezard I was able to install the old version as you suggested. Still can't get it to run though...

aseering commented 8 years ago

Hi @bschwartz -- I just installed the old version from Ubuntu "apt", then added the repository containing the new version and installed that.

That was several versions of WSL ago, though. Maybe there has been a relevant change or regression?

sunilmut commented 8 years ago

Has anyone been able to get the MongoDB version 3.2.9 working on WSL? After following the instructions from @Zx-EvM, I was able to get 3.2.9 installed. service mongodb start is fine, but then service mongodb status shows fail.

kpobococ commented 8 years ago

This is not a WFL problem, the problem is with Ubuntu 14.04:

bschwartz757 commented 8 years ago

@anton @aseering Huh... I followed the steps on the installation guide and it seems have gotten v3.2.9 installed. Only problem is that now I get errors when attempting mongod or the shell, and it is unusable. Specifying a dbpath and port was working for me previously with 2.4.9 but no love here, unfortunately:

root@blakes-PC:/mnt/c/Windows/System32# mongod --dbpath /mnt/c/data/db/ --port 39019 2016-09-21T06:36:29.325-0700 I CONTROL [initandlisten] MongoDB starting : pid=780 port=39019 dbpath=/mnt/c/data/db/ 64-bit host=blakes-PC 2016-09-21T06:36:29.326-0700 I CONTROL [initandlisten] db version v3.2.9 2016-09-21T06:36:29.326-0700 I CONTROL [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c 2016-09-21T06:36:29.326-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014 2016-09-21T06:36:29.326-0700 I CONTROL [initandlisten] allocator: tcmalloc 2016-09-21T06:36:29.326-0700 I CONTROL [initandlisten] modules: none 2016-09-21T06:36:29.326-0700 I CONTROL [initandlisten] build environment: 2016-09-21T06:36:29.326-0700 I CONTROL [initandlisten] distmod: ubuntu1404 2016-09-21T06:36:29.326-0700 I CONTROL [initandlisten] distarch: x86_64 2016-09-21T06:36:29.327-0700 I CONTROL [initandlisten] target_arch: x86_64 2016-09-21T06:36:29.327-0700 I CONTROL [initandlisten] options: { net: { port: 39019 }, storage: { dbPath: "/mnt/c/data/db/" } } 2016-09-21T06:36:29.349-0700 I - [initandlisten] Detected data files in /mnt/c/data/db/ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'. 2016-09-21T06:36:29.353-0700 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(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), 2016-09-21T06:36:30.196-0700 E STORAGE [initandlisten] WiredTiger (5) [1474464990:196582][780:0x7fa0d5450cc0], WT_SESSION.checkpoint: /mnt/c/data/db//journal: handle-sync: fdatasync: Input/output error 2016-09-21T06:36:30.198-0700 E STORAGE [initandlisten] WiredTiger (5) [1474464990:198196][780:0x7fa0d5450cc0], txn-recover: Recovery failed: Input/output error 2016-09-21T06:36:30.702-0700 E STORAGE [initandlisten] WiredTiger (5) [1474464990:702478][780:0x7fa0d5450cc0], connection: /mnt/c/data/db//journal: handle-sync: fdatasync: Input/output error 2016-09-21T06:36:30.703-0700 E STORAGE [initandlisten] WiredTiger (0) [1474464990:704083][780:0x7fa0d5450cc0], connection: Connection has open file handles: journal 2016-09-21T06:36:30.704-0700 I - [initandlisten] Assertion: 28595:5: Input/output error 2016-09-21T06:36:30.704-0700 I STORAGE [initandlisten] exception in initAndListen: 28595 5: Input/output error, terminating 2016-09-21T06:36:30.704-0700 I CONTROL [initandlisten] dbexit: rc: 100 root@blakes-PC:/mnt/c/Windows/System32#

On Wed, Sep 21, 2016 at 4:39 AM, Anton Suprun notifications@github.com wrote:

This is not a WFL problem, the problem is with Ubuntu 14.04:

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BashOnWindows/issues/796#issuecomment-248586378, or mute the thread https://github.com/notifications/unsubscribe-auth/AHK9nPxxPYEPFxF0pux2Ot1pAAoOj3gjks5qsReGgaJpZM4JeViz .

acezard commented 8 years ago

@bschwartz757 : try deleting the db folder and recreating it.

Installing the 3.2.9 was fine for me, but it was crashing after 1 minute because of an issue with wired tiger ('function non implemented')

bschwartz757 commented 8 years ago

Thanks Antonin... My only concern is, that folder is currently not empty on the Windows side of my machine as I'm currently working on a Mongo University course. There's nothing particularly valuable in there but I assume that wiping it out on one will have the net effect of wiping it out on both. So it sounds like I'll have to choose between running it on Windows with the limitations (but familiarity) that entails, and running it on Linux.

On Wed, Sep 21, 2016 at 8:27 AM, Antonin Cezard notifications@github.com wrote:

@bschwartz757 https://github.com/bschwartz757 : try deleting the db folder and recreating it.

Installing the 3.2.9 was fine for me, but it was crashing after 1 minute because of an issue with wired tigers ('function non implemented')

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BashOnWindows/issues/796#issuecomment-248647680, or mute the thread https://github.com/notifications/unsubscribe-auth/AHK9nKgawFa6kFVRGrC2RGUSl-yNSeuYks5qsUzngaJpZM4JeViz .

bschwartz757 commented 8 years ago

Looks like I finally have a working installation!! Thanks all for your help and input. I renamed my windows data/ directory to data_bak/ and things seem to be working now... I even ran a shell script provided by the Mongo University course to create a replica set using the Linux --fork option and it looks like they are all up and running. Connecting with a mongo shell also shows v3.2.

I'll keep my fingers crossed that nothing blows up in my face, but this looks like a good sign!

darkdragon-001 commented 8 years ago

I got it working with your instructions, too.

Note that the service is called mongodb instead of mongod for my installation (as it was in the Ubuntu 14.04 version).

bschwartz757 commented 8 years ago

Just installed the latest round of updates; running mongodb service works fine but when I try to run the mongo shell it causes a blue screen with an error and restarts my computer. Mongodb on the windows side seems to work fine, so I'll go back to that for now. The annoying thing is I was just getting used to being able to use all the handy linux programs while in the shell, now I'm back to git bash and it's "warning: terminal is not fully functional" messages if I try to use vim, less, etc.

benhillis commented 8 years ago

Fear not, the fix is coming soon!

bschwartz757 commented 8 years ago

Excellent! Seemed like I was able to do most things I wanted with MongoDB and I was really enjoying the shell experience. Thanks for the great work!

On Sun, Oct 2, 2016 at 3:46 PM, Ben Hillis notifications@github.com wrote:

Fear not, the fix is coming soon!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BashOnWindows/issues/796#issuecomment-251001515, or mute the thread https://github.com/notifications/unsubscribe-auth/AHK9nLkjIdGluD9sB2z7lneqGJ3HBkMmks5qwDQtgaJpZM4JeViz .

sulliwane commented 8 years ago

I added mongodb-org repo, apt-get install -y --force-yes mogodb-org and then started mongod with mongod --dbpath /mnt/c/windows/fs/mongodb, I get this error from wiredTiger:

WiredTiger (5) [1475891848:14284][16853:0x7fb221910cc0], connection: /mnt/c/mongodb-linux-x86_64-ubuntu1404-3.2.10/bin/data/db/: directory-sync: fdatasync: Input/output error
2016-10-08T09:57:28.017+0800 I -        [initandlisten] Assertion: 28595:5: Input/output error
2016-10-08T09:57:28.018+0800 I STORAGE  [initandlisten] exception in initAndListen: 28595 5: Input/output error, terminating
2016-10-08T09:57:28.018+0800 I CONTROL  [initandlisten] dbexit:  rc: 100

If I start mongodb with dbpath pointing to linux filesystem, then no problem

sulliwane commented 8 years ago

Commented too fast, if dbpath points to linux filesystem, mongodb do start, but after one minute, crash with core dump error (see below) :

 mongod --dbpath /home/me/Documents/
2016-10-08T10:04:20.423+0800 I CONTROL  [initandlisten] MongoDB starting : pid=16885 port=27017 dbpath=/home/me/Documents/ 64-bit host=host
2016-10-08T10:04:20.426+0800 I CONTROL  [initandlisten] db version v3.2.9
2016-10-08T10:04:20.426+0800 I CONTROL  [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
2016-10-08T10:04:20.426+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-10-08T10:04:20.427+0800 I CONTROL  [initandlisten] allocator: tcmalloc
2016-10-08T10:04:20.427+0800 I CONTROL  [initandlisten] modules: none
2016-10-08T10:04:20.427+0800 I CONTROL  [initandlisten] build environment:
2016-10-08T10:04:20.427+0800 I CONTROL  [initandlisten]     distmod: ubuntu1404
2016-10-08T10:04:20.427+0800 I CONTROL  [initandlisten]     distarch: x86_64
2016-10-08T10:04:20.427+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2016-10-08T10:04:20.427+0800 I CONTROL  [initandlisten] options: { storage: { dbPath: "/home/me/Documents/" } }
2016-10-08T10:04:20.459+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(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),
2016-10-08T10:04:20.595+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/home/me/Documents/diagnostic.data'
2016-10-08T10:04:20.595+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-10-08T10:04:20.623+0800 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-10-08T10:05:20.554+0800 E STORAGE  [thread1] WiredTiger (38) [1475892320:555106][16885:0x7fdf16410700], file:index-1-1965467168914914167.wt, WT_SESSION.checkpoint: /home/me/Documents//index-1-1965467168914914167.wt: handle-sync-nowait: sync_file_range: Function not implemented
2016-10-08T10:05:20.557+0800 E STORAGE  [thread1] WiredTiger (38) [1475892320:558055][16885:0x7fdf16410700], checkpoint-server: checkpoint server error: Function not implemented
2016-10-08T10:05:20.558+0800 E STORAGE  [thread1] WiredTiger (-31804) [1475892320:558277][16885:0x7fdf16410700], checkpoint-server: the process must exit and restart: WT_PANIC: WiredTiger library panic
2016-10-08T10:05:20.558+0800 I -        [thread1] Fatal Assertion 28558
2016-10-08T10:05:20.558+0800 I -        [thread1]

***aborting after fassert() failure

2016-10-08T10:05:20.572+0800 F -        [thread1] Got signal: 6 (Aborted).

 0x13225f2 0x1321749 0x1321f52 0x7fdf19860330 0x7fdf194b6c37 0x7fdf194ba028 0x12a8662 0x10a28b3 0x1a88fcc 0x1a8944d 0x1a89834 0x1a0a7cb 0x7fdf19858184 0x7fdf1957a37d
----- BEGIN BACKTRACE -----
{"backtrace":[{"b":"400000","o":"F225F2","s":"_ZN5mongo15printStackTraceERSo"},{"b":"400000","o":"F21749"},{"b":"400000","o":"F21F52"},{"b":"7FDF19850000","o":"10330"},{"b":"7FDF19480000","o":"36C37","s":"gsignal"},{"b":"7FDF19480000","o":"3A028","s":"abort"},{"b":"400000","o":"EA8662","s":"_ZN5mongo13fassertFailedEi"},{"b":"400000","o":"CA28B3"},{"b":"400000","o":"1688FCC","s":"__wt_eventv"},{"b":"400000","o":"168944D","s":"__wt_err"},{"b":"400000","o":"1689834","s":"__wt_panic"},{"b":"400000","o":"160A7CB"},{"b":"7FDF19850000","o":"8184"},{"b":"7FDF19480000","o":"FA37D","s":"clone"}],"processInfo":{ "mongodbVersion" : "3.2.9", "gitVersion" : "22ec9e93b40c85fc7cae7d56e7d6a02fd811088c", "compiledModules" : [], "uname" : { "sysname" : "Linux", "release" : "3.4.0+", "version" : "#1 PREEMPT Thu Aug 1 17:06:05 CST 2013", "machine" : "x86_64" }, "somap" : [ { "elfType" : 2, "b" : "400000", "buildId" : "78E57AF736DDF3E8C558F60DB63F68BCF686D70A" }, { "b" : "7FFFF521C000", "elfType" : 3 }, { "b" : "7FDF1A7A0000", "path" : "/lib/x86_64-linux-gnu/libssl.so.1.0.0", "elfType" : 3, "buildId" : "74864DB9D5F69D39A67E4755012FB6573C469B3D" }, { "b" : "7FDF1A3C0000", "path" : "/lib/x86_64-linux-gnu/libcrypto.so.1.0.0", "elfType" : 3, "buildId" : "AAE7CFF8351B730830BDBCE0DCABBE06574B7144" }, { "b" : "7FDF1A1B0000", "path" : "/lib/x86_64-linux-gnu/librt.so.1", "elfType" : 3, "buildId" : "E2A6DD5048A0A051FD61043BDB69D8CC68192AB7" }, { "b" : "7FDF19FA0000", "path" : "/lib/x86_64-linux-gnu/libdl.so.2", "elfType" : 3, "buildId" : "DA9B8C234D0FE9FD8CAAC8970A7EC1B6C8F6623F" }, { "b" : "7FDF19C90000", "path" : "/lib/x86_64-linux-gnu/libm.so.6", "elfType" : 3, "buildId" : "D144258E614900B255A31F3FD2283A878670D5BC" }, { "b" : "7FDF19A70000", "path" : "/lib/x86_64-linux-gnu/libgcc_s.so.1", "elfType" : 3, "buildId" : "36311B4457710AE5578C4BF00791DED7359DBB92" }, { "b" : "7FDF19850000", "path" : "/lib/x86_64-linux-gnu/libpthread.so.0", "elfType" : 3, "buildId" : "31E9F21AE8C10396171F1E13DA15780986FA696C" }, { "b" : "7FDF19480000", "path" : "/lib/x86_64-linux-gnu/libc.so.6", "elfType" : 3, "buildId" : "CF699A15CAAE64F50311FC4655B86DC39A479789" }, { "b" : "7FDF1AA00000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3, "buildId" : "D0F537904076D73F29E4A37341F8A449E2EF6CD0" } ] }}
 mongod(_ZN5mongo15printStackTraceERSo+0x32) [0x13225f2]
 mongod(+0xF21749) [0x1321749]
 mongod(+0xF21F52) [0x1321f52]
 libpthread.so.0(+0x10330) [0x7fdf19860330]
 libc.so.6(gsignal+0x37) [0x7fdf194b6c37]
 libc.so.6(abort+0x148) [0x7fdf194ba028]
 mongod(_ZN5mongo13fassertFailedEi+0x82) [0x12a8662]
 mongod(+0xCA28B3) [0x10a28b3]
 mongod(__wt_eventv+0x42C) [0x1a88fcc]
 mongod(__wt_err+0x8D) [0x1a8944d]
 mongod(__wt_panic+0x24) [0x1a89834]
 mongod(+0x160A7CB) [0x1a0a7cb]
 libpthread.so.0(+0x8184) [0x7fdf19858184]
 libc.so.6(clone+0x6D) [0x7fdf1957a37d]
-----  END BACKTRACE  -----
Aborted (core dumped)

just reporting...

ztrange commented 8 years ago

I just today, using 14946 managed to install and use mongodb-org almost without problem. (I was able to fix the only problem I found)

I followed the official instructions from mongodb.com.

First, because I had a non-working attempt (on an earlier build) at following those same instructions , I did sudo apt-get purge mongodb-org* to remove it. And then I again tried to install: sudo apt-get install mongodb-org

This was almost successful but it gave some errors:

initctl: Imposible conectar con Upstar: Failed to connect to socket /com/ubuntu/upstart: Conexión rehusada
invoke-rc.d: unknown initscript, /etc/init.d/mongod not found.
runlevel:/var/run/utmp: No existe el archivo o el directorio
invoke-rc.d: policy-rc.d denied execution of start.
Configurando mongodb-org-mongos (3.2.10) ...
Configurando mongodb-org-tools (3.2.10) ...
Procesando disparadores para ureadahead (0.100.0-16) ...
Configurando mongodb-org (3.2.10) ...

But trying to use mongod, I realized it actually worked and the only problem was that I didn't have a working init script to use it with service

So, I went to the mongo repo and got myself an init script

I added this script on /etc/init.d/mongod and set it as executable sudo chmod +x /etc/init.d/mongod

And then tried to start it sudo service mongod start And it worked!

$ sudo service mongod start
initctl: Imposible conectar con Upstar: Failed to connect to socket /com/ubuntu/upstart: Conexión rehusada
 * Starting database mongod                                                                                                  [ OK ]
Robjnoble commented 8 years ago

Thank you all for this issue. I've been working thru all your suggestions.

In regard to adding the inti script, I've done everything you did but when I enter:sudo chmod +x /etc/init.d/mongo I get: chmod: cannot operate on dangling symlink ‘mongod’

ztrange commented 8 years ago

As of 14965 (with clean lxss install of xenial), I can report that it is still possible to install and run mongodb-org

After installing it with the official instructions I also had to create /data/db and chown it to mongodb:mongodb. Also I had to create /etc/init.d/mongod (copied from the repo as I said in my last post) and give it 755 permissions.

I also tried to set it to run with systemctl but had no luck.

Hope this helps someone

TestSmirk commented 7 years ago
root@SMIRK:/data# mongod -version
db version v3.4.2
git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b
OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1404
    distarch: x86_64
    target_arch: x86_64
root@SMIRK:/data# cat /etc/issue
Ubuntu 14.04.5 LTS \n \l

root@SMIRK:/data#

mkdir /data/db bedore .run as mongod without service

yuri-stepanov commented 7 years ago

Hello there. Just wanted to add, that still having an error mongod: unrecognized service, after fresh installing on a Distributor ID: Ubuntu Description: Ubuntu 16.04.3 LTS Release: 16.04 Codename: xenial WSL Regular Ubuntu fine though..

Zeioth commented 7 years ago

You can solve this issue "copy-pasting" this bash script

set -e
if grep -qE "(Microsoft|WSL)" /proc/version &> /dev/null ; then
    sudo apt-get install -y curl
    sudo rm -f /etc/init/mongodb.conf
    sudo curl --http1.1 https://raw.githubusercontent.com/mongodb/mongo/985e2a0be95709ac064c57f0a9bb385a55937285/debian/init.d --output /etc/init.d/mongod
    sudo chmod 755 /etc/init.d/mongod
    sudo mkdir -p /data/db
    sudo chown -R mongodb:mongodb /data/db
fi
sunilmut commented 7 years ago

On the latest Insider build 16273, I am able to:

apt install -y mongodb
mkdir /data/db
mongod

And, I can see the mongodb service listening on port 27017.

ghost commented 7 years ago

@Zeioth 's script resolved the issue for me.

Windows 10 Pro insider Preview Version 1703 OS Build 16281.1000

xtianus79 commented 7 years ago

Ok you shouldn't have to install the script any differently other than these few changes.... and you shouldn't have to make a directory... it's super odd to have to do it this way and where the break down is occurring I do not know but i will give instructions on how to install everything correctly at this time.

IMHO this is a large pile of hoo-diddy from someone and changes should be made... /rant.

Oh by the way, this is where i am altering the directions from.... https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

first I purged my mongo so I know everything is from scratch w/ this command: sudo apt-get purge mongodb-org*

  1. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
  2. ubuntu 16.04: echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
  3. sudo apt-get update
  4. Not in mongo's directions: but rather something i got from reading above comments: sudo apt-get install mongodb At this point the version installed by mongo is an older version... for me ie.
    mongod --version                                                                                                                             
    db version v2.6.10
  5. sudo apt-get install -y mongodb-org ***Now, everything is installed correctly
    
    mongod --version                                                                                                                             
    db version v3.4.9
    git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
    OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
    allocator: tcmalloc
    modules: none
    build environment:
    distmod: ubuntu1604
    distarch: x86_64
    target_arch: x86_64

7.  ***Lastly, per the op's @Zx-EvM  && @aseering above states that instead of the start command of mongod you would use the following command to start mongo:
`sudo service mongodb start`

So what does this do in summary?  

It installs mongod DB on an ubuntu 16.0.4 linux Windows subsystem... Updates it... and runs it via the start command... hope this helps someone and everything in this thread was awesome but a little verbose and not to the point which is what this summary is for.  
aankasman commented 6 years ago

I have tried tips from @xtianus79 and it worked well. Here's what I did,

  1. me@Home-PC:~$ sudo apt-get purge mongodb-org* Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'mongodb-org-unstable-tools' for glob 'mongodb-org' Note, selecting 'mongodb-org-mongos' for glob 'mongodb-org' Note, selecting 'mongodb-org-tools' for glob 'mongodb-org' Note, selecting 'mongodb-org-unstable-server' for glob 'mongodb-org' Note, selecting 'mongodb-org-unstable-shell' for glob 'mongodb-org' Note, selecting 'mongodb-org-shell' for glob 'mongodb-org' Note, selecting 'mongodb-org-unstable-mongos' for glob 'mongodb-org' Note, selecting 'mongodb-org-unstable' for glob 'mongodb-org' Note, selecting 'mongodb-org' for glob 'mongodb-org' Note, selecting 'mongodb-org-server' for glob 'mongodb-org' Package 'mongodb-org-unstable' is not installed, so not removed Package 'mongodb-org-unstable-mongos' is not installed, so not removed Package 'mongodb-org-unstable-server' is not installed, so not removed Package 'mongodb-org-unstable-shell' is not installed, so not removed Package 'mongodb-org-unstable-tools' is not installed, so not removed Package 'mongodb-org' is not installed, so not removed Package 'mongodb-org-mongos' is not installed, so not removed Package 'mongodb-org-server' is not installed, so not removed Package 'mongodb-org-shell' is not installed, so not removed Package 'mongodb-org-tools' is not installed, so not removed The following package was automatically installed and is no longer required: snap-confine Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Then following steps took place

  1. me@Home-PC:~$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 Executing: /tmp/tmp.6onMrC2S0j/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 gpg: requesting key A15703C6 from hkp server keyserver.ubuntu.com gpg: key A15703C6: public key "MongoDB 3.4 Release Signing Key packaging@mongodb.com" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)

  2. me@Home-PC:~$echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse

  3. me@Home-PC:~$sudo apt-get update Ign:1 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 InRelease Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB] Get:3 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release [3,457 B] Hit:4 https://deb.nodesource.com/node_7.x xenial InRelease Ign:5 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 InRelease Hit:6 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 Release Get:7 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release.gpg [801 B] Hit:8 http://archive.ubuntu.com/ubuntu xenial InRelease Get:10 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB] Get:11 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages [8,276 B] Get:12 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse arm64 Packages [8,284 B] Fetched 225 kB in 8s (25.7 kB/s) Reading package lists... Done

  4. me@Home-PC:~$ sudo apt-get install mongodb Reading package lists... Done Building dependency tree Reading state information... Done mongodb is already the newest version (1:2.6.10-0ubuntu1). The following package was automatically installed and is no longer required: snap-confine Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

  5. me@Home-PC:~$sudo service mongodb start

    • Starting database mongodb
  6. me@Home-PC:~$ mongod --version db version v2.6.10 2017-12-20T01:41:55.949+0700 git version: nogitversion 2017-12-20T01:41:55.950+0700 OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016

And finally get worked as resulted below 💯

  1. me@Home-PC:~$ mongo MongoDB shell version: 2.6.10 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user
  2. exit bye me@Home-PC:~$

therealkenc commented 6 years ago

MongoDB proper is operable on recent WSL following the canonical install instructions verbatim. On Ubuntu 16.04 (the most recent cited in the instructions) and 17672....

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt-get update
sudo apt-get install -y mongodb-org
mongod --version

Yields:

db version v3.6.5
git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1604
    distarch: x86_64
    target_arch: x86_64

The remaining gap is that we don't have systemd, which causes the postinstall script to fail softly and silently. As a result, sudo service mongod fails with unrecognized service. I tried the exact sequence above in a Xenial VM and the mongod service is available. There is a related discussion here with a proposed solution. Or you can just start the thing manually.

sudo /usr/bin/mongod --fork --config /etc/mongod.conf

The other way to go is use Ubuntu's mongodb, which is patched to be a little friendlier about (lets call it) legacy init scripts. sudo apt install mongodb. In this case service mongodb start (sic with a 'b') takes. But the OP in this issue# was about installing mondodb-org's package, and Ubuntu's version might or might not be how you want to roll.

Postinstall scripts that depend on the existence of a functioning systemd is a different kettle of fish and not specific to mongodb. If anyone does find further issues with mongodb (like #645), please do feel encouraged to open a new issue.

benjaminbauer commented 6 years ago

@therealkenc Thanks a lot for the hint! You mean sudo mongod --fork --config /etc/mongod.conf, right?

therealkenc commented 6 years ago

You mean sudo mongod --fork --config /etc/mongod.conf, right?

Correct. Bad combination of typing and then changing mind and pasting what was actually in my terminal. I've fixed up the post. Or even more correctly, "whatever works", laugh.

Mikeysax commented 6 years ago

For anyone wondering how to get the latest mongodb-org working with WSL: https://gist.github.com/Mikeysax/cc86c30903727c556bcce960f7e4d59b

MajidJafari commented 5 years ago

I had also problem installing mongodb on wsl. You might check my answer on another issue related to this one: https://github.com/Microsoft/WSL/issues/3286#issuecomment-449053033

gigamesh commented 5 years ago

@Mikeysax Thanks a lot for that tutorial! It helped me get everything working but I'm getting "WARNING: shell and server versions do not match" (shell version v4.0.6, server version: 3.6.3). Restarting the service doesn't work. Any ideas?

nevergiveup777 commented 5 years ago

I had the same problem to install MongoDB on Ubuntu 18.04 (WSL) and I sorted out by just running:

sudo apt-get install mongodb

Not sure why this solution wasn't commented before.

Source: https://medium.com/@zhanxucong/installing-mongodb-and-redis-on-wsl-2038a2f6a0a9

therealkenc commented 5 years ago

Not sure why this solution wasn't commented before.

[a.] It was (quoth: "The other way to go is use Ubuntu's mongodb") and [b.] The ask was for mongodb-org not mongodb. This issue wouldn't even be on the books if the ask was mongodb.

Roaim commented 4 years ago

I was able to fix it by performing following tasks:

sudo nano /etc/init.d/mongod

then copy and paste the content from this url and save it (you can use vim or any other text editor)

After that give executable permission

sudo chmod +x /etc/init.d/mongod

Now you will be able to start the service by following command

sudo service mongod start
ais-one commented 4 years ago

I was able to fix it by performing following tasks:

sudo nano /etc/init.d/mongod

then copy and paste the content from this url and save it (you can use vim or any other text editor)

After that give executable permission

sudo chmod +x /etc/init.d/mongod

Now you will be able to start the service by following command

sudo service mongod start

This is correct. Somehow for the mongodb-org package (the package described in MongoDB documentation) on WSL Ubuntu (tried on 18.04), the service is not created.

If you use sudo apt-get install mongodb you are actually installing and using a different package which may not have an updated version of MongoDB.

bn-l commented 3 years ago

I was able to fix it by performing following tasks:

sudo nano /etc/init.d/mongod

then copy and paste the content from this url and save it (you can use vim or any other text editor)

After that give executable permission

sudo chmod +x /etc/init.d/mongod

Now you will be able to start the service by following command

sudo service mongod start

I tried this and got this:

fail

ais-one commented 3 years ago

I had moved on to using Docker. Since Docker works well with WSL on Windows Home Edition 2004