Read data from Secondary without use rs.slaveOk() in Mongo Shell.

1,749 views
Skip to first unread message

Tom Vo

unread,
Sep 20, 2012, 2:43:25 AM9/20/12
to mongod...@googlegroups.com
Dear all
I setup Replication Set on my system with 1 Primary (port 27017), 1 Secondary (port 27018), 1 Arbiter (port 27019).
Could I read data from Secondary without use rs.slaveOk() in Mongo Shell?


db1 = connect('localhost: 27018 /dbtest')

col1 = db1.getCollection("coltest")

col1.findOne()

Thu Sep 20 13:42:30 uncaught exception: error: { "$err" : "not master and slaveok=false", "code" : 13435 }

Thanks.
Tom Vo

prashant gupta

unread,
Sep 20, 2012, 3:09:53 AM9/20/12
to mongod...@googlegroups.com
try using db.getMongo().setSlaveOk()

Tom Vo

unread,
Sep 20, 2012, 3:21:31 AM9/20/12
to mongod...@googlegroups.com
Dear Sir
Your command help me to solute some problems.
Thanks you for your suggestions.

Tom Vo


try using db.getMongo().setSlaveOk()
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb



--

Thanks and Best Regards
-------------------------------------------------------------------------------------------------------------
Vo Tan Hau (TOM)
Senior Database Administrator
NEXCEL SOLUTIONS LTD
SMS Tower,Lot 40, Quang Trung Software City, District 12, HCMC, Vietnam.
Tel:+84-8-37154278 - Fax:+84-8-37154279 www.nexcel.vn
Messenger
(Skype+Yahoo+Live): Vohau2002


Reply all
Reply to author
Forward
0 new messages