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

How to install Visualizer in MongoDB

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

In this issue, Xiaobian will bring you about how to install visualization tools in MongoDB. The article is rich in content and analyzes and narrates from a professional perspective. After reading this article, I hope you can gain something.

MongoDB uses BSON objects to store, similar to key/value pairs in JSON format. The storage model correspondence between MongoDB database and relational DB:

The theoretical basis of NoSQL database is CAP theory, which stands for Consistency(strong consistency), Availability(availability) and Partition Tolerance(partition tolerance) respectively. Distributed data systems can only satisfy two of these characteristics:

C: The system remains in a consistent state after performing an operation. In a distributed system, all users can read the value of *** after the update operation is successfully performed, and such a system is considered to have strong consistency.

A: The operation performed by the user must return the result within a certain time. If the timeout occurs, the operation rolls back as if it did not occur.

P: Distributed system is composed of multiple partition nodes, each partition node is a separate Server, P attribute indicates that the system can handle the dynamic joining and leaving of partition nodes.

CAP characteristics must be considered when building distributed systems. Traditional relational DB focuses on CA features, and data is generally stored on a Server. Distributed storage and processing systems that handle massive data pay more attention to AP, which has a higher priority than C, but NoSQL does not completely abandon consistency, and NoSQL retains the ultimate consistency of data. Final consistency means that after the update operation is completed, the user will eventually read the value after the data update, but there will be a certain time window, and the user will still read the old data before the update; after a certain time delay, the data reaches consistency.

Set the Path environment variable

In Windows environment, MongoDB default installation file storage directory is: C:Program FilesMongoDB Server3.2bin, click Windows+R, enter cmd, start Command Prompt, enter the installation directory:

Every time you open Command Prompt, you need to enter the installation directory of MongoDB, which is very troublesome. You can modify Computer's Environment Variables, right-click This PC->Properties, click Advanced System Setting->Environment Variables, open the Environment Variables window, modify the Path system variable, and append "C:Program FilesMongoDBServer3.2bin" to the string of Path variable. Note that the two Paths are separated by ";".

Two, take you in.

1. Start MongoDB instance

After setting the environment variables successfully, create a folder data in C drive, which is used to store MongoDB database files. Then, open a command-line tool and type mongod to start the MongoDB instance. The default TCP port to listen to is 27017.

mongod

MongoDB starts an HTTP server at the same time, listening on port 27017. If MongoDB instance is installed locally, enter http://localhost:27017/in the browser.

mongod is the core process of MongoDB, responsible for database creation, deletion and other management operations, running on the server side, listening to client requests, and providing data services.

2, Link to MongoDB instance

Do not close the MongoDB instance, open a new command line tool, type mongo, this command starts the mongo shell, the shell will automatically connect to the local (localhost) MongoDB instance, the default port is 27017:

mongo

Mongo process is to construct a Javascript Shell, used to interact with mongod process, according to the interface provided by mongod to manage MongoDB database, equivalent to SSMS(SQL Server Management Studio), is a tool to manage MongoDB.

3. View the DB currently connected

Use the command to view the database name being connected

db db.getName()

4. View db and collection in MongoDB instance

show dbs show collections db.getCollectionNames()

5, switch db

use foo

6. Create a users collection in the foo database and insert a document into the collection.

use foo db.users.insert({"name":"name 1",age:21}) db.users.find()

7, close MongoDB instance

From the mongo shell, execute the following command to close the MongoDB instance

use admin db.shutdownServer()

8, help orders

help

db.help () View database level help

db.mycoll.help () View Collection-level Help

3. Common parameters of mongod command

1, common parameters

mongod is the main daemon of MongoDB system, which is used to handle data requests, data access and perform background management operations. It must be started to access MongoDB database.

When starting mongod, common parameters are:

dbpath: Directory where MongoDB data files are stored

- directoryperdb: Specifies that each database is stored separately in a directory, which is located under the directory specified by-dbpath, and each subdirectory corresponds to a database name. Uses a separate directory to store data for each database. The directories are under the –dbpath directory, and each subdirectory name corresponds to the database name.

- logpath: Specify the file where mongod logs

- fork: Run service as background deamon

- journal: Start log function, reduce recovery time of single fault by saving operation log

- config(or-f): configuration file used to specify runtime options

- bind_ip: Specify the binding IP address of the external service

- port: external service window

- auth: Enable authentication, verify user rights control

- syncdelay: the time for the system to refresh the disk, the unit is second, the default is 60s

- replSet: Start mongod as a replica set, the identity of the replica set is setname

2. How to start MongoDB

2.1 Start by command, default dbpath is C:datadb

mongod --dbpath=C:datadb

2.2 Start as a profile

Write mongod's command parameters into the configuration file and start with parameter-f.

mongod -f C:datadbmongodb_config.config

2.3 Start as a daemon

When the process that started MongoDB is closed, MongoDB is shut down, just use the-fork parameter to make MongoDB start as a background daemon.

mongod -fork

3. Check the startup parameters of mongod

db.serverCmdLineOpts()

IV. Common parameters of mongo command

Mongo is an interactive js shell that provides a powerful js environment for DBAs to manage MongoDB and developers to query MongoDB data. Interacting with MongoDB through the mongo shell, querying and modifying MongoDB databases, managing MongoDB databases, maintaining replica sets and sharding clusters of MongoDB, is a very powerful tool.

When starting the mongo shell, the usual parameters are:

- nodb: prevents mongo from connecting to the database instance at startup;

- port: Specify the TCP port on which mongo connects to mongod, the default port value is 27017;

- host: specifies the server on which mongod runs, if this parameter is not specified, then mongo tries to connect to the mongod instance running locally (localhost);

: Specify the database to which mongo is connected

- username/-u and-password/-p: Specify the account and password to access the MongoDB database, only after authentication, the user can access the database;

- authenticationDatabase: Specify the database in which the User is created. When the User is created in which database, the database is the User Authentication Database;

The above is how to install visualization tools in MongoDB shared by Xiaobian. If you happen to have similar doubts, you may wish to refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.

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