Tim Meagher
Tim Meagher

Reputation: 163

I need to add a replica forest to another host in a MarkLogic cluster

The MarkLogic documentation provides an example for creating a forest and a forest replica using the /manage/v2/forests Rest API as follows:


$ curl --anyauth --user admin:admin -X POST \
-d '{"forest-name": "Documents", "host": "host-1.marklogic.com", "database": "Master", \
"forest-replicas": {"forest-replica":[{"replica-name": "Documents-R", "host": "host-3.marklogic.com"}]}}' \
-i -H "Content-type: application/json" http://localhost:8002/manage/v2/forests

This creates a "Documents" forest on "host-1" with a "Documents-R" replica forest on "host-3." Note that both hosts must be in the same cluster.

However, I would like to add a replica forest for an existing forest, but need help with the syntax, perhaps using /manage/v2/forests/{id|name}/properties (PUT).

Aside from the above question I also have the following issue:

My admin console doesn't allow me to specify forest replicas - it's just blank and I don't know how to enable it when creating a forest replica in the admin console.

Upvotes: 1

Views: 103

Answers (1)

Mads Hansen
Mads Hansen

Reputation: 66783

Since you have already created that primary forest, you will need to create the replica forest, then attach it to the primary as an HA-replica (two steps).

  1. Create the HA replica in a similar manner as you did for your primary forest.

  2. Then you can set the "forest-replica" property with the ID of the HA-replica forest using https://docs.marklogic.com/REST/PUT/manage/v2/forests/[id-or-name]/properties

Note: The properties described here are for XML payloads. In general they are the same for JSON, with the exception that, in JSON, failover-hosts and forest-replicas are expressed in singular form. For example, in JSON, failover-hosts is instead failover-host and the format is: "failover-host":["hostname"].

Once the HA-replica forest has been created, it should also appear in the dropdown for available forests to assign as a replica on the forest status page in the Admin UI, so that would also be an option.

Upvotes: 0

Related Questions