8-Day Learning mongodb--Seventh Day operation and maintenance technology

Source: Internet
Author: User
Tags mongorestore

In this article we look at MongoDB as an administrator, and as an administrator, there are 4 main areas that we often come into contact with:

1. Installation deployment

2. Status monitoring

3. Security Certifications

4. Backup and Recovery,

Here we will explain 1.1.

One: Installation deployment

My previous articles were hosted by the console program, but this is not a best practice in the production environment, and no one wants to look for MongoDB after the machine restarts,

In MongoDB, a model called "Service Homestay" is provided, and I think it is easy to understand if you are familiar with WCF. All right, let's practice, here I drive the D-Drive.

Inside of MongoDB.

There are two points to note here:

<1> LogPath: When we use the service homestay, we can see with our eyes that we certainly don't use the console to host the log messages.

<2> Install: Open the installation service homestay, very happy Ah, the Administrator's manual operation to minimize, thanks to MongoDB.

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

It is also important to remind you that these command parameters are very complex and easy to forget, but it doesn't matter, the database provides us with a help method that we can

Take Mongod and MONGO to say things.

Mongod

Mongo

II: Status Monitoring

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

1:http Monitor

I also mentioned in the previous article, this is not the case.

2:serverstatus ()

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

Important, the specific parameter meaning can refer to the park friend: http://www.cnblogs.com/xuegang/archive/2011/10/13/2210339.html

This is still a screenshot of the figure is familiar.

3:mongostat

Before those statistic information again Ox X, that is also static statistics, cannot let me watch the real-time data change, fortunately, MongoDB inside provides here to say Mongodstat

Monitor, this thing will refresh every second, in the actual production environment is very useful, or cut a map, very interesting, is not feeling the army foe.

Three: Security certification

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

Verify the method, then how to do it? In fact, MongoDB provides the AddUser method, and one point of note is that if you add it in the admin database

will be considered "super admin".

The Admin user above will be treated as super admin, and the third parameter appended by the "Jack" user indicates whether it is "read-only user", so we have added all the added

We did not use authentication mode the first time we logged in, we now use--reinstall to restart the service and log in in--auth authentication mode.

Well, we go into the test set and turn over the data to see what happens, and we find that Jack's users are always not writable, 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 will be dead, MongoDB, there are 3 of commonly used means.

1: Direct copy

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

Destruction, the only guarantee is to temporarily shut down the server, copy after the re-open.

2:mongodump and Mongorestore

This is the built-in tool that MONGO provides to us, it is very useful, can guarantee to copy data without shutting down the server.

For ease of operation, we first remove authorized users.

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

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

One point is the drop option, which says I delete the data from the original database before I restore the test data, and you can see it through help.

3: Master-slave replication

I have introduced this in the previous article, and I will not dwell on it here.

In fact, the above 1, 22 points can not guarantee the real-time access to data, because we are in the back up when there may be data in memory can not come out, then we

Want to say can the data violence to the hard disk, of course, is possible, MongoDB provides us with a fsync+lock mechanism to meet our needs.

Fsync+lock first will buffer data violence into the hard disk, and then a write lock to the database, the other instances of the write operations are all blocked until Fsync

+lock Release the lock.

It's not going to be tested here.

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

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

8-Day Learning mongodb--Seventh Day operation and maintenance technology

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.