SlideShare a Scribd company logo
Configuring and
Deploying mongoDB
Sharded Cluster in 30
minutes
Prepared by Sudheer Kondla
Solutions Architect
 The presentation is based on VMs created using VMWare’s ESXi/Vsphere and RHEL/Oracle
Linux.
 This presentation is based on setting up mongoDB sharded cluster
 with 6 VMs in the MongoDB cluster (RedHat Linux).
 Each VM consists of 2 vCPUs and 4 GB of RAM
 Each VM is created with 80 GB of disk space. No special mounts/ file systems are used.
 Linux version used: 6.5
Sharded Cluster VIRTUAL MACHINES
VM Configuration
Installing mongdb
 The following steps guide you through installing mongodb software on Linux.
 set yum repository and download packages using yum package installer.
 [root@bigdata1 ~]# cd /etc/yum.repos.d/
 [root@bigdata1 yum.repos.d]# cat mongodb.repo
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
 Before you run “yum install”, be sure to check internet is working.
 [root@bigdata6 yum.repos.d]# yum install -y mongodb-org-2.6.1 mongodb-org-server-2.6.1
mongodb-org-shell-2.6.1 mongodb-org-mongos-2.6.1 mongodb-org-tools-2.6.1
Setting up mongodb
 Make sure to create /data/configdb and /data/db directories on each servers
 The above directories should be owned by mongod user and mongod group.
 Change ownership to mongod
 As a root user run “chown mongod:mongod /data/configdb” and “chown mongod:mongod
/data/db”
 Without above directories mongod process will not start
 When you start mongo daemon process it will create “/data/configdb/mongod.lock” file
 You can also start mongod process with service option as root. For example “service mongod
start”
 You can also configure mongo daemon to start at system boot.
MongoDB Sharding Architecture
 Sharding is a method for storing data across multiple machines. MongoDB uses sharding
to support deployments with very large data sets and high throughput operations.
 Database systems with large data sets and high throughput applications can challenge
the capacity of a single server. High query rates can exhaust the CPU capacity of the
server. Larger data sets exceed the storage capacity of a single machine. Finally,
working set sizes larger than the system’s RAM stress the I/O capacity of disk drives.
 Sharding addresses the challenge of scaling to support high throughput and large data
sets:
 Sharding reduces the number of operations each shard handles. Each shard processes fewer
operations as the cluster grows. As a result, a cluster can increase capacity and throughput
horizontally.
 For example, to insert data, the application only needs to access the shard responsible for
that record.
 Sharding reduces the amount of data that each server needs to store. Each shard stores less
data as the cluster grows.
 For example, if a database has a 1 terabyte data set, and there are 4 shards, then each shard
might hold only 256GB of data. If there are 40 shards, then each shard might hold only 25GB
of data.
Sharding Architecture
Deploying a sharded cluster
 Start the Config Server Database Instances.
 The config server processes are mongod instances that store the cluster’s metadata.
 Designate a mongod as a config server using the --configsvr option.
e.g: mongod --configsvr --dbpath /data/configdb --port 27019 --bind_ip 192.168.0.131 –v
 Each config server stores a complete copy of the cluster’s metadata.
 Production deployments require three config server instances, each of them running on different servers to ensure
high availability and data safety.
 All members of a sharded cluster must be able to connect to all other members of a sharded cluster.
 Make sure to setup proper network connectivity, firewall rules.
 Start the three config server instances. For example
 Node1: mongod --configsvr --dbpath /data/configdb --port 27019 --bind_ip 192.168.0.131 -v
 Node2: mongod --configsvr --dbpath /data/configdb --port 27019 --bind_ip 192.168.0.132 –v
 Node3: mongod --configsvr --dbpath /data/configdb --port 27019 --bind_ip 192.168.0.133 -v
 Start the mongos Instances:
 The mongos instances are lightweight and do not require data directories.
 You can run a mongos instance on a system that runs other cluster components, such as on an application server or a
server running a mongod process.
 By default, a mongos instance runs on port 27017. Specify the hostnames of the three config servers, either in the
configuration file or as command line parameters.
 For example: mongos --configdb bigdata1:27019,bigdata2:27019,bigdata3:27019
Add Shards to the Cluster
 Enable Sharding for a Database
 Enabling sharding for a database does not redistribute data but make it possible to shard the
collections in that database.
 From a mongo shell, connect to the mongos instance. Issue a command using the following
