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