MySQL NDB Cluster API Developer Guide  /  ...  /  Functions for Starting & Stopping Nodes

3.2.6 Functions for Starting & Stopping Nodes

The MGM API provides several functions which can be used to start, stop, and restart one or more Cluster data nodes. These functions are described in this section.

Starting, Stopping, and Restarting Nodes.  You can start, stop, and restart Cluster nodes using the following functions, which are described in more detail in the next few sections.

ndb_mgm_start()

Description

This function can be used to start one or more Cluster nodes. The nodes to be started must have been started with the no-start option (-n), meaning that the data node binary was started and is waiting for a START management command which actually enables the node.

Signature
int ndb_mgm_start
    (
      NdbMgmHandle handle,
      int          number,
      const int*   list
    )
Parameters

ndb_mgm_start() takes 3 parameters:

  • An NdbMgmHandle.

  • A number of nodes to be started. Use 0 to start all of the data nodes in the cluster.

  • A list of the node IDs of the nodes to be started.

Return value

The number of nodes actually started; in the event of failure, -1 is returned.

ndb_mgm_stop()

Description

This function stops one or more data nodes.

Signature
int ndb_mgm_stop
    (
      NdbMgmHandle handle,
      int          number,
      const int*   list
    )
Parameters

ndb_mgm_stop() takes 3 parameters: Calling this function is equivalent to calling ndb_mgm_stop2(handle, number, list, 0).

  • An NdbMgmHandle.

  • The number of nodes to be stopped. Use 0 to stop all of the data nodes in the cluster.

  • A list of the node IDs of the nodes to be stopped.

Return value

The number of nodes actually stopped; in the event of failure, -1 is returned.

ndb_mgm_stop2()

Description

Like ndb_mgm_stop(), this function stops one or more data nodes. However, it offers the ability to specify whether or not the nodes shut down gracefully.

Signature
int ndb_mgm_stop2
    (
      NdbMgmHandle handle,
      int          number,
      const int*   list,
      int          abort
    )
Parameters

ndb_mgm_stop2() takes 4 parameters:

  • An NdbMgmHandle.

  • The number of nodes to be stopped. Use 0 to stop all of the data nodes in the cluster.

  • A list of the node IDs of the nodes to be stopped.

  • The value of abort determines how the nodes will be shut down. 1 indicates the nodes will shut down immediately; 0 indicates that the nodes will stop gracefully.

Return value

The number of nodes actually stopped; in the event of failure, -1 is returned.

ndb_mgm_stop3()

Description

Like ndb_mgm_stop() and ndb_mgm_stop2(), this function stops one or more data nodes. Like ndb_mgm_stop2(), it offers the ability to specify whether the nodes should shut down gracefully. In addition, it provides for a way to check to see whether disconnection is required prior to stopping a node.

Signature
int ndb_mgm_stop3
    (
      NdbMgmHandle handle,
      int          number,
      const int*   list,
      int          abort,
      int*         disconnect
    )
Parameters

ndb_mgm_stop3() takes 5 parameters:

  • An NdbMgmHandle.

  • The number of nodes to be stopped. Use 0 to stop all of the data nodes in the cluster.

  • A list of the node IDs of the nodes to be stopped.

  • The value of abort determines how the nodes will be shut down. 1 indicates the nodes will shut down immediately; 0 indicates that the nodes will stop gracefully.

  • If disconnect returns 1 (true), this means the you must disconnect before you can apply the command to stop. For example, disconnecting is required when stopping the management server to which the handle is connected.

Return value

The number of nodes actually stopped; in the event of failure, -1 is returned.

ndb_mgm_stop4()

Description

Like the other ndb_mgm_stop*() functions, this function stops one or more data nodes. Like ndb_mgm_stop2(), it offers the ability to specify whether the nodes should shut down gracefully; like ndb_mgm_stop3() it provides for a way to check to see whether disconnection is required prior to stopping a node. In addition, it is possible to force the node to shut down even if this would cause the cluster to become nonviable.

Signature
int ndb_mgm_stop4
    (
      NdbMgmHandle handle,
      int          number,
      const int*   list,
      int          abort,
      int          force,
      int*         disconnect
    )
Parameters

