1 00:00:02,280 --> 00:00:07,830 So there's a bunch of stuff we can configure and what exactly can we configure there or what could 2 00:00:07,830 --> 00:00:09,080 be interesting to us? 3 00:00:09,360 --> 00:00:15,090 Well things like quiet allow you to change the way things get logged or output by the server 4 00:00:15,120 --> 00:00:19,430 and if you feel like it's talking too much to you, you can control that with quiet 5 00:00:19,680 --> 00:00:25,520 and obviously check out the official docs for more detailed explanations of all the options. Interesting 6 00:00:25,520 --> 00:00:34,130 to us is the log path and also another setting, the db path which you can find a bit further down towards 7 00:00:34,130 --> 00:00:35,390 the end of this list. 8 00:00:35,690 --> 00:00:42,350 These two path allow you to configure where your data gets stored in the case of db path because 9 00:00:42,370 --> 00:00:47,020 mongodb of course does write your data to real files on your system, 10 00:00:47,150 --> 00:00:52,970 so the db path is where these files will live and the log path is essentially where the logs will 11 00:00:52,970 --> 00:00:58,340 be written to and the logs are interesting because in the logs, you can then see for example warnings 12 00:00:58,340 --> 00:01:01,370 of json schema validation, warnings 13 00:01:01,370 --> 00:01:08,960 if you set the validation action to warning, what we did in a previous module. So log path and db 14 00:01:08,960 --> 00:01:10,220 path can be set, 15 00:01:10,220 --> 00:01:12,130 now how do we set this? 16 00:01:12,200 --> 00:01:16,280 I'm in my mongodb folder and there, I got that bin folder 17 00:01:16,280 --> 00:01:22,060 Now in this mongodb folder, I'll create a new path and I'll name it db and I'll create another 18 00:01:22,070 --> 00:01:24,360 new folder and I'll name it 19 00:01:24,390 --> 00:01:27,610 logs, you can name these folders however you want. 20 00:01:27,620 --> 00:01:33,140 Now these are two new folders and I want to use the db folder for my db files and the logs folder 21 00:01:33,140 --> 00:01:40,310 for my logs, the default setting for db is that it will use my root folder and there, the data db folder, 22 00:01:40,370 --> 00:01:42,490 that is the default setting of mongodb 23 00:01:42,530 --> 00:01:47,240 and if you start a mongod instance without any additional setting, it will use that folder 24 00:01:47,480 --> 00:01:51,550 but you can tell it to use another folder. And the same is true for the logs, 25 00:01:51,560 --> 00:01:58,220 you can tell it to not output its log messages in the window where you started the mongod's instance 26 00:01:58,490 --> 00:02:00,410 but instead into a separate file 27 00:02:00,440 --> 00:02:04,150 and I want to do these two things. Now on Mac, 28 00:02:04,160 --> 00:02:12,200 I can get the path to my db folder by clicking on it with a right click and then get info and then copying 29 00:02:12,200 --> 00:02:14,700 that path, on windows in the explorer, 30 00:02:14,720 --> 00:02:19,700 you can of course just copy that url by clicking into it once it becomes a full url and 31 00:02:19,700 --> 00:02:21,080 then copying that. 32 00:02:21,470 --> 00:02:28,540 And now if I want to start my mongodb server with that path being used, I can run sudo mongod 33 00:02:28,670 --> 00:02:34,040 or on Windows, it would just be Mongod --dbpath like this, 34 00:02:34,190 --> 00:02:35,000 then a blank 35 00:02:35,120 --> 00:02:39,620 and then the path. And now important, I just copied the path to my mongodb folder, 36 00:02:39,620 --> 00:02:47,570 of course I should point to the slash db folder, on windows its /db. Hit enter and enter your 37 00:02:47,570 --> 00:02:48,840 password if you have to 38 00:02:48,890 --> 00:02:54,560 And this should bring up your mongod server as it worked in the past but now you should see that in 39 00:02:54,560 --> 00:02:59,930 the db folder, it created a bunch of files because now it's storing the data here and therefore this is 40 00:02:59,930 --> 00:03:04,290 now using a totally different database storage than it previously did, 41 00:03:04,340 --> 00:03:07,130 it's totally detached from our old database path, 42 00:03:07,130 --> 00:03:12,620 we have a brand new database set up now because we're using a different file storage for the database 43 00:03:12,620 --> 00:03:16,430 files. Now logging would also be interesting, 44 00:03:16,430 --> 00:03:20,350 so let me quickly clear the window to make it easier to read, 45 00:03:20,360 --> 00:03:24,490 let me quickly rerun sudo mongod here with db path 46 00:03:24,710 --> 00:03:30,220 but I'll set an additional flag separated with a blank and then --logpath 47 00:03:30,590 --> 00:03:33,760 and now I want to use almost the same path, 48 00:03:35,230 --> 00:03:35,960 this one, 49 00:03:36,270 --> 00:03:43,270 however it should be /logs and and that's important to know, the logs, the log path needs the path 50 00:03:43,290 --> 00:03:44,970 to a log file, 51 00:03:45,180 --> 00:03:51,860 so here you could add log.log for example. If you hit enter, 52 00:03:51,980 --> 00:03:57,770 this now starts the server but you see way less output here because now if you look into logs, you should 53 00:03:57,770 --> 00:03:59,660 have a log.log file, 54 00:03:59,660 --> 00:04:02,200 now all the output gets written into that file 55 00:04:02,360 --> 00:04:06,860 and that of course can be useful because now this file will get saved and you can always come back 56 00:04:06,860 --> 00:04:07,320 to it, 57 00:04:07,400 --> 00:04:09,590 check your logs from yesterday, 58 00:04:09,590 --> 00:04:10,720 go through it, 59 00:04:10,850 --> 00:04:16,430 see any warnings or errors you might have in there, like this warning that access control is not enabled 60 00:04:16,490 --> 00:04:19,330 which is the default right now, we got no authentication, 61 00:04:19,370 --> 00:04:20,450 we'll add it later. 62 00:04:20,690 --> 00:04:22,690 So this can be useful for 63 00:04:22,820 --> 00:04:30,810 well persist and error searching or for simply persistent and auditing of your server. 64 00:04:31,160 --> 00:04:37,250 So this now is how you can set a custom path for your logs and how you can set a custom path for your 65 00:04:37,250 --> 00:04:39,370 database. What else can we do?