MongoDB survey notes

Source: Internet
Author: User
Tags mongodb server mongodump mongorestore
Document directory
  • Deployment and startup
  • Master-slave backup
  • Cold backup
  • Auxiliary development tools
  • Performance monitoring
  • Advantages and disadvantages
  • Finally, compare the query languages of nosql and RDBMS systems.

Http://blog.csdn.net/aegis1019/article/details/6902704

 

 

For cost considerations, the company intends to port historical data from Oracle to an open-source database, which is just divided into MongoDB research tasks. Since the research report has been completed, here is a simple summary for future reference.

It's just a bit messy.

MongoDB is a distributed document-type database. Currently, most of it is used in Web2.0 projects, which may not be suitable for our current projects. Most of it is used to assist relational databases in storage. Of course, it is also used separately, it is said to have performed well in processing massive data. However, the actual test performance is not satisfactory, far from reaching the Oracle level, and the performance is close to that of MySQL. However, it focuses on scalability and focuses on different advantages.

An example of MongoDB's most famous application downtime is that 4square's failure to handle 11 hours of downtime due to automatic sharding won't be solved until 10gen support.

Deployment and startup

The MongoDB server can run on Linux, windows, or OS X. It supports 32-bit and 64-bit applications. The default port is 27017. We recommend that you run on a 64-bit platform because MongoDB supports a maximum file size of 2 GB when running in 32-Bit mode.

The deployment is easy. Download the available version of the operating system on the mongodbofficial network. mongod.exe-dbpath =/opt/mongdb/Data specifies the database data directory to complete the startup. Enter http: // localhost: 27017/in the browser to display the port setting prompt.

Master-slave backup

There are two modes: master-slave mode and mutual master-slave mode. Both modes do not necessarily require two machines. You can deploy two databases on the same machine as the master slave. However, we do not recommend that you do this because it is difficult to consider disaster tolerance.

Master-slave mode command: master machine mongod -- dbpath./data/mongodb1 -- master -- logpath./data/mongdb1.log -- logappened

Slave machine mongod -- dbpath./data/mongodb2 -- source 127.0.0.1: 27017 -- autoresync -- slavedelay 30 -- logpath./data/mongodb2.log -- Port 27018 -- logappend

-- Autoresync automatically restarts the replication operation 10 seconds after the slave node is not synchronized. If the -- autoresync parameter is specified, only one operation is performed to automatically re-synchronize data from the node within 10 minutes.

In the master-slave mode, the master-slave command is added to the master-slave command. The master-slave mode can be automatically switched Based on the server load.

Cold backup

Cold data backup can be completed through the dump and restore tools provided by MongoDB.

Command syntax:

> Mongodump-H dbhost-D dbname-O dbdirectory

-H: the address of the mongdb server, such as 127.0.0.1. You can also specify the port number 127.0.0.1: 27017.

-D: The database instance to be backed up, for example, test

-O: The storage location of the backup data, for example,/data/dump. Of course, this directory must be created in advance. After the backup is complete, the system automatically creates a test directory under the dump directory, this directory stores the backup data of the database instance.

> Mongorestore-H dbhost-D dbname -- directoryperdb dbdirectory

-H: Address of the MongoDB Server

-D: The database instance to be restored, for example, test. Of course, this name can be different from that during backup, for example, Test2.

-- Directoryperdb: Location of the backup data, for example,/data/dump/test.

-- Drop: Delete the current data and restore the backup data. That is to say, after the restoration, all the data added and modified after the backup will be deleted.

Distributed tests are not performed.

Auxiliary development tools

Built-in tools: like Oracle, MongoDB also comes with some auxiliary development tools: mongo.exe, mongoexport.exe, and mongoimport.exe, mongodump.exe, and mongorestore.exe. Restore is a database backup and recovery tool. These tools are all black screen tools.

There are also some third-party development auxiliary tools for MongoDB. Here I personally recommend a PHP-based development tool, rockmongo, which can be written in code. download from Google and link to the MongoDB official website. The interface is similar to PL/SQL develop.

Performance monitoring

MongoDB can use profile to monitor and optimize data. Run the following command to check whether the profile function is Enabled:

DB. getprofilinglevel () returns the level. The value is 0 | 1 | 2, indicating that 0 indicates that the log is disabled, 1 indicates that the log is slow, and 2 indicates that the log is all.

Start the profile function:

DB. setprofilinglevel (level); # level. The value is the same as above. When the level is 1, the default value of the slow command is 100 ms, Which is changed to DB. setprofilinglevel (Level, slowms), such as DB. setprofilinglevel (), which is changed to 50 ms.

View the current monitoring log through dB. system. profile. Find (). Parameter Analysis:

