SIP Key-value Database (iii)--MONGODB distributed

Source: Internet
Author: User

SIP Key-value Database (iii)--MONGODB distributed

The random Read and write performance of a single-machine MongoDB is tested, and this section is about MongoDB distribution.

MongoDB is distributed into two types, one is replication, and the other is sharding. We mainly look at sharding.

Put a structure first:

MongoDB auto-sharding configuration is very simple, in different machines to open Shard, config server, MONGOs process can be. (assuming that the config SEREVR IP is 192.168.1.11)

Mongod--shardsvr--dbpath/var/db/mongo_shade--port 10000--fork--logpath/var/log/mongodb.log--logappend-- Nohttpinterface
Mongod--configsvr--dbpath/var/db/mongo_config/--port 20000--fork--logpath/var/log/mongodb_config.log--logappend --nohttpinterface
MONGOs--configdb 192.168.1.11:20000--fork--logpath/var/log/mongodb_shard.log--logappend

It is important to note that if you have more than one shard is intended to use IP connection, then the MONGOs also use IP to connect config server, if the machine name, you have to use the machine name. Otherwise it will be an error.

After that, use the client to connect to the MONGOs service (default or 27017 port) for distributed settings (assuming that the two shard IPs are 192.168.1.12 and 192.168.1.13, share database A's collection B)

./mongo
MongoDB Shell version:1.6.0
Connecting To:test
> Use admin
Switched to DB admin
> Db.runcommand ({addshard: "192.168.1.12:10000"})
{"shardadded": "shard0000", "OK": 1}
> Db.runcommand ({addshard: "192.168.1.13:10000"})
{"shardadded": "shard0001", "OK": 1}
> Db.runcommand ({enablesharding: "a"})
{"OK": 1}
> Db.runcommand ({shardcollection: "a.b", key: {_id:1}})
{"OK": 1}

You can then see the distributed state with Db.runcommand ({listshards:1}) or Db.printshardingstatus ().

Performance testing down to find the speed and not using the distributed time is similar to the speed, the inserted data in chunk_size units, inserted into a shade server. There is a separate balancer thread that compares the chunk numbers of each shade server and distributes them evenly. Such an algorithm obviously does not improve write performance.

Two bugs were found during the test. One is that when a shade server is broken and resumed, the balancer thread is not functioning properly, which means that all data will be inserted on one stage. -.-a very lame bug. Another is that when inserting data in safe=true mode (see Python's client document), a certain server will be killed by the system after a certain amount of time. I do not know when these two bugs can fix off.

SIP Key-value Database (iii)--MONGODB distributed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.