Loading TOC...

MarkLogic Server 11.0 Product Documentation
cma.applyConfig

cma.applyConfig(
   config as (binary()|node())[],
   [config-options as Object?],
   [params as Object?],
   [format as String?]
) as (emptySeq|node())

Summary

Apply a named configuration, overriding parameters and setting options.

Parameters
config A zip file or xml|json configuration to be applied.
config-options Configuration options control how the configuration is applied. This function supports the following configuration options:
name
The configuration profile name to be run, for example "myClusterTestConfig".
format
The configuration format; the value supplied in the $format parameter of the function overrides this value. The allowed values are xml | json. The default value is json.
resourceType
The resource type the configuration applies to. The allowed values are: "forest", "database", "server", "group", "user", "role".
resourceId
The list of specific resources' identifiers to apply the configuration to. The value is string array, for example ["resource-id1", "resource-id2", ...].
resourceName
The regular expression to select specific resources by their names, for example "ha-*".
params Scenario-specific values for parameters to override default values when the configuration is applied. See Usage Notes for details.
format The response format. The allowed values are empty sequence or xml | json. The default value is json.

Usage Notes

This function applies a named configuration, overriding parameters and setting options.

The default namespace for configuration packages is http://marklogic.com/manage/config.

XML root element:
<configuration xmlns="http://marklogic.com/manage/config">
      

The available core scenarios are summarized below. The details on each scenario follow.

HA Local Failover

Local disk failover provides High Availability (HA) by replicating forest data to other hosts. When any particular host goes down, forests' replicas will mount on the other hosts.

The parameters for HA Local Failover scenario are:

replicaSameZoneAsMaster
Create forests on hosts in the same zone. The allowed values are true or false. The default value is true.
masterDatabase
Create if does not exist, add replicas (if none exist). The value is string, for example "myHADatabase".
triggersDatabase
Create if does not exist, add replicas (if none exist). The value is string, for example "myHATriggers".
schemasDatabase
Create if does not exist, add replicas (if none exist). The value is string, for example "myHASchemas".
securityDatabase
When defined, will attempt to add replicas to xdmp:security-database() (if none exist). The value is string, for example "Security".
addReplicaToExistingForests
When set to false - no attempt is made to add replicas; when set to true - replicas will be added to the forest, with total summing up to number-of-replicas-per-forest. The allowed values are true or false. The default value is false.
numberOfMasterForests
Calculated number of master forests. The value is positive integer.
numberOfReplicasPerForest
Calculated number of replicas per forest. The value is positive integer.
numberOfForestsPerHost
Calculated based on number of available hosts, equally balance forests across hosts. The value is positive integer.
masterDataDirectory
Data directory used by master forests. The value is string, for example "/tmp" (e.g. returned by xdmp:data-directory()) function call).
masterFastDataDirectory
Fast directory used by master forests. The value is string, for example "/tmp".
masterLargeDataDirectory
Large directory used by master forests. The value is string, for example "/tmp".
masterReplicaDataDirectory
Data directory used by master forest replicas. The value is string, for example "/tmp".
masterReplicaFastDataDirectory
Fast directory used by master forest replicas. The value is string, for example "/tmp".
masterReplicaLargeDataDirectory
Large directory used by master forest replicas. The value is string, for example "/tmp".

Example

// Apply configuration ZIP.
'use strict';
const cma = require('/MarkLogic/cma.sjs');
cma.applyConfig($zip);
    

Example

// Create a REST server.
'use strict';

const cma = require('/MarkLogic/cma.sjs');

const json = {
    "config": [{
    "forest":[{"forest-name":"mydb1-f1"},{"forest-name":"mymodulesdb-f1"}],
        "database": [{
                "database-name": "myDb",
        "forest":["mydb1-f1"]
            },
            {
                "database-name": "myModulesDb",
        "forest":["mymodulesdb-f1"]
            }
        ],
        "server": [{
            "server-name": "restapiServer",
            "server-type": "http",
      "group-name":"Default",
            "root": "/",
            "port": "8900",
      "url-rewriter": "/MarkLogic/rest-api/8000-rewriter.xml",
            "content-database": "myDb",
            "modules-database": "myModulesDb"
        }]
    }]
};
 
cma.applyConfig(json);
    

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.