Mongodbmasterslave Common commands

Source: Internet
Author: User
Mongodbmasterslave Common commands 1. check the synchronization status of www.2cto on slave. comdb. printSlaveReplicationInfo () 2. if the master service is not restarted after a long period of time, or useadmindb. runCommand ({resync: 1}) www. mongodb. orgdisplayDOCSHalted + Replication3.Mast

Common commands for mongodb master slave 1. check the synchronization status of www.2cto.com in slave. printSlaveReplicationInfo () 2. if the master service is not restarted after a long period of time, or use admin db. runCommand ({resync: 1}) http://www.mongodb.org/display/DOCS/Halted+Replication 3. mast

Common commands for mongodb master slave

1. view the synchronization status on slave

Www.2cto.com

Db. printSlaveReplicationInfo ()

2. If the master node is not synchronized for a long time

Restart the service,

Or

> Use admin

> Db. runCommand ({resync: 1 })

Http://www.mongodb.org/display/DOCS/Halted+Replication

3. What should I do if there is a problem with the Master machine? Www.2cto.com

If the Master machine fails, we can change the Slave to the Master to provide services:

Stop mongod on Slave:

Service producer D stop

Delete the local database because slave information exists.

Cd/var/lib/mongo

Rm-rf local .*

Change slave to master in the configuration file:

Vi/etc/mongod. conf

Delete the following lines:

Slave = true

Source = 192.168.1.174

Autoresync = true

Added:

Master = true

Then start mongod:

Service Producer d start

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.