Install MongoDB in Windows Linux Subsystem
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 ?
@XSmeets services are unimplemented for now but if I install mongodb with sudo apt-get install mongodb sudo service mongod start will work
@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
@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.
@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/
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.
@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.
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.
@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
>
@aseering oh. Thanks! It's work for me
@aseering That worked :D thanks.
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
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 <[email protected]>" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)
Many thanks!!
@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
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!
@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...
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?
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.
This is not a WFL problem, the problem is with Ubuntu 14.04:
- Relevant question on StackOverflow: http://serverfault.com/questions/746348/mongodb-install-fails-in-ubuntu-14-04-docker-container
- Correct installation guide for Ubuntu: https://docs.mongodb.com/master/tutorial/install-mongodb-on-ubuntu/ (Make sure to follow instructions for Ubuntu 14.04)
@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#
- Blake Schwartz
On Wed, Sep 21, 2016 at 4:39 AM, Anton Suprun [email protected] wrote:
This is not a WFL problem, the problem is with Ubuntu 14.04:
- Relevant question on StackOverflow: http://serverfault.com/ questions/746348/mongodb-install-fails-in-ubuntu-14-04-docker-container http://serverfault.com/questions/746348/mongodb-install-fails-in-ubuntu-14-04-docker-container
- Correct installation guide for Ubuntu: https://docs.mongodb.com/ master/tutorial/install-mongodb-on-ubuntu/ https://docs.mongodb.com/master/tutorial/install-mongodb-on-ubuntu/ (Make sure to follow instructions for 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 .
@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')