I am currently using mongodb database to store my openhab items values.
here is my mongodb.cfg file:
url=mongodb://localhost:27017
database=openhab
collection=serial
I am able to access the Local MongoDB database from mongo client running on my PC.
Now in MongoDB Atlas, i have created database named openhab, with collection serial. But as I try to connect to my MongoDB Atlas port, by replacing localhost with the port details as given below: url=mongodb://gettingstarted-shard-00-01-cawjp.mongodb.net:27017
It gives me error of " The activate method has thrown an exception
java.lang.RuntimeException: Cannot connect to database ".
Can anyone help me to understand how to store data on MongoDB Atlas using mongodb persistence.
I just realized something else… the binding configuration does not provide config parameters for authentication and most likely (99,999% chances) the cloud based MongoDB you are using @ mongodb.com/cloud/atlas requires auth
so… this won’t work
although undocumented (untested and most likely not going to succeed), try to set in your mongodb.cfg:
I believe that this will be treated with super low priority, so don’t wait for a fast fix
Even if this happens, I don’t know if the developers will enable the advanced auth mechanisms that Atlas requires…
If I was you, I would consider: store locally on a MongoDB and find a way to replicate the data that you want to the Cloud using a synchronization method that MongoDB provides for (I have no idea what replication mechanisms MongoDB supports with Atlas DBaaS… you will need to read up on that )
Okay i have tried passing authorization in URI, but still facing issue of cannot connect to DB.
url = mongodb://:@gettingstarted-shard-00-01-cawjp.mongodb.net:27017
Ps: When posting configs, use code fences simple one line code: single grave accent (`) character : `text` , more complex code: three grave accent characters in separate lines : ``` new line <code> new line```
it really depends on what you want to achieve (give us a short description of your desired scope)
If only restoreOnStartup = mapdb (nice and simple with zero maintenance)
if lots of historical data should be retained and more advanced graphs should be generated = InfluxDB (see: InfluxDB+Grafana persistence and graphing)
Of course, you can combine both of them (mapdb + InfluxDB Persistence Services in OH2) to achieve both goals at the same time.