in Education by
I tried mongo replica sets for the first time. I am using ubuntu on ec2 and I booted up three instances. I used the private IP address of each of the instances. I picked on as the primary and below is the code. mongo --host Private IP Address rs.initiate() rs.add(“Private IP Address”) rs.addArb(“Private IP Address”) All at this point is fine. When I go to the http://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com:28000/_replSet site I see that I have a primary, secondary, and arbitrary. Ok, now for a test. On the primary create a database in this is the code: use tt db.tt.save( { a : 123 } ) on the secondary, I then do this and get the below error: db.tt.find() error: { "$err" : "not master and slaveOk=false", "code" : 13435 } I am very new to MongoDB and replicates but I thought that if I do something in one, it goes to the other. So, if I add a record in one, what do I have to do to replicate across machines? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Mongo shell has to know that you are allowing read operations from secondaries, this means you have to set “slave okay”. Do this: rs.slaveOk() So, you only need to do this when you query secondaries and need to be used only once per session. After this, you can normally query secondaries.

Related questions

0 votes
    I'm attempting to copy my MySQL database from an Amazon EC2 to an RDS: I successfully did a mysqldump of ... easy question. Thoughts? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I am trying to use aws container service as per the documentation in http://docs.aws.amazon.com/AmazonECS/latest/ ... in a console? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I've created a new linux instance on Amazon EC2, and as part of that downloaded the .pem file to allow me ... Nov 11:20 amazonec2.pem Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I ... user's guide. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I installed Ubuntu 12.04 on my instance and am trying to install packages using apt-get, but I am getting the ... do I fix this? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I have a server from AWS EC2 service running on Linux Ubuntu and I have installed Apache, PHP, and MySQL. I have ... How to fix this? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    Input: {_id:ObjectID(123),ip:'123.123.123.123'} {_id:ObjectID(123),ip:'123.123.123.123'} ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I want to query something with SQL's like query: SELECT * FROM users WHERE name LIKE '%m%' How to do I ... like in the documentation. Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I want to automate the launch of a set of Linux EC2 instances. Basically, I want to write a script/program that ... in Amazon AWS/EC2? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    When you setup an Auto Scaling groups in AWS EC2 Min and Max bounds seem to make sense: The minimum number of ... is larger than Min? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    When I launch an instance on EC2, it gives me an option for t1.micro, m1.small, m1.large etc. There is a ... of what these terms mean? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    Recently Amazon launched Lightsail. Is there any difference between them? If yes, then what's the difference? Are ... than EC2? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    I'm unclear as to what benefits I get from EBS vs. instance-store for my instances on Amazon EC2. If ... is still relatively new? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
...