Loading TOC...

tieredstorage:forest-migrate

tieredstorage:forest-migrate(
   $forest-ids as xs:unsignedLong*,
   [$new-host-id as xs:unsignedLong?],
   [$new-data-directory as xs:string?],
   [$new-large-data-directory as xs:string?],
   [$new-fast-data-directory as xs:string?],
   [$options as xs:string*]
) as empty-sequence()

Summary

This function moves data in a forest to new data directories and optionally sets new host for the forest. If no data directory is specified, the default data directory will be used. For details, see Migrating Forests and Partitions in the Administrator's Guide.

Parameters
$forest-ids IDs of the forests to migrate.
$new-host-id ID of the destination host.
$new-data-directory The optional data directory of the forest. If no directory is specified, then it will be a private forest.
$new-large-data-directory The optional directory where large objects are stored. If no directory is specified, then large objects will be stored in DATA_DIR/Forests/FOREST_NAME/Large.
$new-fast-data-directory The optional directory for the fast data directory for this forest. The fast data directory is typically located on a fast storage device, such as an SSD.
$options Valid option values include:
timeout=N
Specifies the number of seconds to wait for a forest to re-open after a configuration is made during the migration operation.
local-to-local
Indicates that the migration is between local storage to local storage. This is the default when no other direction parameter is specified and the type of storage cannot be derived from either the data directory path.
local-to-shared
Indicates that the migration is between local storage and shared storage. This type of migration supports changing the host.
shared-to-local
Indicates that the migration is to move data from shared storage to local storage. This type of migration supports changing the host.
shared-to-shared
Indicates that the migration is to move data from shared storage to shared storage. This type of migration supports changing the host.

Example

xquery version "1.0-ml";
import module namespace ts="http://marklogic.com/xdmp/tieredstorage" 
          at "/MarkLogic/tieredstorage.xqy";

ts:forest-migrate(
    xdmp:forest("Forest1"), 
    xdmp:host("host1"), 
    "/tmp/test", 
    (), 
    (), 
    ("timeout=20"))
 
    (: Moves the Forest1 from its current location to /tmp/test and sets their 
       timeouts to 20 seconds. )
  

Comments

  • When calling ts:forest-migrate with large forests, the timeout needs to be large enough to copy the data to the new location. This can take hours, so it's best not to run this directly with cq or qconsole. The usual way to start it is with REST: <a href="http://docs.marklogic.com/REST/PUT/manage/v2/forests">http://docs.marklogic.com/REST/PUT/manage/v2/forests</a>. However you can also call xdmp:spawn-function from cq or qconsole, to start a migration task on the task server. Make sure the spawned function runs in update mode, and that the task server time limit is long enough. Monitor ErrorLog.txt for messages. <pre><code>xquery version "1.0-ml"; import module namespace ts="http://marklogic.com/xdmp/tieredstorage" at "/MarkLogic/tieredstorage.xqy"; xdmp:spawn-function( function() { ts:forest-migrate( xdmp:forest("my-forest"), xdmp:host(), '/media/xvdg/mldata', (), (), ("timeout=7200")) }, <options xmlns="xdmp:eval"> <transaction-mode>update</transaction-mode> </options>) </pre></code>
Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy