-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-shards
More file actions
executable file
·57 lines (37 loc) · 1.34 KB
/
Copy pathcreate-shards
File metadata and controls
executable file
·57 lines (37 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
mkdir /data/shards
cd /data/shards
mkdir s0 s1 s2 s3
mongod --dbpath /data/shards/s0 --port 25000 --fork --logpath /data/shards/0.log
mongod --dbpath /data/shards/s1 --port 25001 --fork --logpath /data/shards/1.log
mongod --dbpath /data/shards/s2 --port 25002 --fork --logpath /data/shards/2.log
mongod --dbpath /data/shards/s3 --port 25003 --fork --logpath /data/shards/3.log
mongod --dbpath /data/shards/c --port 25999 --fork --logpath /data/shards/c.log
mongos --port 25017 --configdb localhost:25999 --fork --logpath /data/shards/s.log
mongo localhost:25017
>
sh.addShard("localhost:25000")
sh.addShard("localhost:25001")
sh.addShard("localhost:25002")
sh.addShard("localhost:25003")
mongoimport --host localhost:25017 --db twitter --collection tweets < ~/work/training/data/sampledata/twitter.json
use zips
db.zipcode.ensureIndex({zip:1});
sh.enableSharding("zips")
sh.shardCollection("zips.zipcode", {zip:1})
1) setup mongod on a1/a2/a3
2) Edit mongod.conf on a1/a2/a3
dbpath=/data
replSet = rs
comment out: bind_ip=127.0.0.1
3) start mongod
4) Initialize replica set
rsconf = {
_id: "rs", members: [
{ _id: 0 , host:'tja1.mongodb.ga:27017' },
{ _id: 1, host:'tja2.mongodb.ga:27017' },
{_id: 2, host:'tja3.mongodb.ga:27017'}
]
};
rs.initiate(rsconf);
5) Install monitoring agent and start
6)