I have a Django (with mongoengine) website that works on read only mode, and an offline python app that populates that MongoDB (read by Django). Facing some locks problems, I've discovered that a replicaset would be an improvement since I could make the Secondary instance the website DB.
At first I just changed my connection to the secondary instance host, and got the error:
Request Method: GET
Request URL: http://localhost:8000/awesomeApp/
Django Version: 1.5
Exception Type: AutoReconnect
Exception Value:
not master
After that, I've tried to solve it with a registered connection, without success and then later upgraded to mongoengine 0.8.7, that could connect with:
connect('awesomeApp', host='mongodb://rs63804-a0.mongoserviceprovider.com:27017,rs63804-a1.mongoserviceprovider.com:27017', replicaSet='rs63804', read_preference=ReadPreference.SECONDARY_PREFERRED, username='scott', password='tiger')
But now I'm getting two different error messages when I use ReadPreference.PRIMARY_PREFERRED or ReadPreference.SECONDARY_PREFERRED...
With PRIMARY_PREFERRED it returns:
Request Method: GET
Request URL: http://localhost:8000/awesomeapp/
Django Version: 1.5
Exception Type: OperationFailure
Exception Value:
not authorized to create index on awesomeapp.django_session
And with SECONDARY_PREFERRED:
Request Method: GET
Request URL: http://localhost:8000/awesomeapp/
Django Version: 1.5
Exception Type: OperationFailure
Exception Value:
database error: not authorized for query on awesomeapp.django_session
I'm stucked at this step, looking for a way to allow that operation through mongoengine and/or mongodb configs, but couldn't find a solution yet.. Any ideias?
Thanks in advance