ndb_mgm_stop4() takes 6 parameters:

  • An NdbMgmHandle.

  • The number of nodes to be stopped. Use 0 to stop all of the data nodes in the cluster.

  • A list of the node IDs of the nodes to be stopped.

  • The value of abort determines how the nodes will be shut down. 1 indicates the nodes will shut down immediately; 0 indicates that the nodes will stop gracefully.

  • The value of force determines the action to be taken in the event that the shutdown of a given node would cause an incomplete cluster. 1 causes the node—and the entire cluster—to be shut down in such cases, 0 means the node will not be shut down.

    Setting force equal to 1 also makes it possible to stop a node even while other nodes are starting. (Bug #58451)

  • If disconnect returns 1 (true), this means the you must disconnect before you can apply the command to stop. For example, disconnecting is required when stopping the management server to which the handle is connected.

Return value

The number of nodes actually stopped; in the event of failure, -1 is returned.

ndb_mgm_restart()

Description

This function can be used to restart one or more Cluster data nodes.

Signature
int ndb_mgm_restart
    (
      NdbMgmHandle handle,
      int          number,
      const int*   list
    )
Parameters

ndb_mgm_restart() takes 3 parameters:

  • An NdbMgmHandle.

  • The number of nodes to be stopped. Use 0 to stop all of the data nodes in the cluster.

  • A list of the node IDs of the nodes to be stopped.

Calling this function is equivalent to calling

ndb_mgm_restart2(handle, number, list, 0, 0, 0);

See ndb_mgm_restart2(), for more information.

Return value

The number of nodes actually restarted; -1 on failure.

ndb_mgm_restart2()

Description

Like ndb_mgm_restart(), this function can be used to restart one or more Cluster data nodes. However, ndb_mgm_restart2() provides additional restart options, including initial restart, waiting start, and immediate (forced) restart.

Signature
int ndb_mgm_restart2
    (
      NdbMgmHandle handle,
      int          number,
      const int*   list,
      int          initial
      int          nostart,
      int          abort
    )
Parameters

ndb_mgm_restart2() takes 6 parameters:

  • An NdbMgmHandle.

  • The number of nodes to be stopped. Use 0 to stop all of the data nodes in the cluster.

  • A list of the node IDs of the nodes to be stopped.

  • If initial is true (1), then each node undergoes an initial restart—that is, its file system is removed.

  • If nostart is true, then the nodes are not actually started, but instead are left ready for a start command.

  • If abort is true, then the nodes are restarted immediately, bypassing any graceful restart.

Return value

The number of nodes actually restarted; -1 on failure.

ndb_mgm_restart3()

Description

Like ndb_mgm_restart2(), this function can be used to cause an initial restart, waiting restart, and immediate (forced) restart on one or more Cluster data nodes. However, ndb_mgm_restart3() provides the additional options of checking whether disconnection is required prior to the restart.

Signature
int ndb_mgm_restart3
    (
      NdbMgmHandle handle,
      int          number,
      const int*   list,
      int          initial
      int          nostart,
      int          abort,
      int*         disconnect
    )
Parameters

ndb_mgm_restart3() takes 7 parameters:

  • An NdbMgmHandle.

  • The number of nodes to be stopped. Use 0 to stop all of the data nodes in the cluster.

  • A list of the node IDs of the nodes to be stopped.

  • If initial is true (1), then each node undergoes an initial restart—that is, its file system is removed.

  • If nostart is true, then the nodes are not actually started, but instead are left ready for a start command.

  • If abort is true, then the nodes are forced to restart immediately without performing a graceful restart.

  • If disconnect returns 1 (true), this means the you must disconnect before you can apply the command to restart. For example, disconnecting is required when stopping the management server to which the handle is connected.

Return value

The number of nodes actually restarted; -1 on failure.

ndb_mgm_restart4()

Description

Like the other ndb_mgm_restart*() functions, this function restarts one or more data nodes. Like ndb_mgm_restart2(), it can be used to cause an initial restart, waiting restart, and immediate (forced) restart on one or more NDB Cluster data nodes; like ndb_mgm_stop3() it provides for a way to check to see whether disconnection is required prior to stopping a node. In addition, it is possible to force the node to restart even if this would cause a restart of the cluster.

Signature
int ndb_mgm_restart4
    (
      NdbMgmHandle handle,
      int          number,
      const int*   list,
      int          initial
      int          nostart,
      int          abort,
      int          force,
      int*         disconnect
    )
Parameters

ndb_mgm_restart4() takes 7 parameters:

  • An NdbMgmHandle.

  • The number of nodes to be stopped. Use 0 to stop all of the data nodes in the cluster.

  • A list of the node IDs of the nodes to be stopped.

  • If initial is true (1), then each node undergoes an initial restart—that is, its file system is removed.

  • If nostart is true, then the nodes are not actually started, but instead are left ready for a start command.

  • If abort is true, then the nodes are forced to restart immediately without performing a graceful restart.

  • The value of force determines the action to be taken in the event that the loss of a given node due to restarting would cause an incomplete cluster.

    1 causes the node—and the entire cluster—to be restarted in such cases, 0 means that the node will not be restarted.

    Setting force equal to 1 also makes it possible to restart a node even while other nodes are starting. (Bug #58451)

  • If disconnect returns 1 (true), this means the you must disconnect before you can apply the command to restart. For example, disconnecting is required when stopping the management server to which the handle is connected.

Return value

The number of nodes actually restarted; -1 on failure.