index.rst 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. JMS based Clustering
  2. ====================
  3. Introduction
  4. ------------
  5. The are several approaches to implement a clustered deployment with GeoServer, based on different mixes of data directory sharing plus configuration reload.
  6. The JMS based clustering module architecture is depicted in the following diagram:
  7. .. figure:: images/Schema.png
  8. :align: center
  9. :alt: Illustration Clustering Solution for GeoServer
  10. This module implements a robust Primary/Replica approach which leverages on a Message Oriented Middleware (MOM) where:
  11. * The Primaries accept changes to the internal configuration, persist them on their own data directory but also forward them to the Replicas via the MOM
  12. * The Replicas should not be used to change their configuration from either REST or the User Interface, since are configured to inject configuration changes disseminated by the Primary(s) via the MOM
  13. * The MOM is used to make the Primary and the Replicas exchange messages in a durable fashion
  14. * Each Replicas has its own data directory and it is responsible for keeping it aligned with the Primary's one. In case a Replicas goes down when it goes up again he might receive a bunch of JMS messages to align its configuration to the Primary's one.
  15. * A Node can be both Primary and Replica at the same time, this means that we don't have a single point of failure, i.e. the Primary itself
  16. Summarizing, the Primary as well as each Replicas use a private data directory, Replicas receive changes from the Primary, which is the only one where configuration changes are allowed, via JMS messages. Such messages transport GeoServer configuration objects that the Replicas inject directly in their own in-memory configuration and then persist on disk on their data directory, completely removing the need for a configuration reload for each configuration change.
  17. To make things simpler, in the default configuration the MOM is actually embedded and running inside each
  18. GeoServer, using multicast to find its peers and thus allowing for a clustering installation without
  19. the need to have a separate MOM deploy.
  20. Description
  21. -----------
  22. The GeoServer Primary/Replica integration is implemented using JMS, Spring and a MOM (Message Oriented Middleware), in particular ActiveMQ.
  23. The schema in Illustration represents a complete high level design of Primary/Replica platform.
  24. It is composed by 3 distinct actors:
  25. 1. GeoServer Primary
  26. 2. GeoServer Replicas
  27. 3. The MOM (ActiveMQ)
  28. .. figure:: images/Arch.png
  29. :align: center
  30. :alt: Illustration Component Diagram for the MOM based clustering
  31. This structure allows to have:
  32. 1. Queue fail-over components (using MOM).
  33. 2. Replica down are automatically handled using durable topic (which will store message to re-synch changes happens if one of the replicas is down when the message was made available)
  34. 3. Primary down will not affect any replicas synchronization process.
  35. This full blown deployment is composed by:
  36. * A pure Primary GeoServer(s), this instance can only send events to the topic. It cannot act as a replica
  37. * A set of GeoServer which can work as both Primary and Replica. These instances can send and receive messages to/from the topic. They can work as Primaries (sending message to other subscribers) as well as Replicas (these instances are also subscribers of the topic).
  38. * A set of pure Replicas GeoServer instances whic can only receive messages from the topic.
  39. * A set of MOM brokers so that each GeoServer instance is configured with a set of available brokers (failover). Each broker use the shared database as persistence. Doing so if a broker fails for some reason, messages can still be written and read from the shared database.
  40. All the produced code is based on spring-jms to ensure portability amongst different MOM, but if you look at the schema, we are also leveraging ActiveMQ VirtualTopics to get dynamic routing (you can dynamically attach primary and replica).
  41. The VirtualTopics feature has also other advantages explained here: http://activemq.apache.org/virtual-destinations.html
  42. As said above, in the default configuration the MOM runs inside GeoServer itself, simplifying the topology and
  43. the setup effort.
  44. Installation
  45. ^^^^^^^^^^^^
  46. To install the jms cluster modules into an existing GeoServer refer to the :ref:`jms.installation` page
  47. How to configure GeoServer Instances
  48. ------------------------------------
  49. The configuration for the GeoServer is very simple and can be performed using the provided GUI or modifying the ``cluster.properties`` file which is stored into the ``GEOSERVER_DATA_DIR`` under the ``cluster`` folder (e.g. ``${GEOSERVER_DATA_DIR}/cluster``).
  50. To override the default destination of this configuration file you have to setup the **CLUSTER_CONFIG_DIR** variable defining the destination folder of the **cluster.properties** file.
  51. This is *mandatory* when you want to share the same GEOSERVER_DATA_DIR, but not required if you are giving each GeoServer its own data directory.
  52. In case of shared data directory, it will be necessary to add a different system variable to each JVM running a GeoServer, e.g.:
  53. * ``-DCLUSTER_CONFIG_DIR=/var/geoserver/clusterConfig/1`` to the JVM running the first node
  54. * ``-DCLUSTER_CONFIG_DIR=/var/geoserver/clusterConfig/2`` to the JVM running the second node
  55. * and so on
  56. If the directories are missing, GeoServer will create them and provide a initial ``cluster.properties``
  57. with reasonable defaults.
  58. Instance name
  59. -------------
  60. The instance.name is used to distinguish from which GeoServer instance the message is coming from, so each GeoServer instance should use a different, unique (for a single cluster) name.
  61. Broker URL
  62. ----------
  63. The broker.url field is used to instruct the internal JMS machinery where to publish messages to (primary GeoServer installation) or where to consume messages from (replica GeoServer installation). Many options are available for configuring the connection between the GeoServer instance and the JMS broker, for a complete list, please, check http://activemq.apache.org/configuring-transports.html. In case when (recommended) failover set up is put in place multiple broker URLs can be used. See http://activemq.apache.org/failover-transport-reference.html for more information about how to configure that.
  64. Note
  65. GeoServer will not complete the start-up phase until the target broker is correctly activated and reachable.
  66. Limitations and future extensions
  67. ---------------------------------
  68. Data
  69. ^^^^
  70. NO DATA IS SENT THROUGH THE JMS CHANNEL
  71. The clustering solution we have put in place is specific for managing the GeoServer internal configuration, no data is transferred between primary and replicas. For that purpose use external mechanisms (ref. [GeoServer REST]).
  72. In principle this is not a limitation per se since usually in a clustered environment data is stored in shared locations outside the data directory. With our solution this is a requirement since each replicas will have its own private data directory.
  73. Things to avoid
  74. ^^^^^^^^^^^^^^^
  75. * **NEVER RELOAD THE GEOSERVER CATALOG ON A PRIMARY**: Each primary instance should never call the catalog reload since this propagates the creation of all the resources, styles, etc to all the connected replicas.
  76. * **NEVER CHANGE CONFIGURATION USING A PURE REPLICA**: This will make the configuration of the specific replica out of synch with the others.
  77. Refs:
  78. -----
  79. .. toctree::
  80. installation
  81. activemq/activemqBroker
  82. activemq/JDBC
  83. activemq/SharedFolder
  84. Bibliography:
  85. -------------
  86. [JMS specs]
  87. Sun microsystens - Java Message Service - Version 1.1 April 12, 2002
  88. [JMS]
  89. Snyder Bosanac Davies - ActiveMQ in action - Manning
  90. [GeoServer]
  91. http://docs.geoserver.org/
  92. [GeoServer REST]
  93. http://docs.geoserver.org/latest/en/user/rest/index.html#rest
  94. [ActiveMQ]
  95. http://activemq.apache.org/