MongoDB for Developers with Python Transcripts
Chapter: Deploying MongoDB in production (and playing it safe)
Lecture: Concept: MongoDB admin tools
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
We've seen that we can use our ssh as a tunnel to give us access to our production MongoDB server without exposing too much of it.
0:11
So we can run this ssh command to the Mongo server and say map locally the port 10001 over to the machine called local host over
0:19
in your area Mongo server to port 10001, which means we basically can connect our local host and we connect to the Mongo server on that side of things.
0:29
Once we do that, we can go to things like Robomongo, and say I'd like to connect to here local host 10001,
0:37
and the user name is whatever it is, the password is whatever it is, make sure you check perform authentication and also use ssl, check that,
0:48
you want to use the self signed certificate if that's the way you did it you saw that it doesn't work, kind of blocked me when I said certificate
0:57
because it is like no, no this is an invalid certificate we won't talk to the server, you decide how you do the certificate management
1:03
but if you followed along exactly, you want to make sure you use self signed certificate
1:06
and then ta-da, you are connected to the server just as if it was local there's a slight latency but like I said, once it spins up and starts moving
1:18
it can actually ship a lot of data over that connection pretty quickly. The other thing you might want to do is connect with the Mongo shell,
1:24
we've already seen how to do that, here's the command to do it once again remember, this is using a port 10001 on my local dev machine
1:32
tunneling through the ssh tunnel back to the server; same type of thing you put on the server, basically goes right here
1:39
as long as you have that ssh tunnel running. We can also use Mongodump and Mongodump is one of the ways in which you can back up a database
1:47
so same commands exactly except we said --db dealership output is local folder, that will dump out all that data, and like I said
1:56
this actually works pretty well over that ssh tunnel, for large amounts of data.
2:01
There you have it, we have our production MongoDB server up and running we installed it through aptitude which means
2:08
if there's update, security or otherwise it will automatically apt upgradeā boom take care of it for us,
2:14
that is really super nice, we've got over the wire encryption, we've got non default ports, we've got authentication
2:23
and we even saw how we can use ssh to still use our local dev machine we even saw how we can use ssh tunnels and our local database management tools,
2:34
Robomongo, the Mongo shell and things like that to get back into the production server and manage it,
2:40
without punching holes in the firewall for that purpose. So all in all, I'd call this a pretty good setup.