Database Configurations and Settings

Service Request is a NoSQL based product microservice. To use the database, we must configure the database properties in the properties file.

During deployment, we use the Spring beans to load the entity files and create a table. Hence, after you configure the mentioned database properties and deploy the WAR file in the application, the tables are created.

The supported database is MongoDB. To install and setup MongoDB, follow these steps.

  1. Download and install the MongoDB community edition.
  2. Install it without the Windows service. It will be installed at C:\Program Files\MongoDB\Server\4.2\bin.
  3. Go to C:\Windows\System32\drivers\etc – hosts.file and add 127.0.0.1 mongo1 mongo2 mongo3.
  4. Go to your C drive and create a folder named MongoDB.
  5. In the MongoDB folder, create three new folders named config sub-folder, data sub-folder, and log sub-folder.
  6. Copy the following configurations files into the config folder:
    • mongod_node1.conf
    • mongod_node2.conf
    • mongod_node3.conf
  7. In the data folder, create three new folders named dbnode1, dbnode2, and dbnode3.
  8. Edit each .conf file such that they point to correct data and log folder.
  9. Open the Command Prompt and run the following commands:
    • "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
  10. Each command should be executed separately in a new command prompt window.
  11. Start the Command Prompt, go to the path where MongoDB is installed, run the following commands, and close the Command Prompt.
    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)
  12. Start the Command Prompt, go to the path where MongoDB is installed and run the following commands:
    mongo --host localhost:27017
    use ms_servicerequest
    
    db.createCollection("ms_servicerequest_servicerequest");
    db.createCollection("ms_servicerequest_servicerequestconfiguration");
    db.createCollection("ms_reference_data");

Bookmark Name Actions
Feedback
x