8 days learning MongoDB-7 days O & M Technology

Source: Internet
Author: User
Tags mongorestore

From the Administrator's perspective, as an administrator, we often see four main aspects:

1. installation and deployment

2. Status Monitoring

3. Security Authentication

4. backup and recovery,

Next we will explain it.

 

I. installation and deployment

My previous articles are carried by the console program, but this is not the best practice in the production environment. No one wants to look for mongodb after the machine restarts,

Mongodb provides a "service hosting" mode, which is easy to understand if you are familiar with wcf. Okay, let's take a look at it. Here I will open a drive D.

Mongodb.

 

Note the following two points:

<1> logpath: When we use the service to host, we can see with our eyes that we will not use the console to carry log information.

<2> install: It is very happy to enable the installation service for boarding. It minimizes the manual operations of the Administrator. Thank you for mongodb.

 

Well, the console program asked me to view the log. Then I checked it and found that mongodb has prompted us how to enable mongodb. Then I just did it.

 

We also want to remind you that these command parameters are complex and easy to forget, but it doesn't matter. The database provides us with a help method. We can

Let's talk about things with mongod and mongo.

Mongod:

 

Mongo:

 

Ii. Status Monitoring

Monitoring allows us to know the health status and performance tuning of the database in real time. Three methods are provided in mongodb.

1: http Monitor

I mentioned this in my previous articles. I will not go into details here.

2: serverStatus ()

This function can obtain the server statistics of mongodb, including global locks, indexes, user operations, and so on.

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

Here, we will try to intercept a picture and get familiar with it.

 

3: Using stat

The previous statistics are cool X, which is also Static statistics. I cannot watch real-time data changes. Fortunately, mongodb provides mongodstat.

Monitor, which will refresh every second. It is of great use in the actual production environment. It is interesting to cut a picture. Does it feel overwhelmed.

 

Iii. Security Authentication

As database software, we certainly don't want anyone to access it. To ensure data security, mongodb can also use users like other database software.

The verification method. How can this problem be solved? Mongodb provides the addUser method. Note that if you add

It will be treated as "Super administrator ".

The preceding admin user will be treated as a super administrator. The third parameter appended by the "jack" User indicates whether the user is a "read-only user". Now, we have added all the added parameters,

We did not adopt the Authentication mode when logging on for the first time. Now we use -- reinstall to restart the service and log on in -- auth Authentication mode.

Now, let's go to the test set to flip data to see the situation. We found that jack users are always not authorized to write, whether authorized or unauthorized.

 

Iv. backup and recovery

I don't even need to talk about the importance of this stuff. If it doesn't work well, it will die. There are three common means in mongodb.

1: Direct copy

This is the simplest, but note that it is highly risky to copy data directly when the server is running. data may have been copied

Damage, the only guarantee is to temporarily shut down the server, copy the server and re-open it.

2: mongodump and mongorestore

This is a built-in tool provided by mongo. It is easy to use and can copy data without shutting down the server.

For ease of operation, delete the authorized user first.

 

Now, let's go to the topic. Here we will first create a backup folder on drive d to store the test database.

It's amazing that the data has been backed up. Now we use mongorestore to restore it. Remember, it doesn't have to be shut down.

The drop option is mentioned. Here we will delete the data in the original database before restoring the test data. You can also view the data through help.

 

3: master-slave Replication

I will introduce this in the previous article, and I will not repeat it here.

 

In fact, the above two points do not guarantee the real-time data acquisition, because we may still have data in the memory during backup, so we

I want to say whether or not we can forcibly fl data to the hard disk. Of course, mongodb provides us with the fsync + lock mechanism to meet our requirements.

Fsync + lock first fl the buffer data into the hard disk and then a write lock to the database. All write operations on other instances are blocked until fsync

+ Lock to release the lock.

I will not test it 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.