If it is found that the time is long, optimization is required. For example, if the nscanned number is large or close to the total number of records, the index query may not be used. Reslen is very large and may return unnecessary fields. Nreturned is very large, so it is possible that there is no limit to the query.

The value here indicates:

TS: command execution time

Info: Command content

Query: queries

Order. Order: indicates the database and set to be queried.

Reslen: returned result set size and size, number of bytes

Nscanned: Number of scan records

Nquery: followed by query Conditions

Nreturned: number and time of returned records

Millis: time spent

View the running status of mongod through dB. serverstatus:

> DB. serverstatus ()

{

"Host": "Baobao-laptop", # Host Name

"Version": "1.8.2", # version number

"Process": "mongod", # process name

"Uptime": 15549, # running time

"Uptimeestimate": 15351,

"Localtime": isodate ("2011-07-23t06: 07: 31.220z"), current time

"Globallock ":{

"Totaltime": 15548525410, # total running time (NS)

"Locktime": 89206633, # total lock time (NS)

"Ratio": 0.005737305027178137, # Lock Ratio

"Currentqueue ":{

"Total": 0, # the queue to be executed

"Readers": 0, # Read queue

"Writers": 0 # Write queue

},

"Activeclients ":{

"Total": 0, # number of links executed by the current client

"Readers": 0, # Number of read links

"Writers": 0 # Number of write links

}

},

"Mem": {# Memory Condition

"Bits": 32, #32-bit System

"Resident": 337, # occupied physical memory

"Virtual": 599, # occupies virtual memory

"Supported": True, # whether memory expansion is supported

"Mapped": 512

},

"Connections ":{

"Current": 2, # current link count

"Available": 817 # number of available links

},

"Extra_info ":{

"NOTE": "fields vary by platform ",

"Heap_usage_bytes": 159008, # heap usage bytes

"Page_faults": 907 # Old page

},

"Indexcounters ":{

"Btree ":{

"Accesses": 59963, # Number of indexed partitions

"Hits": 59963, # The number of hits

"Misses": 0, # Number of index deviations

"Resets": 0, # reset count

"Missratio": 0 # No hit rate

}

},

"Backgroundflushing ":{

"Flushes": 259, # refresh times

"Total_ms": 3395, # Total refresh duration

"Average_ms": 13.108108108108109, # average duration

"Last_ms": 1, # last time

"Last_finished": isodate ("2011-07-23t06: 07: 22.725z") # Last refresh time

},

"Cursors ":{

"Totalopen": 0, # Number of opened cursors

"Clientcursors_size": 0, # client cursor size

"Timedout": 16 # timeout

},

"Network ":{

"Bytesin": 285676177, # input data (byte)

"Bytesout": 286564, # output data (byte)

"Numrequests": 2012348 # Number of requests

},

"Opcounters ":{

"Insert": 2010000, # insert operations

"Query": 51, # query operations

"Update": 5, # update operations

"Delete": 0, # delete operations

"Getmore": 0, # Get more operations

"Command": 148 # other command operations

},

"Asserts": {# Number of assertions

"Regular": 0,

"Warning": 0,

"MSG": 0,

"User": 2131,

"Rolovers": 0

},

"Writebacksqueued": false,

"OK": 1

}

Advantages and disadvantages

Advantages:

A high configuration type can minimize the pressure on O & M personnel. Easy-to-use and understandable APIs. Low insertion and query performance also reduces the pressure on developers. Document model data storage, and some internal design to avoid join between tables, can provide a simple and easy to expand architecture. Moreover, data cannot be split due to unattended misuse. MongoDB is a data-driven persistent tool that is suitable for small and medium-sized teams with insufficient manpower to process massive data with high concurrency and high availability. Open source, free of charge, squeeze machine performance.

Disadvantages:

First, the introduction of Schema free and bson makes the data expansion obvious, which is generally 5 ~ 10 times is very easy, because every doc will fully store all the keys and values, even if the structure is the same doc, so the storage file will increase dramatically, if a 32-bit operating system is used, the size of a single file is easily reached. Therefore, MongoDB must use a 64-bit operating system. Second, the use of MMAP (2) makes the read/write scheduling control and Cache control not detailed enough, which makes it easier for programmers to write programs. However, when the amount of data exceeds the memory size, the OS-Based Switching policy alone cannot meet the actual needs. In this case, the performance jitter is severe. Third, multi-table join queries and transactional operations are not supported. In addition, the security is not high, and the operating system needs to allocate memory for it, occupying and consuming a huge amount of memory (different people may say this may be caused by clusters and development environments ), the read/write lock granularity is too coarse.

Finally, compare the query languages of nosql and RDBMS systems.

It should be noted that nosql does not support multi-table joint queries. It can only query a single table, almost the same level as SQL.

 

Mongodb's vs2005driver can only upload .jpg files. rar you know

 

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.