---
title: "MongoDb的“not master and slaveok=false”错误及解决方法"
author: "paynexss"
date: "2017-09-08T14:56:01Z"
tags: ["MongoDB"]
categories: ["数据库"]
slug: "mongodb-not-master-and-slaveok-false"
draft: false
lastmod: "2017-09-08T14:56:01Z"
id: 2392611
url: "https://paynexss.iteye.com/blog/2392611"
---

在SECONDARY查询出发现如下错误：

> SECONDARY&gt; show collections;  
> Sat Aug  4 15:29:00 uncaught exception: error: { "$err" : "not master and slaveok=false", "code" : 13435 }

这是正常的，因为SECONDARY是不允许读写的，如果非要解决，方法如下：

> SECONDARY&gt; rs.slaveOk();