microsoft / WSL

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

tcp keep alive error when running Mongod on Windows Bash #695

Closed alanosman closed 7 years ago

alanosman commented 8 years ago

Hello - I am trying to install mongodb (3.0) on the latest preview build (14393) of Windows Bash (I am on the fast ring and updated windows Bash today with the lxrun command).

I have a couple of issues:

  1. When we install Mongodb and run it from the command line, I see an error
2016-07-27T15:42:09.861-0400 E NETWORK  [initandlisten] can't get TCP_KEEPIDLE: errno:22 Invalid argument
2016-07-27T15:42:09.861-0400 E NETWORK  [initandlisten] can't get TCP_KEEPINTVL: errno:22 Invalid argument

When I looked up this error, it relates to not finding the keepalive interval for TCP packets over mongo.

I checked the /proc/sys/net folders and found nothing there. Is that an intentional left out or is it something i need to install. I'm not a guru at Ubuntu, but know my way around fairly well. This is an area I do not know so well so pointers would be helpful.

My other question is can I run mongod as a service (i.e. service mongod start). I don't know if that is something that the team intentionally left out or if I am doing something wrong during the installation.

I'm assuming also that mongo is something I should be able to run on Windows Bash. right?

Here's some doc on mongo and how it uses keepalive. https://docs.mongodb.com/v2.6/faq/diagnostics/

Thanks

therealkenc commented 8 years ago

645 dup.

benhillis commented 8 years ago

@alanosman You didn't do anything wrong during installation. Any files in the /proc directory are "ProcFs" files and are implemented by our driver. The /proc/sys/net is currently not implemented but it is on our backlog.

The TCP_KEEPIDLE and TCP_KEEPINTVL socket options are currently stubbed and it looks like getsockopt for those particular TCP options will return a failure (EINVAL). We have a lot of networking work on our plate post Windows 10 Anniversary Update and this definitely falls into that bucket.

alanosman commented 8 years ago

@benhillis That is awesome to hear. Shall I close this?

benhillis commented 8 years ago

I'm fine leaving the issue open, it might be useful for other people hitting the same unimplemented surface area.

alanosman commented 8 years ago

@benhillis awesome - I'll keep an eye out for the changes when they hit. You guys are doing rock solid work and it's very much appreciated by folks like me who are Windows based, but also need Liniux. This will make development a heck of a lot smoother. Thanks!

sunilmut commented 8 years ago

@alanosman - Thanks for reporting the issue and trying out WSL. We are glad to know that it is helping streamline your dev process. As @benhillis has indicated, we are looking into implementing these socket options. Please continue the feedback coming.

carpet92 commented 8 years ago

@alanosman

My other question is can I run mongod as a service (i.e. service mongod start)

I created a issue with similar problem here https://github.com/Microsoft/BashOnWindows/issues/796 and get answer https://github.com/Microsoft/BashOnWindows/issues/796#issuecomment-238048520

You can just first install mongodb with sudo apt-get install mongodb (in this case you can run mongodb with sudo service mongodb start) then without remove of this version install latest version with instructions from official website for Ubuntu 14.04

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

Now you can again run MongoDB with sudo service mongodb start and see that your version of mongodb (latest at this moment) 3.2.8

user@DESKTOP-TPQIRNP:/mnt/c/Users/User/Desktop$ sudo service mongodb start
sudo: unable to resolve host DESKTOP-TPQIRNP
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
 * Starting database mongodb                                                                           [ OK ]
user@DESKTOP-TPQIRNP:/mnt/c/Users/User/Desktop$ mongo
MongoDB shell version: 3.2.8
connecting to: test
2016-08-07T02:11:03.473-0700 E NETWORK  [thread1] can't get TCP_KEEPIDLE: errno:22 Invalid argument
2016-08-07T02:11:03.473-0700 E NETWORK  [thread1] can't get TCP_KEEPINTVL: errno:22 Invalid argument
> db.version()
3.2.8
>
bschwartz757 commented 7 years ago

Hi @Zx-EvM and all, I tried following the steps listed here and on #796 and it's still failing to run the service. Unfortunately I'm not super knowledgeable about windows services or how WSL is ideally supposed to run Mongo, but I was able to get it installed and have version 2.4.9. I ran the apt-get command above and the output looks like everything succeeded, but when I try to sudo service mongodb start it gives the following:

`root@blakes-PC:/etc# sudo service mongodb start initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused

Interestingly, I have a file named mongodb in etc/init.d/. Not sure if that's relevant but @Zx-EvM mentioned not having that on the other thread.

Any help would be appreciated - apologies if I'm missing something or my question doesn't make sense. Thanks!

aseering commented 7 years ago

Hi @bschwartz757 -- for what it's worth, I believe the upstart error is a red herring; it doesn't prevent mongodb from starting. Could you confirm that mongodb didn't start anyway? Assuming that it didn't start, could you look around a little to see if there are error logs anywhere?

Keep in mind that, if you start a background process this way, it will be terminated when you close all WSL terminals.

bschwartz757 commented 7 years ago

Thanks for the response, guys! I'll have to get back to you on that unfortunately. Assuming mongodb is in fact running, would I just be able to run mongod from a new terminal window? I'm embarrassed to say I didn't think to try that... just assumed it would start in the current window. I'll give it a shot when I'm back at my home machine and let you know.

On Tue, Sep 20, 2016 at 8:52 AM, Adam Seering notifications@github.com wrote:

Hi @bschwartz757 https://github.com/bschwartz757 -- for what it's worth, I believe the upstart error is a red herring; it doesn't prevent mongodb from starting. Could you confirm that mongodb didn't start anyway? Assuming that it didn't start, could you look around a little to see if there are error logs anywhere?

Keep in mind that, if you start a background process this way, it will be terminated when you close all WSL terminals.

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

bschwartz757 commented 7 years ago

@aseering Hmm, this looks promising - I was in fact able to get the server running (it looks like) although I had to feed it a dbpath and port - it didn't recognize the existing data/db/ folders on my Windows installation that I've been using with Git Bash. If anyone else has the same problem, this worked for me: mongod --dbpath /mnt/c/data/db/ --port 29019 although it seems to re-assign the process to a different port (30019 in my case.)

I'm able to connect from the mongo shell, but unfortunately it looks like it's still using version 2.4.9:

root@blakes-PC:/mnt/c/Windows/System32# mongo
MongoDB shell version: 2.4.9
connecting to: test
Tue Sep 20 19:57:18.518 ERROR: can't get TCP_KEEPIDLE: errno:22 Invalid argument
Tue Sep 20 19:57:18.518 ERROR: can't get TCP_KEEPINTVL: errno:22 Invalid argument
> db.version()
2.4.9

I tried re-running the apt-get command @Zx-EvM referenced above for version 3.2, and it seems to succeed, but I'm still only getting access to the older version.

Any ideas?

sunilmut commented 7 years ago

This should be fixed in the latest insider build 14971. Closing it out. If the issue persists, please let us know and we can reopen it.