Eve: Building RESTful APIs with MongoDB and Flask Transcripts
Chapter: Appendix: Installing MongoDB
Lecture: Setting up MongoDB on Linux

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Are you taking this class using your Linux desktop?
0:03 Well, let's get your machine all set up and configured with MongoDb.
0:07 So here we are just on the homepage mongodb.com,
0:10 I am going to go click download, and it's totally possible to click and say
0:16 download the tarball, but we could also say I would like to see
0:19 how to set this up on let's say Ubuntu, as you change this,
0:23 notice different things happen, so if we go to Amazon
0:27 it says here are instructions for installing with yum, that's the package manager there,
0:31 if I go to Ubuntu, so here's the instructions for installing with aptitude,
0:34 so we're going to go over here to that one,
0:36 make sure you pick the right distribution, do we want to read this— no.
0:40 So there's a couple of steps that we need to go through
0:43 and they're pretty simple, most importantly they just like walk us through it
0:47 so notice here that there is a package named mongodb.org
0:52 let's try to just install that, sudo apt install that,
1:00 oh it needs my password, okay, and nope, there's no mongodb,
1:05 darn, doesn't it say right here, here's how you install all the pieces?
1:08 It is true, but we got to go through a few steps to get there.
1:11 So first thing that we got to do is basically add a source to aptitude,
1:16 so we're going to go over here, and we're going to set a key,
1:19 so you're just going to go through a few copy paste steps,
1:21 so we're going to do our apt key here, it takes a moment,
1:26 and all right, that's all good, next thing to do
1:28 is we're going to create a list file, all right, great.
1:34 Be really careful about the version numbers here,
1:38 later is probably better, pick the one that matches yours.
1:40 So the next thing we need to do, is run a sudo apt update
1:44 and you can do apt.get or just apt, whatever
1:47 but you need to tell it hey, go pull all the sources
1:50 now the new one included and just have that list there.
1:53 We don't need to back up anything, so go away.
1:58 Alright, now everything is registered, we're pointing at the right package source,
2:02 we've updated it, now we can go over here and do
2:05 our thing that we tried to do originally.
2:08 So we wanted a sudo apt installed mongodb.org,
2:14 this time it knows what that means, hey look that's mongodb,
2:18 mongos which is a sharding server, mongo server, mongo shell, mongo tools,
2:22 I am just going to install them all.
2:29 Perfect, okay, so we have MongoDB all set up and ready to go,
2:35 and now we can just type mongo, and it tries to connect,
2:40 we have mongo now but we really need to start it.
2:51 So we started up mongod, great, now we can connect to it.
2:56 Awesome so it has some warnings again about access control
2:59 when we get to the deployment chapter,
3:02 we're actually going to set up Ubuntu as a cloud server
3:05 with some of these errors removed,
3:07 we're going to set it up with access control, with authentication,
3:10 with firewalls, all sorts of things, but for now, for the dev version,
3:13 we're going to just use this, okay.
3:16 So it looks like it's up and running, that's cool,
3:19 now the last thing is maybe we want to configure our server;
3:22 so, we can come over here to /etc/mongod/conf
3:30 and you can see we've got our storage path,
3:33 like here's where our data files are going to go, change that if you like,
3:36 journaling, you generally want that on,
3:38 it's going to be running with wired tiger,
3:41 it is an older style of database storage engine called this mmapv1,
3:45 that's how things used to work, they've switched the default to wired tiger
3:49 because it's faster, I believe it's much faster for inserts a little faster for reads,
3:53 here's where the log file goes, if it's not working and you want to see what's going on.
3:58 So most importantly though is this bit right there, this bindIp.
4:02 So the bindIp is set to, we should have our firewall turned on anyway,
4:08 we shouldn't be exposing this port, but we're only listening on the local host,
4:13 I think this machine actually right now has two ip adresses,
4:16 one public ipv6 and one net ipv4 ip address,
4:21 but it's not listening on either of them because of this, right.
4:24 So it's super important that this is here,
4:27 otherwise if someone can get to this port on your machine
4:30 and you don't set up authentication, bad things happen.
4:33 All right, so make sure this is here,
4:36 and only change that on your staging servers
4:38 and other things where you control the network, much more carefully.
4:41 Again, we'll talk way more about this in the deployment section
4:44 but for now, this should do for our development environment.
4:47 The other things we'll have to do is we want to set up a RoboMongo,
4:50 we want to set up PyCharm, and we want to make sure
4:54 that we have Python 3 on here, I believe we do, 3.5.3 is more than late enough,
5:00 so we don't need to install any Python,
5:02 but be sure to get RoboMongo and PyCharm,
5:05 whichever version you want set up so that you can follow along.