rs.slaveOK won't run on secondary node

I’m trying to perform the lecture instructions for “Reads and Writes on Replica Sets”.

  1. The replica set is started. I’ve verified that by running rs.isMaster() from the primary.
  2. I’ve created the collection newDB.new_collection.
  3. I’ve inserted the document {student: “Matt Javaly”, grade: “A+”} into new_collection.
  4. I successfully connected directly to one of the secondaries using the command:
    mongo --host “192.168.103.100:27002” -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”
  5. I issued the command “show dbs”. That failed with the expected error. So far so good.
  6. I issued the command “rs.slaveOK” which returned the unexpected error:
    2019-06-29T15:07:14.432+0000 E QUERY [thread1] TypeError: rs.slaveOK is not a function :
    @(shell):1:1

Does anyone know why rs.slaveOK() is not a function? Thanks.

Never mind. Careless capitalization mistake. I was typing “rs.slaveOK()” instead of “rs.slaveOk()”

1 Like