Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Maintaining MongoDB and Solr

Sri Maurya Kummamuru edited this page Jan 20, 2021 · 5 revisions
Warning: This page is going to be retired and this documentation will be maintained at - https://github.com/OpenConceptLab/ocl-docs/

Overview

OCLAPI's data is kept in MongoDB and Solr. MongoDB and Solr are wrapped in ocl_mongo and ocl_solr containers, respectively.

docker-compose.yml in the codebase dictates that an evironment variable named DATA_ROOT is provided to the container images so that Solr and MongoDB data is kept physically in the host machine and their data is not lost when ocl_mongo and ocl_solr containers are restarted. If DATA_ROOT environment variable is not provided, the data will be lost, MongoDB data will need to be restored from backup (see backup page for details) and Solr index will need to rebuilt from scratch in order to eliminate consistencies.

Right now, DATA_ROOT variable is provided through the build pipeline and it is /data/ocl/.

Data issues

This is mostly a QA or Staging environment issue, should not happen in Production ever. Data could be corrupt or inconsistent and result in one of the following:

ocl_mongo stops as soon as started

This happens usually when MongoDB gets a segmentation fault. Most likely the following has happened

  • ocl_mongo container was started with its data stored in the host machine (i.e DATA_ROOT was set). The physical location (DATA_ROOT) was removed and ocl_mongo was recycled.

In order to resolve this, contents of /data/ocl/mongo/ should be removed, and ocl_mongo container be deleted. Then a deployment could be done and mongo data could be restored from a backup.

Search page on ocl_web returns an error unless the search term is not returning any results

This happens when the data between Solr and MongoDB is inconsistent due to MongoDB losing data and Solr index getting stale because of that.

Two possible solutions:

  • Run yes | docker exec -it ocl_api python manage.py rebuild_index
  • Delete contents of /data/ocl/solr/ and redeploy ocl_api through build pipeline.

Connecting to MongoDB instance from a personal computer

Mongo port 27017 is closed to access from outside world, therefore SSH authentication is required in order to access Mongo instance on any of the QA (Showcase), Staging or Production environments.

  • Download or brew cask install robomongo RoboMongo
  • Click "Create connection"
  • Enter the following information:
  • New Connection 1
  • New Connection SSH
  • It should look like this Mongo Collections
  • All set! Should be able to browse collections
Clone this wiki locally