MongoDB Shard deployment under Linux

Source: Internet
Author: User

Premise: The Shard server is not set from the service and equalization service, only the primary server;
The current test is on the same physical machine for all servers.

1. Test environment: 192.168.1.55.
2. Test mode: Stand-alone.
3. Service: Shard Server 1:192.168.1.55:10001
Shard Server 2:192.168.1.55:10002
Configuration server: 192.168.1.55:20001
Routing server: 192.168.1.55:30001

4. Directory Settings:
Shard server 1:/USR/MONGODBTEST/SD1, including directory Data,log directory, configuration file
Shard server 2:/USR/MONGODBTEST/SD2, including directory Data,log directory, configuration file
Configuration server:/usr/mongodbtest/cfg1, including directory Data,log directory, configuration file
Routing server:/usr/mongodbtest/rout, log file included

5. Configuration file:
Shard server 1:
Systemlog:

destination: file
logAppend: true
path: /usr/mongodbtest/sd1/log/mg.log

Storage

dbPath: /usr/mongodbtest/sd1/data
journal:
enabled: true
engine: wiredTiger

Processmanagement:


pidFilePath: /usr/mongodbtest/sd1/mongod.pid

Net

port: 10001
分片服务器2:
类似1.
配置服务器:
多2个参数:
replication:
replSetName: set61
sharding:
clusterRole: configsvr
配置服务器:
暂用命令方式,见第8步。

6. Start the Shard and configure the server:
>./mongod--config actual configuration file path

7. Initialize the configuration server:
>./mongo 192.168.1.55:20001
>rs.initiate ({
_id: "Set61",
Configsvr:true,
members:[{_id:0, Host: "192.168.1.55:20001"}//can set more than one
]
})

8. Start the routing server:
./mongos--port 30001--configdb set61/192.168.1.55:20001--logappend--LogPath

/usr/mongodbtest/rout/rt.log --fork

9. Adding shards
>./mongo 192.168.1.55:30001
Mongos> Sh.addshard ("192.168.1.55:10001");
Mongos> Sh.addshard ("192.168.1.55:10002");

10. Activating shards
>./mongo 192.168.1.55:30001
Mongos>sh.enablesharding ("Your Database")

11. Add Tablet keys
Sh.shardcollection ("Gwgps.location", {"HostID": 1})

12. Add indexes, insert data, and more.

MongoDB Shard deployment under Linux

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.