1. MongoDB Sharding Cluster Installation Guide
Version Author Abstract Release date
0.1 Philip zhong Draft 2012-07-09
Deployment Architecture ................................................................................................................... 2
Prepare Servers ................................................................................................................................. 2
2. Deployment Architecture
Prepare Servers
Shard Name Primary Instance server Second Instance server Mongos Server Config Server
Shard1 10.224.56.105:27017 null 10.224.56.105:30000 10.224.57.165:20000
Shard2 10.224.56.106:27017 null 10.224.56.106:30000 10.224.57.165:20000
Shard3 10.224.56.107:27017 null 10.224.56.107:30000 10.224.57.165:20000
Shard4 10.224.56.108:27017 null 10.224.56.108:30000 10.224.57.165:20000
Shard5 10.224.56.109:27017 null 10.224.56.109:30000 10.224.57.165:20000
Shard6 10.224.56.110:27017 null 10.224.56.110:30000 10.224.57.165:20000
Shard7 10.224.56.111:27017 null 10.224.56.111:30000 10.224.57.165:20000
Shard8 10.224.56.112:27017 null 10.224.56.112:30000 10.224.57.165:20000
Shard9 10.224.56.113:27017 null 10.224.56.113:30000 10.224.57.165:20000
Shard10 10.224.56.114:27017 null 10.224.56.114:30000 10.224.57.165:20000
*Notice:
1. You can install Mongos to another single server.
3. 2. You can use three config servers to improve the High availability.
3. You can install three replica set to improve the High availability.
1. Install Primary/secondary Instance program on every shard
instance server.
Please refer to << MongoDB_Program_Installation_Guide.doc>>
#su - root
# mkdir -p /data/mongo
# mkdir -p /var/log/mongo/
# chown -R mongodb:mongodb /data/mongo
# chown -R mongodb:mongodb /var/log/mongo
# mkdir -p /data/mongo/shard1/
#numactl --interleave=all /opt/mongodb206/bin/mongod --shardsvr --replSet shard1 --port
27017 --dbpath /data/mongo/shard1 --oplogSize 100 --logpath /var/log/mongo/mongod.log --
logappend --fork --journal
* Notice:
1. You can change it by you install directory.
2. If you have secondary replica set, you can start primary replica set with nojournal
2. Initiate MongoDB replica set on every shard instance server.
# /opt/mongodb206/bin/mongo
>config = {_id: 'shard1' , members:
[
{_id: 0, host: '10.224.56.105:27017'}
]
}
>rs.initiate(config)
4. * Notice:
1. If you want to add secondary replica set, you can add the server and port into Initiation.
3. Install config program on config server
Please refer to << MongoDB_Program_Installation_Guide.doc>>
#su - mongodb
# mkdir -p /data/mongo/config
# numactl --interleave=all /opt/mongodb206/bin/mongod --configsvr --dbpath
/data/mongo/config --port 20000 --logpath /data/mongo/config/config.log --logappend --fork
4. Install mongos program on every shard mongos server
If mongos server and mongoDB instance are not in same server, please refer to <<
MongoDB_Program_Installation_Guide.doc >>
#su -root
# mkdir -p /var/log/mongo/
# chown -R mongodb:mongodb /var/log/mongo
#su - mongodb
#/opt/mongodb206/bin/mongos --configdb 10.224.57.165:20000 --port 30000 --chunkSize
1000 --logpath /var/log/mongo/mongos.log --logappend –fork
5. Configure Shard Cluster
Login one mongos server, For example:
#/opt/mongodb206/bin/mongo 10.224.56.114:30000/admin
>db.runCommand ({addshard:"shard1/10.224.56.105:27017",name:"s1",maxsize:20480});
>db.runCommand({addshard:"shard2/10.224.56.106:27017",name:"s2",maxsize:20480});
>db.runCommand({addshard:"shard3/10.224.56.107:27017",name:"s3",maxsize:20480});
>db.runCommand({addshard:"shard4/10.224.56.108:27017",name:"s4",maxsize:20480});
>db.runCommand({addshard:"shard5/10.224.56.109:27017",name:"s5",maxsize:20480});
>db.runCommand({addshard:"shard6/10.224.56.110:27017",name:"s6",maxsize:20480});
6. 6. Trouble shooting
#on testing ENV, you need turn off firewall and then you need restart the mongo programs.
#/etc/init.d/iptables status
#/etc/init.d/iptables stop
#/etc/init.d/iptables status
#chkconfig iptables off
7. Install Monitor program
???