You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/mongodb/replica.md
+45-35Lines changed: 45 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
# User change
3
3
title: "Run YCSB using a 3 node replica set"
4
4
5
+
draft: true
6
+
5
7
weight: 5# (intro is 1), 2 is first, 3 is second, etc.
6
8
7
9
# Do not modify these elements
@@ -10,7 +12,7 @@ layout: "learningpathall"
10
12
11
13
The recommended MongoDB YCSB test setup is a relica set containing three nodes of equal size. The primary node is the node you send the YCSB traffic to and the others are secondary nodes.
12
14
13
-
## What is a replica Set?
15
+
## What is a replica set?
14
16
15
17
A replica set is a group of instances that maintain the same data set. A replica set contains many nodes, but 3 nodes are used for testing.
16
18
@@ -28,6 +30,48 @@ Install MongoDB on each node using the previously provided instructions.
28
30
29
31
Select 1 instance as the primary node and install YCSB on the instance.
30
32
33
+
## Initialize the replica set
34
+
35
+
1. Set variables with the IP addresses of each node:
36
+
37
+
```bash
38
+
PRIMARY_NODE_IP="<primary-node-ip>"
39
+
SECONDARY_NODE1_IP="<secondary-node1-ip>"
40
+
SECONDARY_NODE2_IP="<secondary-node2-ip>"
41
+
```
42
+
43
+
2. Connect to the primary node using the MongoDB shell:
44
+
45
+
```bash
46
+
mongosh --host <primary-node-ip>:27017
47
+
```
48
+
49
+
3. Initialize the replica set with the following command:
50
+
51
+
```bash
52
+
PRIMARY_NODE_IP="<primary-node-ip>"
53
+
SECONDARY_NODE1_IP="<secondary-node1-ip>"
54
+
SECONDARY_NODE2_IP="<secondary-node2-ip>"
55
+
56
+
mongosh --host $PRIMARY_NODE_IP:27017 <<EOF
57
+
rs.initiate({
58
+
_id: "rs0",
59
+
members: [
60
+
{ _id: 0, host: "$PRIMARY_NODE_IP:27017" },
61
+
{ _id: 1, host: "$SECONDARY_NODE1_IP:27017" },
62
+
{ _id: 2, host: "$SECONDARY_NODE2_IP:27017" }
63
+
]
64
+
})
65
+
EOF
66
+
```
67
+
68
+
3. Verify the replica set status:
69
+
70
+
```bash
71
+
mongosh --host $PRIMARY_NODE_IP:27017 <<EOF
72
+
rs.status()
73
+
EOF
74
+
```
31
75
32
76
## Modify the MongoDB configuration
33
77
@@ -91,40 +135,6 @@ setParameter:
91
135
92
136
If you want to use encryption you will need to add the security and keyFile to your configuration. As well as change some of the parameters in the `mongod.conf` file.
93
137
94
-
## Initialize the replica set
95
-
96
-
1. Connect to the primary node using the MongoDB shell:
97
-
98
-
```bash
99
-
mongo --host <primary-node-ip>:27017
100
-
```
101
-
102
-
2. Initialize the replica set with the following command:
0 commit comments