MongoDB with Async Python Transcripts
Chapter: Deployment
Lecture: Configuring MongoDB, Part 1

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now that we have MongoDB set up, we need to configure it. So let's go back to the server. I can't remember if we actually set enable MongoDB.
0:12 No, it looks like we didn't. So make sure you also do the enable or this thing won't start over. Okay, it won't start again if you restart the server.
0:21 So now the instructions say C settings for etc/mongoconf. slash Mongo conf. That means this file over here. So when we did apt install MongoDB dash
0:34 org, we got file not folder over here, it created this with a bunch of defaults. So
0:41 you can see this is where the log file goes. But look, it's on port 27017. And we said
0:47 we don't want that. But this is one of the really big changes they made, I guess probably around 2017 that is really nice.
0:54 It said, by default, do not listen on the public internet. It's just localhost, nothing else. So no one can get to this server from the outside.
1:03 And this is where we go back to our virtual private network. Remember, I said, what we're gonna do is only let it be visible on the network.
1:11 How do we do that? Well, here's its VPC IP address. If I want it public on the internet, I could say, listen on that address.
1:21 then I'd have to go back to my uncomplicated firewall and be real careful about what I let actually get through on that IP address.
1:28 But here, long as you trust this virtual network, which is the heart of our data center basically,
1:34 this should be a pretty safe option to let it listen here. So we're gonna change that. And let's go back.
1:43 And we're gonna change it to the port as well. So we said 5621. Okay, that's pretty good.
1:58 We also want to require SSL, but let's hold off just a minute on that.
2:03 The time zone is good. Authorization, we're also going to hold off on that because we have to
2:08 first connect to it and create a user. But let's just see that this is working here. I'll go ahead and copy this storage part over.
2:19 Oops, if I remember the R. Just to be super explicit about this part. Those are mostly defaults, but I just want to be clear.
2:32 Okay, so here's the data folders, /var/lib. Here's the log files, /var/log/mongodb. if you need to get to either of those.
2:44 All right, let's write that out and we should be able to exit. And then we had sys, remember I had you install all my Z shell
2:53 because if we just hit up arrow, beautiful. Those are all the, those settings, right? So we want to, let's try restart and then we can run status.
3:06 Perfect, still listening. Let's just try to connect to it to make sure that we still can. So mongosh, mongoshel. This should time out, it said error,
3:19 because look what it tried to connect to. This right here, default address. So let's go ahead and try to connect with the port of 5621.
3:31 Again, it's using the wrong host. So we'll say host, and we wanna use our IP address. Yeah, we're already on the server,
3:40 but this is the one it's listening on, right? Here we go. Excellent, excellent. So it gives us some warning like, access control is not enabled.
3:49 Yes, we know we're gonna come back. I'm gonna go ahead and just disable telemetry for this 'cause I don't care about it.
3:55 This is not a real system, is it? Okay, so things are looking good. Well, let me just connect one more time.
4:02 All right, it still has a couple of warnings, but we're going to disregard those for the minute. Notice we're running 606 for the MongoDB version.
4:13 Here's our Mongo shell version. Here's the connection string that the shell used to connect when we gave it those command line arguments.
4:22 And this thing is nowhere near ready for putting in production. We need to go back and turn on SSL and all those things.
4:31 But this part of getting it installed, get it set up, get it listing on a different IP address and a different port. That's all good.
4:39 Looks like we have it working here.


Talk Python's Mastodon Michael Kennedy's Mastodon