MongoDB Persistence with OpenHAB 2

I’m trying just today to use OH2 with mongodb.
I followed the guide to configure oh1 to oh2, configuring addons,cfg and runtime.cfg as explained in
https://docs.openhab.org/tutorials/migration.html#installing-unofficially-supported-openhab-1x-add-ons
I imported the jre and see the bundle active in openhab karaf container,
I created a mongodb.cfg in conf/services folder to config the server, database and collection.
But unfortunately I receive the following warn:
16:02:21.603 [WARN ] [ig.dispatch.internal.ConfigDispatcher] - Could not parse line ‘mongodb://<>:2701’
I don’t know what I’ve to do to fix it.
Can you help me?

add the following line as the first line in your mongodb.cfg:

pid:org.openhab.persistence.mongodb

and then fix correctly the config parameters as described here: MongoDB - Persistence Services | openHAB

I added your issue in [MongoDB] Enable Add-on and include auth support · Issue #5712 · openhab/openhab1-addons · GitHub

Hello, I am trying to install the MongoDB in Openhab but I can’t find the *.jar file, could anyone tell me where to find or download the *.jar file?

Blockquote Download the latest *.jar manually from:
https://openhab.ci.cloudbees.com/job/openHAB1-Addons/lastSuccessfulBuild/artifact/bundles/persistence/org.openhab.persistence.mongodb/target/

This link does not work anymore,

Thank you

https://ci.openhab.org/job/openHAB1-Addons/lastSuccessfulBuild/artifact/bundles/persistence/org.openhab.persistence.mongodb/target/

Thank you very much

1 Like

Hello again, I have placed de *.jar file, I have configured the .cfg and the .persist files and I have seen with the OH console that the service is active, but, where does the data get storaged? How can I acccess to it?

Thank you

did you install and configure the Mongo Database?
Why mongodb by the way?
what do you want to do with a persistence db?

Yes I have installed de mongodb and I have read that the data is stored in the path /data/db but I cant see anything there, what configurations have to be done? I have installed it, created the path /data/db and then used it to configure the port in the same place that in the .cfg of openhab using this:

sudo mongod --port 27017 --dbpath /data/db/ --fork --logpath /data/mongodb1.log

I have installed mongodb because I want to have a database to store the information of my sensor in my rasp. I am still a begginer and if I dont get it I have thougth to install a MySQL database instead of the MongoDB. What is the problem with a persistence db?

There is no problem (on the contrary…). There are many options and some fit better to each cause.
What is your goal? To store only (for restoreOnStartup)? To display in graphs? To replicate/export data to another system?

In any case, if you go ahead with Mongo, you need to read: https://docs.mongodb.com/manual/

Keep in mind that:

  1. Not many OH2 users use MongoDB as a persistence storage destination
  2. The binding is not “officially” checked for compatibility with OH2
  3. There is maintenance involved with each DB

Describe your goal and we can give some better options

Read also: Persistence | openHAB

My goal is to restoreOnStartup, to display in graphs and to maybe in a future to replicate/export data to another system. I want a system that is the most flexible as possible. After your comment, I think that a MySQL database is better, I don’t know if it is easy to make the graphs with it but maybe I can use another tool as ThingSpeak or Xively.

Now we are talking :slight_smile:

best option (by far): mapdb
MySQL is way slower than MapDB for this purpose

one of the best options: InfluxDB+Grafana persistence and graphing

You can go with a 3rd one here: MySQL or use Influx. MySQL is more flexible here (export/replicas)

You can also achieve all 3 goals with MySQL as your persistence service. Grafana can also use MySQL as the backend DB and you can also do restoreOnStartup from MySQL.

If you want to use only 1 persistence service, go with MySQL using the JDBC driver.

For your setup, I would recommend a triple persistence configuration: Map + Influx + MySQL
Make sure that your host has enough RAM (~2G) to support all 3 :slight_smile:

Well, I am using a Rasp 3 b+ so my RAM is 1GB. So I think after reading you that the best option is to install MySQL with JDBC driver. That driver that you linked me is the same that we can find in the paper UI / add-ons / persistence, “JDBC Persistence MySQL” ?

do I have to download MySQL from the official page and later configure the JDBC driver ?

Then I can use the Grafana to graph the data

And what about the storage in the cloud, what would you recommend me?

Thank you very much

Yes to all 3 :slight_smile:

Directly from OH2 (configuring the persistence service to connect to a Cloud DB): I wouldn’t recommend this due to latency. It can be done but it’s not fast enough and you may experience problems. It’s better to have a local DB.
It also depends if you want to have DB Access on the Cloud or just a backup destination.
For simple backup: Write a script that exports daily the local MySQL DB and ships it over to the cloud destination.
If you want DB Access on the Cloud you can take a look at: https://www.openhab.org/addons/integrations/azureiothub/
Export MySQL->Import in Azure