db.rst 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. .. _monitor_db:
  2. Database Persistence
  3. ====================
  4. The monitor extension is capable of persisting request data to a database via the
  5. `Hibernate <http://www.hibernate.org/>`_ library.
  6. .. note::
  7. In order to utilize hibernate persistence the hibernate extension must be installed on
  8. top of the core monitoring extension. See the :ref:`monitor_installation` for details.
  9. Configuration
  10. -------------
  11. General
  12. ^^^^^^^
  13. In order to activate hibernate persistence the ``storage`` parameter must be set to the
  14. value "hibernate"::
  15. storage=hibernate
  16. The hibernate storage backend supports both the ``history`` and ``live`` modes however
  17. care should be taken when enabling the ``live`` mode as it results in many transactions
  18. with the database over the life of a request. Unless updating the database in real time
  19. is required the ``history`` mode is recommended.
  20. Database
  21. ^^^^^^^^
  22. The file ``db.properties`` in the ``<GEOSERVER_DATA_DIR>/monitoring`` directory specifies
  23. the Hibernate database. By default an embedded H2 database located in the ``monitoring``
  24. directory is used. This can be changed by editing the ``db.properties`` file::
  25. # default configuration is for h2
  26. driver=org.h2.Driver
  27. url=jdbc:h2:file:${GEOSERVER_DATA_DIR}/monitoring/monitoring
  28. For example to store request data in an external PostgreSQL database, set ``db.properties`` to::
  29. driver=org.postgresql.Driver
  30. url=jdbc:postgresql://192.168.1.124:5432/monitoring
  31. username=bob
  32. password=foobar
  33. defaultAutoCommit=false
  34. In addition to ``db.properties`` file is the ``hibernate.properties`` file that contains
  35. configuration for Hibernate itself. An important parameter of this file is the hibernate
  36. dialect that informs hibernate of the type of database it is talking to.
  37. When changing the type of database both the ``databasePlatform`` and ``database`` parameters
  38. must be updated. For example to switch to PostgreSQL::
  39. # hibernate dialect
  40. databasePlatform=org.hibernate.dialect.PostgreSQLDialect
  41. database=POSTGRESQL
  42. # other hibernate configuration
  43. hibernate.use_sql_comments=true
  44. generateDdl=true
  45. hibernate.format_sql=true
  46. showSql=false
  47. hibernate.generate_statistics=true
  48. hibernate.session_factory_name=SessionFactory
  49. hibernate.hbm2ddl.auto=update
  50. hibernate.bytecode.use_reflection_optimizer=true
  51. hibernate.show_sql=false
  52. Hibernate
  53. ^^^^^^^^^
  54. As mentioned in the previous section the ``hibernate.properties`` file contains the configuration
  55. for Hibernate itself. Aside from the database dialect parameters it is not recommended that you
  56. change this file unless you are an experienced Hibernate user.