1
1

00:00:00,370  -->  00:00:01,700 line:15% 
<v Jose>Hi, and welcome back.</v>
2

2

00:00:01,700  -->  00:00:02,690 line:15% 
In this video we're gonna look
3

3

00:00:02,690  -->  00:00:06,220 line:15% 
at installing MongoDB in our server.
4

4

00:00:06,220  -->  00:00:09,200
Installing MongoDB in Ubuntu is really easy.
5

5

00:00:09,200  -->  00:00:13,373
We'll start by doing sudo apt instal mongodb,
6

6

00:00:14,360  -->  00:00:16,170
then just press Enter when it asks you
7

7

00:00:16,170  -->  00:00:17,370
if you want to continue.
8

8

00:00:19,290  -->  00:00:20,160
That's it.
9

9

00:00:20,160  -->  00:00:22,680
That's MongoDB installed and usually
10

10

00:00:22,680  -->  00:00:24,960
it'll already be running.
11

11

00:00:24,960  -->  00:00:26,090
You can check whether it's running
12

12

00:00:26,090  -->  00:00:28,900
by doing sudo systemctl,
13

13

00:00:28,900  -->  00:00:30,430
which is the system controller,
14

14

00:00:30,430  -->  00:00:32,800
status mongodb.
15

15

00:00:32,800  -->  00:00:35,870
And, here you can see that it is already running.
16

16

00:00:35,870  -->  00:00:39,420
That's because installing MongoDB in this way
17

17

00:00:39,420  -->  00:00:41,380
sets it as a service.
18

18

00:00:41,380  -->  00:00:44,890
That means that it already will run
19

19

00:00:44,890  -->  00:00:46,910
when your server restarts.
20

20

00:00:46,910  -->  00:00:48,120
If you want to disable that
21

21

00:00:48,120  -->  00:00:52,940
you can do sudo systemctl disable mongodb.
22

22

00:00:52,940  -->  00:00:53,990
If you do that you'll have
23

23

00:00:53,990  -->  00:00:56,804
to start and stop MongoDB manually.
24

24

00:00:56,804  -->  00:00:59,030
Of course, you can do sudo systemctl start mongodb
25

25

00:01:00,640  -->  00:01:05,340
to start it or you can do sudo systemctl stop mongodb
26

26

00:01:05,340  -->  00:01:06,173
to stop it.
27

27

00:01:07,610  -->  00:01:09,260
If you've got MongoDB installed,
28

28

00:01:09,260  -->  00:01:11,340
that means that you can do mongo
29

29

00:01:11,340  -->  00:01:13,970
to connect to MongoDB and you can see
30

30

00:01:13,970  -->  00:01:15,160
that this has connected
31

31

00:01:15,160  -->  00:01:17,260
and it doesn't give you an error.
32

32

00:01:17,260  -->  00:01:20,790
So, you can go ahead and use MongoDB
33

33

00:01:20,790  -->  00:01:23,040
as we had it installed here.
34

34

00:01:23,040  -->  00:01:26,490
Now, you do get a couple warnings
35

35

00:01:26,490  -->  00:01:28,950
when you are using MongoDB.
36

36

00:01:28,950  -->  00:01:30,780
The first one is about the file system.
37

37

00:01:30,780  -->  00:01:32,840
Using the XFS file system is strongly recommended
38

38

00:01:32,840  -->  00:01:34,780
with the WiredTiger storage engine.
39

39

00:01:34,780  -->  00:01:37,860
This is a warning that we can't realistically action
40

40

00:01:37,860  -->  00:01:41,730
when we're using an Ubuntu version of DigitalOcean.
41

41

00:01:41,730  -->  00:01:43,370
That's because it's asking us to use
42

42

00:01:43,370  -->  00:01:46,120
an entirely different way of storing our documents
43

43

00:01:46,120  -->  00:01:48,410
than what DigitalOcean provides.
44

44

00:01:48,410  -->  00:01:49,560
You can maybe change this
45

45

00:01:49,560  -->  00:01:52,640
but it would be a little bit tricky.
46

46

00:01:52,640  -->  00:01:54,460
The other one is that access control
47

47

00:01:54,460  -->  00:01:57,010
is not enabled for the database.
48

48

00:01:57,010  -->  00:01:58,670
At the moment that's not a problem,
49

49

00:01:58,670  -->  00:02:01,590
this becomes a big problem if your database
50

50

00:02:01,590  -->  00:02:04,140
is open to the outside world.
51

51

00:02:04,140  -->  00:02:06,320
Now, your database at the moment
52

52

00:02:06,320  -->  00:02:09,580
is only running locally in the server
53

53

00:02:09,580  -->  00:02:10,920
that we're currently in.
54

54

00:02:10,920  -->  00:02:13,960
That means that only a logged in user to the server
55

55

00:02:13,960  -->  00:02:18,420
or an application running in this server can access MongoDB.
56

56

00:02:18,420  -->  00:02:21,490
If you want applications in other servers
57

57

00:02:21,490  -->  00:02:23,180
to be able to access MongoDB
58

58

00:02:24,100  -->  00:02:27,190
then you need to setup access control,
59

59

00:02:27,190  -->  00:02:28,910
that is so that
60

60

00:02:29,830  -->  00:02:32,310
other applications only have read and write access
61

61

00:02:32,310  -->  00:02:33,963
to certain data.
62

62

00:02:34,810  -->  00:02:37,230
Something else you can setup for extra security
63

63

00:02:37,230  -->  00:02:39,630
in the server, even though only applications
64

64

00:02:39,630  -->  00:02:41,580
in this server can access MongoDB
65

65

00:02:41,580  -->  00:02:43,490
is some access control anyway
66

66

00:02:43,490  -->  00:02:45,710
so that only certain users
67

67

00:02:45,710  -->  00:02:49,010
can access certain databases in MongoDB.
68

68

00:02:49,010  -->  00:02:52,110
Think of it as another layer of user accounts
69

69

00:02:52,110  -->  00:02:54,230
just for MongoDB.
70

70

00:02:54,230  -->  00:02:55,100
We're not going to look
71

71

00:02:55,100  -->  00:02:56,700
at setting that up in this course
72

72

00:02:56,700  -->  00:02:59,610
but the MongoDB documentation is quite good
73

73

00:02:59,610  -->  00:03:02,810
and it guides you well through how to set all of that up.
74

74

00:03:02,810  -->  00:03:04,210
So, again, particularly important
75

75

00:03:04,210  -->  00:03:05,960
if you wanna open up your database
76

76

00:03:05,960  -->  00:03:07,130
to the outside world,
77

77

00:03:07,130  -->  00:03:08,880
for example, if you have multiple servers
78

78

00:03:08,880  -->  00:03:12,940
that wanna interact with one central MongoDB server,
79

79

00:03:12,940  -->  00:03:14,493
or if you want extra security.
80

80

00:03:15,680  -->  00:03:17,310
But, that's MongoDB installed,
81

81

00:03:17,310  -->  00:03:18,220
if you wanna exit,
82

82

00:03:18,220  -->  00:03:21,350
of course you can always do Control + C
83

83

00:03:21,350  -->  00:03:23,510
and remember that as you restart your server
84

84

00:03:23,510  -->  00:03:25,570
MongoDB will start running again
85

85

00:03:25,570  -->  00:03:26,510
so you don't have to worry
86

86

00:03:26,510  -->  00:03:28,850
about stopping it and starting it.
87

87

00:03:28,850  -->  00:03:30,990
That's it for this video, thank you for joining me.
88

88

00:03:30,990  -->  00:03:32,440
I'll see you in the next one.
