Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Deploy PostgreSQL: (This step is optional if you already have a running Postgres database with all required tables and data).

    1. Add the Bitnami Helm repository:

      Code Block
      helm repo add bitnami https://charts.bitnami.com/bitnami

      Create a postgres_values.yaml file to configure Postgres deployment:

      Code Block
      global:
        postgresql:
          auth:
            password: password
            postgresPassword: password
            username: hivemq
      
      primary:
        initdb:
          scriptsConfigMap: postgresql-db-init

      Create a ConfigMap called postgresql-db-init containing the create-table.sql script this file is located inside hivemq-postgresql-extension/conf/examples/, which creates required tables.

      Code Block
      kubectl create configmap postgresql-db-init --from-file create-table.sql

      Deploy Postgres using Helm:

      Code Block
      languagebash
      helm upgrade postgres --install bitnami/postgresql --values postgres_values.yaml

      Verify the status of the pod:

      Code Block
      kubectl get pods

      If an error occurs, check the pod logs:

      Code Block
      kubectl logs <pod name>

      Connect to the Postgres pod to verify the connection:

      Code Block
      psql --host 127.0.0.1 -U postgres -d postgres -p 5432

      Use the following commands in the Postgres shell to interact with the database:

      • \l: List the databases.

      • \c <db name>: Connect to a specific database.

      • \dt: List the tables from the connected database.

      • select * from users;

  2. Deploy HiveMQ with PostgreSQL extension

    1. Generate hivemq_values.yaml:

      Deploy HiveMQ using the HiveMQ Platform and generate the hivemq_values.yaml file:

      Code Block
      helm show values hivemq/hivemq-platform > hivemq_values.yaml
    2. Configure PostgreSQL extension License:

      Follow the specific steps outlined for configuring the HiveMQ and PostgreSQL extension license. Setting Up HiveMQ License for Your HiveMQ Cluster using HiveMQ Platform Operator

    3. Create config.xml for PostgreSQL extension:

      1. Examples of the config.xml file are in the extension folder under conf/examples.

      2. Configure the postgresql with your database name, host, username, and password.

      3. Configure the <mqtt-to-postgresql-route>, setting <use-authorization-key> to false and <use-authorization-role-key> to true.

      4. Please refer to the example:

        Code Block
        <hivemq-postgresql-extension xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                     xsi:noNamespaceSchemaLocation="config.xsd">
            <postgresqls>
                <postgresql>
                    <id>my-postgresql-id</id>
                    <host>postgres-postgresql</host>
                    <port>5432</port>
                    <database>postgres</database>
                    <username>hivemq</username>
                    <password>password</password>
                </postgresql>
            </postgresqls>
        
            <mqtt-to-postgresql-routes>
        
                <!-- insert every message using the INSERT STATEMENT processor -->
                <mqtt-to-postgresql-route>
                    <id>my-mqtt-to-postgresql-route-insert</id>
                    <postgresql-id>my-postgresql-id</postgresql-id>
                    <mqtt-topic-filters>
                        <mqtt-topic-filter>test/#</mqtt-topic-filter>
                    </mqtt-topic-filters>
                    <processor>
                        <insert-statement>
                            <table>mqtt_to_postgresql_table</table>
                            <batching>true</batching>
                            <columns>
                                <column>
                                    <name>topic</name>
                                    <value>mqtt-topic</value>
                                </column>
                                <column>
                                    <name>payload_utf8</name>
                                    <value>mqtt-payload-utf8</value>
                                </column>
                            </columns>
                        </insert-statement>
                    </processor>
                </mqtt-to-postgresql-route>
        
                <!-- insert message using the STATEMENT TEMPLATE processor -->
                <mqtt-to-postgresql-route>
                    <id>my-mqtt-to-postgresql-route-template</id>
                    <postgresql-id>my-postgresql-id</postgresql-id>
                    <mqtt-topic-filters>
                        <mqtt-topic-filter>help/#</mqtt-topic-filter>
                    </mqtt-topic-filters>
                    <processor>
                        <!-- please use absolute path here->
                        <statement-template>/opt/hivemq-4.24.0/extensions/hivemq-postgresql-extension/conf/statement-template.sql</statement-template>
                    </processor>
                </mqtt-to-postgresql-route>
        
            </mqtt-to-postgresql-routes>
        </hivemq-postgresql-extension>
        
        
    4. Create ConfigMap for PostgreSQL configuration

      Code Block
      languagebash
      kubectl create configmap postgresql-config --from-file config.xml --from-file statement-template.sql -n <namespace>
    5. Deploy HiveMQ Platform Operator:

      Code Block
      languagebash
      helm install platform-op hivemq/hivemq-platform-operator -n <namespace>
    6. Edit hivemq_values.yaml: Modify the hivemq_values.yaml file to include PostgreSQL-related changes.

      1. Configure the ConfigMap name created in the previous step. Set enabled: true to enable this extension.

        Code Block
        ...
        extensions:
        # HiveMQ Enterprise Extension for PostgreSQL
        # This extension does not support hot-reload of the configuration.
          - name: hivemq-postgresql-extension
            enabled: true
        # The ConfigMap name that contains the PostgreSQL extension configuration.
            configMapName: "postgresql-config"
        ...
      2. Deploy HiveMQ:

        Code Block
        helm upgrade --install -f hivemq_values.yaml hivemq hivemq/hivemq-platform -n <namespace>
      3. Check Pod Status:

        Verify that all hivemq pods are running.

        Code Block
        kubectl get pods -n <namespace>
      4. Verify Enterprise PostgreSQL Extension Start:

        Check the hivemq.log to confirm successful extension startup.

        Code Block
        kubectl logs <pod name> -n <namespace> | grep -v "started succ"
      5. Perform Quick Tests:

        Utilize the MQTT CLI to conduct quick tests.

...

Filter by label (Content by label)
page
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@957
showSpacefalse
sortmodified
showSpacetypefalsepage
reversetruetype
labelskb-how-to-article
cqllabel in ( "kb-how-to-article" , "platform-operator" ) and type = "page" and space = "KB"labelskb-how-to-article