SpringBoot integrates mongodb Implementation steps: pom file import coordinates <!–mongo–> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> Yaml configuration file configures mongodb: spring: data: mongodb: uri: mongodb://localhost/spring Just create a pojo @Data @NoArgsConstructor @AllArgsConstructor public class Book {<!– –> private int id; private String name; […]
Tag: mongodb
MongoDB cluster construction
MongoDB cluster construction 1. Introduction to MongoDB cluster 1. Replica Set (preferred) replica set. The cluster contains multiple copies of data. After the master node hangs up, the slave node can continue to provide services. 2. Sharding sharding cluster, only real big data can show its advantages. After all, it takes time for nodes to […]
[Mango] Use explain() to view the execution plan of mongodb query statement
Use explain() to view the execution plan of the mongodb query statement Similar to relational databases such as MySQL and Oracle, MongoDB calculates the optimal query plan for each query statement through the query optimizer, including selected indexes, query time, scanned records, number of scanned indexes, alternative execution plans, etc. information. This article introduces using […]
Compile and deploy the arm64 version of Mongodb5.0.18
Compile and deploy the arm64 version of Mongodb5.0.18 MongoDB source code compilation Prepare installation package https://github.com/mongodb/mongo/releases/tag/r5.0.18 Upload: /opt/package Unzip: tar -zxvf /opt/package/mongo-r5.0.18.tar.gz -C /opt/package View the build documentation, which contains detailed instructions and requires the server to meet the conditions. cat /opt/package/mongo-r5.0.18/docs/building.md Install gcc Download address: http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-9.5.0/gcc-9.5.0.tar.gz Upload: /opt/package Unzip: gcc-9.5.0.tar.gz tar -zxvf /opt/package/gcc-9.5.0.tar.gz -C […]
mongodb command line connection and basic commands
You may usually use client tools to connect and query mongodb during the development process, but generally the databases in production do not allow local client connections. This article mainly explains how to connect to the mongodb server through the command line and use some simple query statements Article directory 1. Connect to mongodb from […]
Springboot integrated mongodb
1. Introduce dependencies 1.1 Maven <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> 2. yml configuration file data: mongodb: #Basic link parameters # Linked libraries database: mongodb # username username: mongodb # password password:mongodb # IP and port (host:port), such as 127.0.0.1:27017. Cluster mode is separated by, such as host1:port1,host2:port2 address: 192.168.1.1:3717,192.168.1.2:3717 # Set up the authentication database, if […]
Use Docker to deploy a highly available MongoDB sharded cluster
Use Docker to deploy MongoDB cluster Mongodb cluster construction There are three ways to build a mongodb cluster: Master-Slave mode, or master-slave replication mode. Replica Set mode. Sharding mode. Among them, the first method is basically meaningless, and the official does not recommend this method of construction. The other two methods are replica sets and […]
MongoDB sharded cluster
4.1. Sharding cluster mechanism and principle 4.1.1. Common MongoDB deployment architecture Single node: used for development and testing (about 20% of the total) Replica set: high availability (overall accounted for about 70%) Sharded cluster: horizontal expansion (overall accounting for about 10%) 4.1.2. Why use sharded cluster It is recommended to use sharded clusters in the […]
MySQL and MongoDB, how to choose technology?
Hello, everyone, I am Zhang Zhang, the author of the public account “The Road to Architecture Improvement”. Introduction Under normal circumstances, when considering how to make technical selections between MySQL and MongoDB, you must have encountered access problems similar to unstructured data JSON, otherwise everyone would just start using MySQL. Why should you pay attention […]
106 MongoDB related concepts
MongoDB related concepts 1.1 Business application scenarios 1.2 Introduction to MongoDB 1.3 Architecture 1.4 Data model 1.5 Features of MongoDB 2 docker install mongoDB 3 Connect to mongodb 4 Create database and collection 4.1 Create database 4.2 Create a collection 5 springboot basic mongdb 5.1 Build the project 5.1.1 Create project 5.2.2 Integrate mongodb 5.2 […]