/
atom.xml
76 lines (54 loc) · 2.71 KB
/
atom.xml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Category: mongodb | Coding For Fun]]></title>
<link href="http://utopiazh.github.com/blog/categories/mongodb/atom.xml" rel="self"/>
<link href="http://utopiazh.github.com/"/>
<updated>2013-03-17T10:55:50+08:00</updated>
<id>http://utopiazh.github.com/</id>
<author>
<name><![CDATA[Hang Zhou]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[Configure Sharded MongoDB on single host]]></title>
<link href="http://utopiazh.github.com/blog/2013/03/17/configure-sharded-mongodb-on-single-host/"/>
<updated>2013-03-17T10:54:00+08:00</updated>
<id>http://utopiazh.github.com/blog/2013/03/17/configure-sharded-mongodb-on-single-host</id>
<content type="html"><![CDATA[<h1>Configure Sharded MongoDB on single host</h1>
<p>The default configuration of mongodb only use a single thread, which will be
bottleneck.</p>
<h2>Config and Start mongodb</h2>
<p>Start 3 config server</p>
<pre><code>mongod --configsvr --dbpath /var/lib/mongodb/configdb/27019 --port 27019 --logpath /var/log/mongodb/mongod-27019.log --logappend &
mongod --configsvr --dbpath /var/lib/mongodb/configdb/27119 --port 27119 --logpath /var/log/mongodb/mongod-27119.log --logappend &
mongod --configsvr --dbpath /var/lib/mongodb/configdb/27219 --port 27219 --logpath /var/log/mongodb/mongod-27219.log --logappend &
</code></pre>
<p>Start 3 data server</p>
<pre><code>mongod --dbpath /var/lib/mongodb/datadb/27029 --port 27029 --logpath /var/log/mongodb/mongod-27029.log --logappend &
mongod --dbpath /var/lib/mongodb/datadb/27129 --port 27129 --logpath /var/log/mongodb/mongod-27129.log --logappend &
mongod --dbpath /var/lib/mongodb/datadb/27229 --port 27229 --logpath /var/log/mongodb/mongod-27229.log --logappend &
</code></pre>
<p>Start mongos server</p>
<pre><code>mongos --configdb 127.0.0.1:27019,127.0.0.1:27119,127.0.0.1:27219 --port 27017 --logpath /var/log/mongodb/mongos-27017.log --logappend &
</code></pre>
<h2>Add shard for standalone mongod</h2>
<p>Connect to mongos</p>
<pre><code># mongo
MongoDB shell version: 2.0.6
connecting to: test
mongos> sh.addShard("127.0.0.1:27029")
mongos> sh.addShard("127.0.0.1:27129")
mongos> sh.addShard("127.0.0.1:27229")
</code></pre>
<p>Enable shard for DB</p>
<p> mongos> sh.enableSharding("github")</p>
<p>Create Index on the to-be-sharded key</p>
<pre><code>mongos> use github
mongos> db.repos.ensureIndex({"id" :1})
</code></pre>
<p>Enable shard for collection</p>
<pre><code>mongos> sh.shardCollection("github.repos", {"id": 1})
</code></pre>
]]></content>
</entry>
</feed>