3

I have to create multiple bootstrap hosts in the clusters using marklogic API during deployment using ml-gradle.

I know I can configure it by admin console (8001 port) but I am not able to figure out how can I add multiple bootstrap hosts in the MarkLogic cluster using MarkLogic API?

Edit Local Cluster Configuration

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
Manish Narang
  • 87
  • 1
  • 1
  • 10

3 Answers3

3

I will assume you are referring to the Management API. If that's the case, then you can POST against the hosts endpoint to define bootstrap hosts

https://docs.marklogic.com/REST/POST/manage/v2/hosts

cat myHost.json
==> 

{
  "host-name": "hostname1",
  "group": "",
  "bind-port": 8090,
  "foreign-bind-port": 9091,
  "zone": "",
  "bootstrap-host": true
}

curl -X POST --digest -u admin:admin -H "Content-type: application/json" \
-d @myHost.json http://localhost:8002/manage/v2/hosts 

==>  Defines the host, named "hostname1," as the bootstrap host in 
     the cluster. 
Mike Gardner
  • 6,611
  • 5
  • 24
  • 34
  • 1
    Getting error status: 405 Method not allowed "REST-UNSUPPORTEDMETHOD: (err:FOER0000) Endpoint does not support method: POST" – Manish Narang May 15 '20 at 07:57
3

Following case worked in Postman:

HTTP Verb:
PUT

Authorization:
Digest Auth admin:admin

Header: 
Content-Type application/json

URI:
{ml-host}:8002/manage/v2/hosts/{new-bootstrap-host}/properties

Body:
{
    "bootstrap-host": true
}  
Manish Narang
  • 87
  • 1
  • 1
  • 10
1

Bootstrap host -> dh5a

Target joining host -> dh5b

  1. Save dh5b config as dh5b-config.xml
curl -o dh5b-config.xml --user {authen-user:passwd} \
-X GET -H "Content-type:application/xml" \
http://dh5b:8001/admin/v1/server-config
  1. Send dh5b config to dh5a as cluster-config.zip
curl --digest --user {authen-user:passwd} -X POST -o cluster-config.zip -d "group=Default" \
--data-urlencode "server-config@./dh5b-config.xml" \
-H "Content-type: application/x-www-form-urlencoded" \
http://dh5a:8001/admin/v1/cluster-config
  1. Send cluster-config.zip to dh5b and complete the joining process
curl --anyauth --user {authen-user:passwd} -X POST -H "Content-type: application/zip" \
--data-binary @./cluster-config.zip \
http://dh5b:8001/admin/v1/cluster-config

For production deployment:

1) Use Gradle to deploy additional hosts if Gradle is permitted

2) Write/Execute Shell script to include above API operations

(This approach has a lot more fun: combination of old Shell and modern API)

You can then use automation tool to invoke Shell or Gradle.

Fiona Chen
  • 1,358
  • 5
  • 16