MongoDB Introductory tutorials in the common operation of the technology introduction _MONGODB

Source: Internet
Author: User
Tags mongodb mongodb server mongorestore

We look at MongoDB from an administrator's point of view, as an administrator, we are often exposed to 4 main areas:

1. Install deployment

2. State Monitoring

3. Security certification

4. Backup and Recovery,

Here we will explain the 1.1 points.

One: Install deployment

My previous article is to use the console program to load, but in the production environment this is not the best practice, who is not willing to restart the machine after the ground looks like looking for MongoDB,

In MongoDB, a model called "service boarding" is provided, and I think it is easy to understand if you are familiar with WCF. OK, let's practice, here I'll open the MongoDB in the D-plate.

Here are two points to note:

<1> LogPath: When we use the service boarding, we can use our eyes to understand that we will not use the console to host the log information.

<2> Install: Open installation Service boarding, very happy Ah, the administrator to minimize the manual operation, thanks to MongoDB.

Well, the console program tells me to look at log logs, and I'll look at it and find out how MongoDB has prompted us to open MongoDB, and then I'll just do it.

To remind you that these command parameters are very complex and easy to forget, but it doesn't matter, the database gives us a help method, we can

Take Mongod and MONGO to say something.

Mongod:

Mongo

Second: State monitoring

Monitoring allows us to understand the health status of the database and performance tuning in real time, providing us with three ways in MongoDB.

1:http Monitor

This I also mentioned in the previous article, here is not to repeat.

2:serverstatus ()

This function can obtain MongoDB server statistics, including: Global lock, Index, user action behavior and so on these statistics, to the administrator is very

Important, the specific parameter meaning can refer to this article: http://www.jb51.net/article/53878.htm

Here is still a picture of the cross look familiar.

3:mongostat

In front of those statistics again cow X, that is also static statistics, can not let me watch real-time data changes, fortunately, MongoDB inside provides here to say Mongodstat

Monitor, this thing will refresh every second, in the actual production environment of great use, or cut a picture, very interesting, is not feeling the army border.

Third: Safety certification

As a database software, we certainly do not want to have access to anyone, in order to ensure the security of data, MongoDB will be like other database software can use the user

Verification method, then what should be done? In fact, it's very simple, MongoDB provides the AddUser method, and one of the points to note is that if you add in the Admin database

will be considered "super admin".

The Admin user above will be considered a super administrator, and the third parameter appended by the "Jack" user indicates whether it is a "read-only user", OK, we've added all the additions,

The first time we logged in was not a validation mode, we now use--reinstall to restart the service and log in in--auth authentication mode.

Okay, we'll go into the test set and look at the situation, and we find that Jack's users are always without permission to write, either authorized or unauthorized.

IV: Backup and Recovery

The importance of this thing I don't think I need to say it, if this thing can be dead, mongodb inside the commonly used means there are 3 kinds.

1: Direct copy

This is the simplest, but note that in the case of server running direct copy is very risky, may be copy out when the data has been

Destruction, the only guarantee is to temporarily shut down the server, copy after the restart.

2:mongodump and Mongorestore

This is MONGO to provide us with the built-in tools, very useful, to ensure that the server does not shut down the case of copy data.

For ease of operation, we first remove the authorized user.

Okay, let's get to the point where I'm going to set up a backup folder in D to store the test database.

Look, the data has been backed up, too cool, now we use Mongorestore to restore the past, remember Ah, it is not to shut down the machine.

Here's the drop option, which means that I delete the data from the original database before I recover the test data, and you can see it through help.

3: Master-slave copy

This I have in the previous article has introduced, here also does not repeat.

In fact, the above 1, 22 points can not guarantee the real-time data acquisition, because we are in the backup may still have data pouring in memory does not come out, then we

Want to say can the data violent brush to the hard disk, of course, MongoDB gives us the fsync+lock mechanism can meet our demand.

Fsync+lock will first brush the buffer data into the hard drive, then give the database a write lock, the other instances of the write operations are blocked until the Fsync

+lock Release the lock.

There's no testing here.

Lock: Db.runcommand ({"Fsync": 1, "Lock": 1})

Release Lock: Db. $cmd. Unlock.findone ()

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.