Skip to main content

Administrating MarkLogic Server

Rolling Upgrades Using XQuery

The XQuery Admin APIs can be used to set up and perform a rolling upgrade through the Query Console. This section contains sample code that you can use from the Query Console.

To get the host versions via REST, use this code:

xquery version "1.0-ml";
 
  <hosts>{
  for $i in xdmp:host-name(xdmp:hosts())
    return (
       let $response := xdmp:http-get(concat("http://localhost:8002/manage/v2/hosts/",$i,"?view=status&format=json"),
        <options xmlns="xdmp:http">
          <authentication method="digest">
            <username>admin</username>
            <password>admin</password>
          </authentication>
          <headers>
            <content-type>application/json</content-type>
          </headers>
        </options>)
        return (
          <host>
          <name>{$response[2]//*:name/data()}</name>
<host-software-version>{$response[2]//*:software-version/value/data()}</host-software-version>
<cluster-effective-version>{$response[2]//*:effective-version/value/data()}</cluster-effective-version>
          </host>
        )       
    )
    }</hosts>

To complete the upgrade, log onto the Admin Interface to upgrade the Security database.

Note

Committing the upgrade results in the updated configuration being saved with a re-read delay of 5 seconds to ensure that all online hosts have received the new file before XDQP connections start dropping.

See Step 9 in Upgrading an EC2 Instance. If the servers don’t have the correct version, there may be a host that is in maintenance mode. The admin:can-commit-upgrade function will return true if all servers have the correct software version. See Admin APIs for more about the XQuery Admin APIs available.