In order to verify the functionality of the replica set, we need to restore the sample data for the biglittle database onto the primary. To restore the sample data, proceed as follows:
- Copy the sample data from /path/to/repo/sample_data/biglittle*.js to /path/to/repo/chapters/13/common_data.
- Open a shell to member1 (or whichever server was elected the primary):
docker exec -it learn-mongo-member-1 /bin/bash
- Use the mongo shell on member1 to restore the data for biglittle:
mongo /data/common/biglittle_common_insert.js
mongo /data/common/biglittle_users_insert.js
mongo /data/common/biglittle_loans_insert.js
- Enter the mongo shell and confirm that the data has been restored:
- Next, open a mongo shell on either of the secondaries.
- Repeat these commands to confirm that the data has been synchronized:
rs.slaveOk();
use biglittle;
show collections;
db.loans.find().count();
You should see something similar to the following screenshot...