Preparations
- Obtain and upload the tsdbtool package to the server, and decompress it to obtain a complete software folder tsdbtool.
- Download GCC-7.3.0, CMake-3.5.2, Cython, PyYAML, Typing, and Cheetah3 source code packages to the mongodbDep folder in the tsdbtool folder. For details about the download addresses, see Table 2.
- Obtain the MongoDB source package or RPM package and upload it to the tsdbtool directory.
- Modify the installation configuration file mongoconf.csv.
Table 1 describes the parameters in the mongodbconf.csv configuration file.
Table 1 Parameters in the mongodbconf.csv configuration file Parameter
Description
isopath
Specifies the OS image path, which must be uploaded to the OS of the server in advance for installing some dependencies.
prefixdir
Specifies the absolute path for installing the software after the source code is compiled. The path must exist in the OS. This parameter is invalid and not used for RPM package installation.
os_root_user
Specifies the root username of the OS on the server where MongoDB is installed.
os_root_password
Specifies the password of user root for logging in to the OS of the server where MongoDB is installed.
version
Specifies the MongoDB version.
compile_flag
Determines the check process. Set this parameter to 1 for the check before RPM package compilation. Otherwise, set this parameter to 0. The number of check items is small during compilation.
config_server
Specifies the IP addresses of the config servers in the MongoDB cluster. Use semicolons (;) to separate multiple IP addresses.
config_server_num
Specifies the number of config servers, which is used for verification.
config_db_prefix_dir
Specifies the prefix of the config db directory. The data and log directories are created in this directory.
config_db_port
Specifies the port number used by config db.
router_server
Specifies the IP addresses of the router servers in the MongoDB cluster. Use semicolons (;) to separate multiple IP addresses.
router_server_num
Specifies the number of router servers, which is used for verification.
router_db_prefix_dir
Specifies the prefix of the router db directory. The data and log directories are created in this directory.
router_db_port
Specifies the port number used by router db.
shard_server
Specifies the IP addresses of the shard servers in the MongoDB cluster. Use semicolons (;) to separate multiple IP addresses.
shard_server_num
Specifies the number of shard servers, which is used for verification.
shard_db_prefix_dir
Specifies the directories used by the shard databases. Multiple directories are separated by semicolons (;). The directories can be the same. Based on the number of shards and the directory sequence, create datashard1 logshard1 directories in the first directory to store the data and logs of shard 1. In the second directory, create datashard2 and logshard2 directories to store the data and logs of shard 2.
shard_db_port
Specifies the port numbers used by the shard databases. Use semicolons (;) to separate multiple port numbers.
shard_num
Specifies the number of shards in the MongoDB cluster.
replica_num
Specifies the number of replicas in the MongoDB cluster.
wiredTigerCacheSizeGB
Specifies the memory used by each shard.
Table 3 lists the MongoDB cluster plan example (for four servers, four shards, and three replicas).
Database |
Port |
Server1 |
Server2 |
Server3 |
Server4 |
prefixdir |
|---|---|---|---|---|---|---|
Router |
1801 |
√ |
√ |
√ |
- |
/mg/router |
Config |
1802 |
- |
√ |
√ |
√ |
/mg/config |
Shard1 |
1803 |
√ |
√ |
√ |
- |
/mg/shard1 |
Shard2 |
1804 |
- |
√ |
√ |
√ |
/mg/shard2 |
Shard3 |
1805 |
√ |
- |
√ |
√ |
/mg/shard3 |
Shard4 |
1806 |
√ |
√ |
- |
√ |
/mg/shard4 |
The tool will select different server groups to divide shards based on the number of servers, number of shards, and number of replicas. For example, select server1, server2, and server3 for shard 1 with three replicas. Select server2, server3, and server4 for shard 2. Select server3, server4, and server1 for shard 3. Select server4, server1, and server2 for shard 4.
Table 4 describes the key configuration items in the mongodbconf.csv file.
Type |
Parameter |
Value |
|---|---|---|
Config configuration |
config_server |
server2-ip;server3-ip;server4-ip |
config_server_num |
3 |
|
config_db_prefix_dir |
/mg/config |
|
config_db_port |
1802 |
|
Router configuration |
router_server |
server1-ip;server2-ip;server3-ip |
router_server_num |
3 |
|
router_db_prefix_dir |
/mg/router |
|
router_db_port |
1801 |
|
Shard configuration |
shard_server |
server1-ip;server2-ip;server3-ip;server4-ip |
shard_server_num |
4 |
|
shard_db_prefix_dir |
/mg/shard1;/mg/shard2;/mg/shard3;/mg/shard4 |
|
shard_db_port |
1803;1804;1805;1806 |
|
shard_num |
4 |
|
replica_num |
4 |
This document uses check, install, and uninstall of MongoDB 4.0.12 as examples. Before installing MongoDB using tsdbtool:
- Obtain and upload the tool package to the server, and decompress it to the /home directory to obtain the /home/tsdbtool directory.
- Upload the mongo-r4.0.12.tar.gz source code package or RPM package to the /home/tsdbtool directory.
- Download GCC-7.3.0, CMake-3.5.2, Cython, PyYAML, Typing, and Cheetah3 source code packages to the mongodbDep folder in the tsdbtool folder.
- Modify the mongodbconf.csv file, and create the prefixdir directory. (This parameter is not required if you install MongoDB using an RPM package.)