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

A complete Collection of MongoDB installation and Operation

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

Share

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

Brief introduction

MongoDB is a database based on distributed file storage. Written in C++ language. Designed to provide scalable high-performance data storage solutions for WEB applications. MongoDB is a product between relational database and non-relational database, which is the most functional and most like relational database in non-relational database. It supports a very loose data structure, which is similar to json's bson format, so it can store more complex data types. The most important feature of Mongo is that the query language it supports is very powerful, and its syntax is somewhat similar to the object-oriented query language. It can almost achieve most of the functions similar to the single table query of relational database, and also supports the establishment of data indexing.

Characteristics

For collection storage, it is easy to store data of object type. Mode freedom. Dynamic query is supported. Full indexing is supported, including internal objects. Query is supported. Replication and failure recovery are supported. Use efficient binary data storage, including large objects such as video, etc. Automatically handle fragments to support scalability at the cloud computing level. Support for RUBY,PYTHON,JAVA,C++,PHP,C# and other languages. The file is stored in BSON (an extension of JSON). Can be accessed through the network.

Suitable for scenario website data caching large size, low value data highly scalable scenarios for object and JSON data storage highly transactional systems traditional business intelligence applications

Issues that require SQL

1. MongoDB installation

1. Add a yum source

Vim / etc/yum.repos.d/mongodb-org.repo

[mongodb-org]

Name=MongoDB Repository

Baseurl= https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/

Gpgcheck=1

Enabled=1

Gpgkey= https://www.mongodb.org/static/pgp/server-3.6.asc

2. Install mongodb

Yum list

Yum install mongodb-org-y

3. Edit the configuration file

The configuration file for vim / etc/mongod.conf # yum installation is under / etc

Port: 27017 # listening port

BindIp: 0.0.0.0 # listening address

4. Start the service

Systemctl start mongod.service # method 1

Mongod-f / etc/mongod.conf # method II

Netstat-anpt | grep 27017 # View Port

5. Shut down the service

Mongod-f / etc/mongod.conf-- shutdown # method 1

Kill-9 process number # method II

6. Enter the database

2. Multi-instance operation

1. Edit the configuration file of instance 2

Cd / etc/

Cp-p mongod.conf mongod2.conf # copy profile

Vim mongod2.conf # modify the configuration file

Path: / data/mongodb/mongod2.log dbPath: / data/mongodb/mongod2 port: 27018

2. Create a log file and data file storage directory

Mkdir-p / data/mongodb/

Cd / data/mongodb/

Mkdir mongod2

Touch mongod2.log

Chmod 777 mongod2.log

3. Open instance 2

Mongod-f / etc/mongod2.conf

4. View the port

Netstat-ntap

Basic operating commands

# increase

/ / if it does not exist, it will be created. If it is not established, it will be deleted.

Use mydb

/ / insert data

Db.createCollection ('a')

Db.a.insert ({"id": 1, "name": "zhang1"})

For (var item2witi

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