MongoDB3.0 cluster configuration file automatic generator-PHP source code

Source: Internet
Author: User
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.

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.