Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and basic operation of MongoDB

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. About MongoDB

1. Introduction to MongoDB

MongoDB is a cross-platform, document-oriented database. It can achieve high performance, high availability, and can be easily scaled. Is a product between relational database and non-relational database, in the case of high load, adding more nodes can ensure server performance.

MongoDB is also a product between relational database and non-relational database, which is the most functional and most like relational database in non-relational database. The main reason for not adopting the relational model is for better extensibility. MongoDB no longer has the concept of "row", and its operation mode is mainly based on two concepts: collection and document.

2. The characteristics of MongoDB

The characteristics of MongoDB include set-oriented storage, free mode, rich query statements and multi-level index, replication set mechanism, easy horizontal expansion, pluggable document-oriented storage function, and easy to operate.

MongoDB is easy to install, provides document-oriented storage function, and is easy to operate.

MongoDB provides replication, high availability and automatic sharding. If the load increases, it can be distributed to other nodes in the computer network. This is called sharding.

Mongo supports a rich set of query expressions. Query instructions use tags in the form of JSON to easily query embedded objects and arrays in a document.

MongoDB supports a variety of programming languages: Ruby, Python, java, C++, PHP, C # and other medium languages.

3. Applicable areas of MongoDB

MongoDB can provide scalable high-performance data storage solutions for Web applications. The main areas of use are website data, distributed scenarios, data caching and JSON document format storage. It is suitable for Internet applications with large amount of data, high concurrency and weak transactions, and its built-in horizontal scaling mechanism provides data processing capacity from millions to billions, which can well meet the data storage requirements of Web2.0 and mobile Internet applications.

II. Installation and basic operation of MongoDB

1. Configure the yum source repository

Vi / etc/yum.repos.d/CentOS-Base.repo

Add the yum source module for MongoDB on the last line

[mongodb-org] name=MongoDB Repositorybaseurl= https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc

2. Install MongoDB

Add a bridge network card to ensure that the virtual machine can access the external network

Yum install-y mongodb-org / / install vi / etc/mongod.conf / / modify listening address and port

Systemctl start mongod / / start service netstat-anpt | grep 27017 / / View listening port

Mongo / / enter db.version () / / check the version good show dbs; / / View the library db.getMongo () / / View the address of the connection to the current database

Note: the operation commands in MongDB can be completed by [tab].

Third, the basic operation of MongoDB

1. Enable multiple real columns

Cp-p / etc/mongod.conf / etc/mongod2.conf / / copy configuration file vi / etc/mongod2.conf / / modify the path and port corresponding to the new real column

Mkdir-p / data/mongodb/mongo / / create directory consistent with configuration file cd / data/mongodb/touch mongod2.log / / enter mongodb directory to add log file chmod 777 mongod2.log / / add permissions mongod-f / etc/mongod2.conf / / load the configuration file of the new column

Mongo-- port 27018 / / enter the library netstat-ntap corresponding to the new real column | grep mongod / / exit the real column to view the port

2. Basic commands of MongoDB

Mongo / / enter database use mydb; / / create if no collection exists, delete db.createCollection ('a') / / create collection db.a.insert ({"id": 1, "name": "zhangsan"}) / / insert data db.a.find () into collection a / / query all data for in collection a

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report