Home » Eclipse Projects » Kura » persistance in kura(h2 data base )
| |
Re: persistance in kura [message #1778246 is a reply to message #1778216] |
Tue, 12 December 2017 09:50 |
Nicola Timeus Messages: 17 Registered: May 2017 |
Junior Member |
|
|
Hi,
if you have not already done so, I would recommend you to have a look at this guide as well:
https://eclipse.github.io/kura/builtin/h2-database.html
before reading the guide you mentioned.
Basically Kura provides the following two database-related services:
H2DbService (factory pid org.eclipse.kura.core.db.H2DbService): This represent an actual database instance that can be used to store your data, and it is identified by the following two identifiers:
- a JDBC URL, like the one you mentioned (jdbc:h2:mem:testdb) that can be provided to external applications for connecting to the database.
- the Kura service pid: a Kura specific identifier that can be supplied to other services that run inside Kura (like the DataService, the H2 db wire components) to select a specific db instance.
All data published by an application (like Heater) using a CloudService/DataService is stored into an H2DbService instance (the one selected in the DataService configuration) inside the "DS_MESSAGES" table.
H2DbServer: This is a component that provides access to the Kura database instances (instances of H2DbServices) to processes running outside Kura.
It is basically just a server that provides access to existing db instances trough some network protocol (JDBC, Postgres) and, in addition, is also capable to provide a web console that can be used to inspect the database instances.
If I understand correctly, you are trying to open the H2 web console using your browser, but your H2DbServer instance is configured for JDBC (TCP type), if this is the case the H2DbServer instance must be reconfigured as follows:
- db.server.type: WEB
- db.server.commandline: -webPort 9123 -webAllowOthers -ifExists
then you should be able open the web console, provided that port 9123 is open in the firewall configuration section.
By the way, I'm not able to open the dropbox links you posted, can you please attach the screens like you did for testdb.png?
In any case, you can find more details regarding the H2DbService and H2DbServer components and their configuration in the guide I posted above.
Best Regards,
Nicola
|
|
| | |
Re: persistance in kura [message #1778268 is a reply to message #1778263] |
Tue, 12 December 2017 13:23 |
Nicola Timeus Messages: 17 Registered: May 2017 |
Junior Member |
|
|
Hi
For viewing the data published by the heater demo, you need to enter in the Web console the db url of the instance used by the DataService, in this case you should be able to find the data inside the "DS_MESSAGES" table.
In the default configuration, this instance is automatically created, and it has the "H2DbService" kura service pid, (you should see it under Services in the web ui) and its db url should be "jdbc:h2:mem:kuradb". By entering this last URL in the Web console you should be able to see the heater data.
If use the "jdbc:h2:mem" URI you are creating an in-memory (RAM) database instance, that is not persisted on the device storage, so there are no files involved.
In-memory dbs are quite fast and do not wear out flash storage, but all data contained in them is lost when Kura is restarted, the db instance is deleted, or if you change the URL of the db instance to something different.
You can use this for non-critical temporary data that is frequently updated, and it is the default for the Data Service db.
Using the "jdbc:h2:file" URI you get a persistent database instance, that uses a regular file for storing the data.
In this case the data is retained as long as the backing file exists, you can append different parameters to the url string for tuning the db performance and reliability.
You can find more details about the db URIs at the end of the guide I've posted above and in the official H2 documentation, for example here:
http://www.h2database.com/html/features.html#database_url.
In this case it is not necessary to create the files before opening the instance, they will be created automatically.
One more thing about the H2DbServer: if you need to use the TCP/JDBC server and the Web console at the same time, you can create two different H2DbServer instances listening on two different ports.
One instance needs to be configured in TCP mode and the other one in WEB mode.
Best Regards,
Nicola
|
|
| | | | | | |
Re: persistance in kura [message #1778433 is a reply to message #1778378] |
Thu, 14 December 2017 09:06 |
ermanno porporato Messages: 26 Registered: November 2017 |
Junior Member |
|
|
Thanks for the answer. I think the problem is just that sometimes there are more running instances..
Generally in eclipse I start the Eclipse project by launching right click on the script Kura_emulator ...
then I open the Kura console in browser, localhost:8080,
(wires, configuration, ecc..)
at the end I stop with the small red square 'Terminate' in eclipse
I do not understand what do you mean with ' stop button above the console' (??)
The problem is that often, apparently, the situation does not change also closing eclipse..
n.b. we are always working in windows, the script to launch is the script 'home made' by us' modifying the script for linux... (and works well, no problems)
[Updated on: Thu, 14 December 2017 09:26] Report message to a moderator
|
|
|
Re: persistance in kura [message #1778437 is a reply to message #1778433] |
Thu, 14 December 2017 09:34 |
ermanno porporato Messages: 26 Registered: November 2017 |
Junior Member |
|
|
Here is an exemple of wires used, 'MODBUS ASSET' receives the data from a modbus simulator, 2 channels, timer set to 5 seconds
(broker activemq, publish and subscribe without problems)
And then the data written in the db, table 'mytable3' (yesterday, now there are problems...)
-
Attachment: gra1.jpg
(Size: 45.97KB, Downloaded 226 times) -
Attachment: gra2.jpg
(Size: 216.73KB, Downloaded 211 times)
[Updated on: Thu, 14 December 2017 10:05] Report message to a moderator
|
|
|
Re: persistance in kura [message #1778451 is a reply to message #1778437] |
Thu, 14 December 2017 10:26 |
ermanno porporato Messages: 26 Registered: November 2017 |
Junior Member |
|
|
I made several attempts, including deactivating the bundle heater, turning off the computer, restarting everything and verifying that the modbus simulator works correctly.
Now it seems that everything works, if I stop the project and restart it kura resumes to write the records correctly, even without closing eclipse .. however any advice about this type of problems is always welcome..
[Updated on: Thu, 14 December 2017 10:27] Report message to a moderator
|
|
|
Re: persistance in kura [message #1778501 is a reply to message #1778451] |
Fri, 15 December 2017 08:21 |
ermanno porporato Messages: 26 Registered: November 2017 |
Junior Member |
|
|
a report that can be useful: this morning the wire graph above
(message #1778437 ) did not write anything on the db. I removed only connection with the wire component H2DBSTORE, save, re-establish the connection, save, and the writing has begun .. without stopping anything
[Updated on: Fri, 15 December 2017 08:22] Report message to a moderator
|
|
| | | | |
Goto Forum:
Current Time: Thu Sep 26 14:34:43 GMT 2024
Powered by FUDForum. Page generated in 0.08288 seconds
|