[hdfs@bigdata3 ~]$ mongo --host bigdata2 --port 27017
MongoDB shell version: 2.6.1
connecting to: bigdata2:27017/test
rs0:PRIMARY>
 sh.addShard("rs0/bigdata1:27017")
 sh.addShard("rs0/bigdata2:27017")
 sh.addShard("rs0/bigdata3:27017")
 sh.addShard("rs0/bigdata4:27017")
 sh.addShard("rs0/bigdata5:27017")
 sh.addShard("rs0/bigdata6:27017")
Enable Sharding for a Collection
 Before you can shard a collection, you must enable sharding for the collection’s database.
 Enabling sharding for a database does not redistribute data but make it possible to shard the
collections in that database.
 Once you enable sharding for a database, MongoDB assigns a primary shard for that database
where MongoDB stores all data before sharding begins.
 Issue the sh.enableSharding() method.
 rs0:PRIMARY> show dbs
 sh.enableSharding(" customer”) OR
 db.runCommand( { enableSharding: “customer” } )
 Enable sharding on a per-collection basis.
 sh.shardCollection("records.people", { "zipcode": 1, "name": 1 } )
 sh.shardCollection("people.addresses", { "state": 1, "_id": 1 } )
 sh.shardCollection("assets.chairs", { "type": 1, "_id": 1 } )
 sh.shardCollection("events.alerts", { "_id": "hashed" } )

More Related Content

What's hot

Postgresql các vấn đề thực tế
Postgresql các vấn đề thực tếPostgresql các vấn đề thực tế
Postgresql các vấn đề thực tế
TechMaster Vietnam
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform Training
Yevgeniy Brikman
 
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte DataProblems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
Jignesh Shah
 
Facebook Messages & HBase
Facebook Messages & HBaseFacebook Messages & HBase
Facebook Messages & HBase
强 王
 
Sonatype nexus 로 docker registry 관리하기
Sonatype nexus 로 docker registry 관리하기Sonatype nexus 로 docker registry 관리하기
Sonatype nexus 로 docker registry 관리하기
KwangSeob Jeong
 
CKA Certified Kubernetes Administrator Notes
CKA Certified Kubernetes Administrator Notes CKA Certified Kubernetes Administrator Notes
CKA Certified Kubernetes Administrator Notes
Adnan Rashid
 
Apache kafka 확장과 응용
Apache kafka 확장과 응용Apache kafka 확장과 응용
Apache kafka 확장과 응용
JANGWONSEO4
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
Rishabh Kumar
 
Terraform infraestructura como código
Terraform infraestructura como códigoTerraform infraestructura como código
Terraform infraestructura como código
Victor Adsuar
 
MySQLレプリケーションあれやこれや
MySQLレプリケーションあれやこれやMySQLレプリケーションあれやこれや
MySQLレプリケーションあれやこれや
yoku0825
 
MySQL developing Store Procedure
MySQL developing Store ProcedureMySQL developing Store Procedure
MySQL developing Store ProcedureMarco Tusa
 
Introduction to PostgreSQL
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQL
Joel Brewer
 
카카오 광고 플랫폼 MSA 적용 사례 및 API Gateway와 인증 구현에 대한 소개
카카오 광고 플랫폼 MSA 적용 사례 및 API Gateway와 인증 구현에 대한 소개카카오 광고 플랫폼 MSA 적용 사례 및 API Gateway와 인증 구현에 대한 소개
카카오 광고 플랫폼 MSA 적용 사례 및 API Gateway와 인증 구현에 대한 소개
if kakao
 
[2019] 바르게, 빠르게! Reactive를 품은 Spring Kafka
[2019] 바르게, 빠르게! Reactive를 품은 Spring Kafka[2019] 바르게, 빠르게! Reactive를 품은 Spring Kafka
[2019] 바르게, 빠르게! Reactive를 품은 Spring Kafka
NHN FORWARD
 
REST in AEM by Roy Fielding
REST in AEM by Roy FieldingREST in AEM by Roy Fielding
REST in AEM by Roy Fielding
AEM HUB
 
RDB開発者のためのApache Cassandra データモデリング入門
RDB開発者のためのApache Cassandra データモデリング入門RDB開発者のためのApache Cassandra データモデリング入門
RDB開発者のためのApache Cassandra データモデリング入門
Yuki Morishita
 
Percona server for MySQL 제품 소개
Percona server for MySQL 제품 소개Percona server for MySQL 제품 소개
Percona server for MySQL 제품 소개
NeoClova
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
SANG WON PARK
 
Terraform
TerraformTerraform
Terraform
Marcelo Serpa
 
Developer’s guide to contributing code to Kafka with Mickael Maison and Tom B...
Developer’s guide to contributing code to Kafka with Mickael Maison and Tom B...Developer’s guide to contributing code to Kafka with Mickael Maison and Tom B...
Developer’s guide to contributing code to Kafka with Mickael Maison and Tom B...
HostedbyConfluent
 

What's hot (20)

Postgresql các vấn đề thực tế
Postgresql các vấn đề thực tếPostgresql các vấn đề thực tế
Postgresql các vấn đề thực tế
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform Training
 
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte DataProblems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
 
Facebook Messages & HBase
Facebook Messages & HBaseFacebook Messages & HBase
Facebook Messages & HBase
 
Sonatype nexus 로 docker registry 관리하기
Sonatype nexus 로 docker registry 관리하기Sonatype nexus 로 docker registry 관리하기
Sonatype nexus 로 docker registry 관리하기
 
CKA Certified Kubernetes Administrator Notes
CKA Certified Kubernetes Administrator Notes CKA Certified Kubernetes Administrator Notes
CKA Certified Kubernetes Administrator Notes
 
Apache kafka 확장과 응용
Apache kafka 확장과 응용Apache kafka 확장과 응용
Apache kafka 확장과 응용
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
Terraform infraestructura como código
Terraform infraestructura como códigoTerraform infraestructura como código
Terraform infraestructura como código
 
MySQLレプリケーションあれやこれや
MySQLレプリケーションあれやこれやMySQLレプリケーションあれやこれや
MySQLレプリケーションあれやこれや
 
MySQL developing Store Procedure
MySQL developing Store ProcedureMySQL developing Store Procedure
MySQL developing Store Procedure
 
Introduction to PostgreSQL
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQL
 
카카오 광고 플랫폼 MSA 적용 사례 및 API Gateway와 인증 구현에 대한 소개
카카오 광고 플랫폼 MSA 적용 사례 및 API Gateway와 인증 구현에 대한 소개카카오 광고 플랫폼 MSA 적용 사례 및 API Gateway와 인증 구현에 대한 소개
카카오 광고 플랫폼 MSA 적용 사례 및 API Gateway와 인증 구현에 대한 소개
 
[2019] 바르게, 빠르게! Reactive를 품은 Spring Kafka
[2019] 바르게, 빠르게! Reactive를 품은 Spring Kafka[2019] 바르게, 빠르게! Reactive를 품은 Spring Kafka
[2019] 바르게, 빠르게! Reactive를 품은 Spring Kafka
 
REST in AEM by Roy Fielding
REST in AEM by Roy FieldingREST in AEM by Roy Fielding
REST in AEM by Roy Fielding
 
RDB開発者のためのApache Cassandra データモデリング入門
RDB開発者のためのApache Cassandra データモデリング入門RDB開発者のためのApache Cassandra データモデリング入門
RDB開発者のためのApache Cassandra データモデリング入門
 
Percona server for MySQL 제품 소개
Percona server for MySQL 제품 소개Percona server for MySQL 제품 소개
Percona server for MySQL 제품 소개
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
 
Terraform
TerraformTerraform
Terraform
 
Developer’s guide to contributing code to Kafka with Mickael Maison and Tom B...
Developer’s guide to contributing code to Kafka with Mickael Maison and Tom B...Developer’s guide to contributing code to Kafka with Mickael Maison and Tom B...
Developer’s guide to contributing code to Kafka with Mickael Maison and Tom B...
 

Similar to Setting up mongodb sharded cluster in 30 minutes

Setting up mongo replica set
Setting up mongo replica setSetting up mongo replica set
Setting up mongo replica setSudheer Kondla
 
MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017
Antonios Giannopoulos
 
Sharded cluster tutorial
Sharded cluster tutorialSharded cluster tutorial
Sharded cluster tutorial
Antonios Giannopoulos
 
MongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster TutorialMongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster Tutorial
Jason Terpko
 
Percona Live 2017 ­- Sharded cluster tutorial
Percona Live 2017 ­- Sharded cluster tutorialPercona Live 2017 ­- Sharded cluster tutorial
Percona Live 2017 ­- Sharded cluster tutorial
Antonios Giannopoulos
 
Getting started with replica set in MongoDB
Getting started with replica set in MongoDBGetting started with replica set in MongoDB
Getting started with replica set in MongoDBKishor Parkhe
 
Configuring MongoDB HA Replica Set on AWS EC2
Configuring MongoDB HA Replica Set on AWS EC2Configuring MongoDB HA Replica Set on AWS EC2
Configuring MongoDB HA Replica Set on AWS EC2
ShepHertz
 
MongoDB Replication and Sharding
MongoDB Replication and ShardingMongoDB Replication and Sharding
MongoDB Replication and ShardingTharun Srinivasa
 
MongoDB Shard Cluster
MongoDB Shard ClusterMongoDB Shard Cluster
MongoDB Shard Cluster
Anuchit Chalothorn
 
Percona Cluster with Master_Slave for Disaster Recovery
Percona Cluster with Master_Slave for Disaster RecoveryPercona Cluster with Master_Slave for Disaster Recovery
Percona Cluster with Master_Slave for Disaster RecoveryRam Gautam
 
Mongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guideMongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guidePhilip Zhong
 
How to Become Cloud Backup Provider
How to Become Cloud Backup ProviderHow to Become Cloud Backup Provider
How to Become Cloud Backup Provider
Cloudian
 
MongoDB Sharding
MongoDB ShardingMongoDB Sharding
MongoDB Sharding
uzzal basak
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for Beginners
Enoch Joshua
 
MySQL Oslayer performace optimization
MySQL  Oslayer performace optimizationMySQL  Oslayer performace optimization
MySQL Oslayer performace optimization
Louis liu
 
How to become cloud backup provider
How to become cloud backup providerHow to become cloud backup provider
How to become cloud backup providerCLOUDIAN KK
 
MySQL Cluster Basics
MySQL Cluster BasicsMySQL Cluster Basics
MySQL Cluster Basics
Wagner Bianchi
 
Building Apache Cassandra clusters for massive scale
Building Apache Cassandra clusters for massive scaleBuilding Apache Cassandra clusters for massive scale
Building Apache Cassandra clusters for massive scale
Alex Thompson
 
Mdb dn 2016_11_ops_mgr
Mdb dn 2016_11_ops_mgrMdb dn 2016_11_ops_mgr
Mdb dn 2016_11_ops_mgr
Daniel M. Farrell
 
MariaDB10.7_install_Ubuntu.docx
MariaDB10.7_install_Ubuntu.docxMariaDB10.7_install_Ubuntu.docx
MariaDB10.7_install_Ubuntu.docx
NeoClova
 

Similar to Setting up mongodb sharded cluster in 30 minutes (20)

Setting up mongo replica set
Setting up mongo replica setSetting up mongo replica set
Setting up mongo replica set
 
MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017MongoDB – Sharded cluster tutorial - Percona Europe 2017
MongoDB – Sharded cluster tutorial - Percona Europe 2017
 
Sharded cluster tutorial
Sharded cluster tutorialSharded cluster tutorial
Sharded cluster tutorial
 
MongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster TutorialMongoDB - Sharded Cluster Tutorial
MongoDB - Sharded Cluster Tutorial
 
Percona Live 2017 ­- Sharded cluster tutorial
Percona Live 2017 ­- Sharded cluster tutorialPercona Live 2017 ­- Sharded cluster tutorial
Percona Live 2017 ­- Sharded cluster tutorial
 
Getting started with replica set in MongoDB
Getting started with replica set in MongoDBGetting started with replica set in MongoDB
Getting started with replica set in MongoDB
 
Configuring MongoDB HA Replica Set on AWS EC2
Configuring MongoDB HA Replica Set on AWS EC2Configuring MongoDB HA Replica Set on AWS EC2
Configuring MongoDB HA Replica Set on AWS EC2
 
MongoDB Replication and Sharding
MongoDB Replication and ShardingMongoDB Replication and Sharding
MongoDB Replication and Sharding
 
MongoDB Shard Cluster
MongoDB Shard ClusterMongoDB Shard Cluster
MongoDB Shard Cluster
 
Percona Cluster with Master_Slave for Disaster Recovery
Percona Cluster with Master_Slave for Disaster RecoveryPercona Cluster with Master_Slave for Disaster Recovery
Percona Cluster with Master_Slave for Disaster Recovery
 
Mongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guideMongo db sharding_cluster_installation_guide
Mongo db sharding_cluster_installation_guide
 
How to Become Cloud Backup Provider
How to Become Cloud Backup ProviderHow to Become Cloud Backup Provider
How to Become Cloud Backup Provider
 
MongoDB Sharding
MongoDB ShardingMongoDB Sharding
MongoDB Sharding
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for Beginners
 
MySQL Oslayer performace optimization
MySQL  Oslayer performace optimizationMySQL  Oslayer performace optimization
MySQL Oslayer performace optimization
 
How to become cloud backup provider
How to become cloud backup providerHow to become cloud backup provider
How to become cloud backup provider
 
MySQL Cluster Basics
MySQL Cluster BasicsMySQL Cluster Basics
MySQL Cluster Basics
 
Building Apache Cassandra clusters for massive scale
Building Apache Cassandra clusters for massive scaleBuilding Apache Cassandra clusters for massive scale
Building Apache Cassandra clusters for massive scale
 
Mdb dn 2016_11_ops_mgr
Mdb dn 2016_11_ops_mgrMdb dn 2016_11_ops_mgr
Mdb dn 2016_11_ops_mgr
 
MariaDB10.7_install_Ubuntu.docx
MariaDB10.7_install_Ubuntu.docxMariaDB10.7_install_Ubuntu.docx
MariaDB10.7_install_Ubuntu.docx
 

More from Sudheer Kondla

MongoDB cluster_on_aws_example
MongoDB cluster_on_aws_exampleMongoDB cluster_on_aws_example
MongoDB cluster_on_aws_example
Sudheer Kondla
 
No sql
No sqlNo sql
AWS multi-region DB design and deployment
AWS multi-region DB design and deploymentAWS multi-region DB design and deployment
AWS multi-region DB design and deployment
Sudheer Kondla
 
Aws aurora scaling
Aws aurora scalingAws aurora scaling
Aws aurora scaling
Sudheer Kondla
 
Data platform architecture
Data platform architectureData platform architecture
Data platform architecture
Sudheer Kondla
 
Digital transformation is not about technology
Digital transformation is not about technologyDigital transformation is not about technology
Digital transformation is not about technology
Sudheer Kondla
 
Cloudera cluster setup and configuration
Cloudera cluster setup and configurationCloudera cluster setup and configuration
Cloudera cluster setup and configuration
Sudheer Kondla
 

More from Sudheer Kondla (7)

MongoDB cluster_on_aws_example
MongoDB cluster_on_aws_exampleMongoDB cluster_on_aws_example
MongoDB cluster_on_aws_example
 
No sql
No sqlNo sql
No sql
 
AWS multi-region DB design and deployment
AWS multi-region DB design and deploymentAWS multi-region DB design and deployment
AWS multi-region DB design and deployment
 
Aws aurora scaling
Aws aurora scalingAws aurora scaling
Aws aurora scaling
 
Data platform architecture
Data platform architectureData platform architecture
Data platform architecture
 
Digital transformation is not about technology
Digital transformation is not about technologyDigital transformation is not about technology
Digital transformation is not about technology
 
Cloudera cluster setup and configuration
Cloudera cluster setup and configurationCloudera cluster setup and configuration
Cloudera cluster setup and configuration
 

Recently uploaded

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 

Setting up mongodb sharded cluster in 30 minutes

  • 1. Configuring and Deploying mongoDB Sharded Cluster in 30 minutes Prepared by Sudheer Kondla Solutions Architect
  • 2.  The presentation is based on VMs created using VMWare’s ESXi/Vsphere and RHEL/Oracle Linux.  This presentation is based on setting up mongoDB sharded cluster  with 6 VMs in the MongoDB cluster (RedHat Linux).  Each VM consists of 2 vCPUs and 4 GB of RAM  Each VM is created with 80 GB of disk space. No special mounts/ file systems are used.  Linux version used: 6.5
  • 5. Installing mongdb  The following steps guide you through installing mongodb software on Linux.  set yum repository and download packages using yum package installer.  [root@bigdata1 ~]# cd /etc/yum.repos.d/  [root@bigdata1 yum.repos.d]# cat mongodb.repo [mongodb] name=MongoDB Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ gpgcheck=0 enabled=1  Before you run “yum install”, be sure to check internet is working.  [root@bigdata6 yum.repos.d]# yum install -y mongodb-org-2.6.1 mongodb-org-server-2.6.1 mongodb-org-shell-2.6.1 mongodb-org-mongos-2.6.1 mongodb-org-tools-2.6.1
  • 6. Setting up mongodb  Make sure to create /data/configdb and /data/db directories on each servers  The above directories should be owned by mongod user and mongod group.  Change ownership to mongod  As a root user run “chown mongod:mongod /data/configdb” and “chown mongod:mongod /data/db”  Without above directories mongod process will not start  When you start mongo daemon process it will create “/data/configdb/mongod.lock” file  You can also start mongod process with service option as root. For example “service mongod start”  You can also configure mongo daemon to start at system boot.
  • 7. MongoDB Sharding Architecture  Sharding is a method for storing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.  Database systems with large data sets and high throughput applications can challenge the capacity of a single server. High query rates can exhaust the CPU capacity of the server. Larger data sets exceed the storage capacity of a single machine. Finally, working set sizes larger than the system’s RAM stress the I/O capacity of disk drives.  Sharding addresses the challenge of scaling to support high throughput and large data sets:  Sharding reduces the number of operations each shard handles. Each shard processes fewer operations as the cluster grows. As a result, a cluster can increase capacity and throughput horizontally.  For example, to insert data, the application only needs to access the shard responsible for that record.  Sharding reduces the amount of data that each server needs to store. Each shard stores less data as the cluster grows.  For example, if a database has a 1 terabyte data set, and there are 4 shards, then each shard might hold only 256GB of data. If there are 40 shards, then each shard might hold only 25GB of data.
  • 9. Deploying a sharded cluster  Start the Config Server Database Instances.  The config server processes are mongod instances that store the cluster’s metadata.  Designate a mongod as a config server using the --configsvr option. e.g: mongod --configsvr --dbpath /data/configdb --port 27019 --bind_ip 192.168.0.131 –v  Each config server stores a complete copy of the cluster’s metadata.  Production deployments require three config server instances, each of them running on different servers to ensure high availability and data safety.  All members of a sharded cluster must be able to connect to all other members of a sharded cluster.  Make sure to setup proper network connectivity, firewall rules.  Start the three config server instances. For example  Node1: mongod --configsvr --dbpath /data/configdb --port 27019 --bind_ip 192.168.0.131 -v  Node2: mongod --configsvr --dbpath /data/configdb --port 27019 --bind_ip 192.168.0.132 –v  Node3: mongod --configsvr --dbpath /data/configdb --port 27019 --bind_ip 192.168.0.133 -v  Start the mongos Instances:  The mongos instances are lightweight and do not require data directories.  You can run a mongos instance on a system that runs other cluster components, such as on an application server or a server running a mongod process.  By default, a mongos instance runs on port 27017. Specify the hostnames of the three config servers, either in the configuration file or as command line parameters.  For example: mongos --configdb bigdata1:27019,bigdata2:27019,bigdata3:27019
  • 10. Add Shards to the Cluster  Enable Sharding for a Database  Enabling sharding for a database does not redistribute data but make it possible to shard the collections in that database.  From a mongo shell, connect to the mongos instance. Issue a command using the following [hdfs@bigdata3 ~]$ mongo --host bigdata2 --port 27017 MongoDB shell version: 2.6.1 connecting to: bigdata2:27017/test rs0:PRIMARY>  sh.addShard("rs0/bigdata1:27017")  sh.addShard("rs0/bigdata2:27017")  sh.addShard("rs0/bigdata3:27017")  sh.addShard("rs0/bigdata4:27017")  sh.addShard("rs0/bigdata5:27017")  sh.addShard("rs0/bigdata6:27017")
  • 11. Enable Sharding for a Collection  Before you can shard a collection, you must enable sharding for the collection’s database.  Enabling sharding for a database does not redistribute data but make it possible to shard the collections in that database.  Once you enable sharding for a database, MongoDB assigns a primary shard for that database where MongoDB stores all data before sharding begins.  Issue the sh.enableSharding() method.  rs0:PRIMARY> show dbs  sh.enableSharding(" customer”) OR  db.runCommand( { enableSharding: “customer” } )  Enable sharding on a per-collection basis.  sh.shardCollection("records.people", { "zipcode": 1, "name": 1 } )  sh.shardCollection("people.addresses", { "state": 1, "_id": 1 } )  sh.shardCollection("assets.chairs", { "type": 1, "_id": 1 } )  sh.shardCollection("events.alerts", { "_id": "hashed" } )