Home > Database > Mysql Tutorial > mongodb master slave常用命令

mongodb master slave常用命令

WBOY
Release: 2016-06-07 14:53:57
Original
1443 people have browsed it

mongodb master slave常用命令 1. 在slave查看同步状态 www.2cto.com db.printSlaveReplicationInfo() 2. 如果长时间没有同步上master 重启服务, 或 use admin db.runCommand({resync: 1}) http://www.mongodb.org/display/DOCS/Halted+Replication 3. Mast

mongodb master slave常用命令

 

1. 在slave查看同步状态

  www.2cto.com  

db.printSlaveReplicationInfo()

 

2. 如果长时间没有同步上master

 

重启服务,

 

> use admin

> db.runCommand({resync: 1})

 

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

 

 3. Master机器出问题怎么办?  www.2cto.com  

如果Master机器挂了,那么我们可以先把Slave改成Master让其提供服务:

 

在Slave上先停止mongod:

 

service mongod stop

 

再删除本地数据库,因为slave的相关信息存在这里面了。

cd /var/lib/mongo

 

rm -rf local.*

 

在配置文件内把slave改成master:

 

vi /etc/mongod.conf

 

删掉下面几行:

slave = true

source = 192.168.1.174

autoresync = true

 

增加:

master = true

 

最后再启动mongod:

 

service mongod start

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template