MongoDB3.0 cluster configuration file automatic generator
File description:
-- cfg.conf.template -- mongod.conf.template -- mongos.conf.template
Cfg. conf. template: template of the configuration file for the cluster preparation server
Mongod. conf. template: mongod process preparation file template
Mongos. conf. template: template of the mongos route process preparation file
Generator. php: automatically generate the PHP script for the preparation file
Script usage:
Create a new directory on your Linux server. the directory I created here is/data/mongo.
mkdir -p /data/mongo
Copy the above four files in this project to the/data/mongo directory and execute php generator. php. Make sure that PHP is installed on the machine before execution.
Preparation instructions:
Some constants are defined in the generator. php file. you can modify the values of these constants.
// Define IPdefine ("BIND_IP", "127.0.0.1, 192.168.100.10, 192.168.100.11, 192.168.100.12"); // define ("BINPATH ", "/usr/local/mongodb/bin"); // Superstart port number define ("START_PORT", 4000); // define ("CFG_SVR_NUM", 3 ); // define ("RS_NUM", 3); // define ("RS_NODE_NUM", 3 );
Template modification:
The three template files define common configurations of MongoDB processes. you can modify these configurations. # Is the dynamic part to be replaced.
Script output:
After running the script, you will see the following output:
C:\data\GitRoot\mongodb-conf-generator>php generator.phpcfg->node0->4000cfg->node1->4001cfg->node2->4002rs0->node0->4003rs0->node1->4004rs0->node2->4005rs1->node0->4006rs1->node1->4007rs1->node2->4008rs2->node0->4009rs2->node1->4010rs2->node2->4011mongos----->4012
Cfg: indicates configuring the server.
Node: indicates a node.
Rs: indicates a replica set.
4000: the rightmost number is the port number.