Configuring Mongo Database

This section shows how you can configure Mongo database and deploy Holdings microservice.

Procedure

  1. Download MongoDB community edition. For more information, see https://www.mongodb.com/download-center/community.
  2. Install without windows service. It gets installed in the C:\Program Files\MongoDB\Server\4.2\bin location.
  3. Open the host.file from C:\Windows\System32\drivers\etc and add the following line:

    127.0.0.1 mongo1 mongo2 mongo3

  4. Create a folder named C:\MongoDB and also create the followig sub folders:
    • config
    • data
    • log
  5. Copy the following files into the config sub folder:
    • mongod_node1.conf
    • mongod_node2.conf
    • mongod_node3.conf
  6. In data folder, create three empty folders as dbnode1, dbnode2, and dbnode3.
  7. Edit each .conf file to point to proper data and log folder.
  8. Execute the below in three command prompts, repectively:
    "C:\Program Files\MongoDB\Server\4.2\bin\mongod" --port 27017 --config C:\MongoDB\config\mongod_node1.conf
    "C:\Program Files\MongoDB\Server\4.2\bin\mongod" --port 27018 --config C:\MongoDB\config\mongod_node2.conf
    "C:\Program Files\MongoDB\Server\4.2\bin\mongod" --port 27019 --config C:\MongoDB\config\mongod_node3.conf
  9. Launch command prompt under C:\Program Files\MongoDB\Server\4.2\bin and execute the following commands:
    mongo --host localhost:27017
    config ={"_id" : "rs1","members" : [{"_id" : 0,"host" : "localhost:27017","priority": 2},{"_id" : 1,"host" : "localhost:27018","priority": 0},{"_id" : 2,"host" : "localhost:27019","priority": 0}]}; 
    rs.initiate(config)
  10. Exit the prompt.
  11. Launch command prompt under C:\Program Files\MongoDB\Server\4.2\bin and execute the following commands:
    mongo --host localhost:27017
    use ms_holdings
    db.createCollection("ms_holdings_balance");
    db.createCollection("ms_holdings_transaction");

Bookmark Name Actions
Feedback
x