Posts

MongoDB - Deployment

Image
When you are preparing a MongoDB deployment, you should try to understand how your application is going to hold up in production. It’s a good idea to develop a consistent, repeatable approach to managing your deployment environment so that you can minimize any surprises once you’re in production. The best approach incorporates prototyping your set up, conducting load testing, monitoring key metrics, and using that information to scale your set up. The key part of the approach is to proactively monitor your entire system - this will help you understand how your production system will hold up before deploying, and determine where you will need to add capacity. Having insight into potential spikes in your memory usage, for example, could help put out a write-lock fire before it starts. To monitor your deployment, MongoDB provides some of the following commands − mongostat This command checks the status of all running mongod instances and return counters of database operations. These count

MongoDB - Data Modelling

Image
Data in MongoDB has a flexible schema.documents in the same collection. They do not need to have the same set of fields or structure Common fields in a collection’s documents may hold different types of data. Data Model Design MongoDB provides two types of data models: — Embedded data model and Normalized data model. Based on the requirement, you can use either of the models while preparing your document. Embedded Data Model In this model, you can have (embed) all the related data in a single document, it is also known as de-normalized data model. For example, assume we are getting the details of employees in three different documents namely, Personal_details, Contact and, Address, you can embed all the three documents in a single one as shown below − { _id : , Emp_ID : "10025AE336" Personal_details :{ First_Name : "Kishan" , Last_Name : "choudhary" , Date_Of_Birth : "1995-09-26" }, Contact : { e - mail : "

MongoDB - Installation

Image
  Install MongoDB On Windows To install MongoDB on Windows, first download the latest release of MongoDB from  https://www.mongodb.com/download-center . Enter the required details, select the  Server  tab, in it you can choose the version of MongoDB, operating system and, packaging as: Now install the downloaded file, by default, it will be installed in the folder  C:\Program Files\ . MongoDB requires a data folder to store its files. The default location for the MongoDB data directory is c:\data\db. So you need to create this folder using the Command Prompt. Execute the following command sequence. C:\>md data C:\md data\db Then you need to specify set the  dbpath  to the created directory in  mongod.exe . For the same, issue the following commands. In the command prompt, navigate to the bin directory current in the MongoDB installation folder. Suppose my installation folder is  C:\Program Files\MongoDB C:\Users\XYZ>d:cd C:\Program Files\MongoDB\Server\4.2\bin C:\Program Files\Mo

SPARK - Deployment

Spark application, using spark-submit, is a shell command used to deploy the Spark application on a cluster. It uses all respective cluster managers through a uniform interface. Therefore, you do not have to configure your application for each one. Example Let us take the same example of word count, we used before, using shell commands. Here, we consider the same example as a spark application. Sample Input The following text is the input data and the file named is  in.txt . people are not as beautiful as they look, as they walk or as they talk. they are only as beautiful as they love, as they care as they share. Look at the following program − SparkWordCount.scala import org . apache . spark . SparkContext import org . apache . spark . SparkContext . _ import org . apache . spark . _ object SparkWordCount { def main ( args : Array [ String ]) { val sc = new SparkContext ( "local" , "Word Count" , "/usr/local/spark" ,