Clustered Trivial Database

Clustered Trivial Database (CTDB) is a cluster implementation of the TDB database used by Samba to store temporary data. It is used for services such as Samba and NFS to provide high availability and load sharing across multiple nodes in the CTDB Cluster.

A CTDB Cluster relies on a Distributed Filesystem that must be mounted as a client on each of the CTDB Cluster Nodes. A CTDB Cluster also manages a list of external (virtual) IP addresses that provide services to the clients.

Basic Operations

The basic operation of List is available for an existing CTDB Cluster’s Status, Configuration, Nodes, External (Virtual) Addresses, and Logs. Additionally, you are able to set Configuration, Nodes, and Virtual Addresses of a CTDB Cluster, and Link these settings from the Distributed Filesystem to the desired Node. Lastly, you are able to Enable and Disable the samba, nfs, and winbind event scripts for CTDB.

List CTDB Status

Call to /db/ctdb/status to get the status of an active CTDB Cluster

Request Object

+ URL
  /api/v2/db/ctdb/status

+ Method
  GET

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {}

Response Object

Sending this should get you back a valid response, an object with both the raw and parsed output of the status

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {
    "raw": "Number of nodes:2\npnn:0 192.168.6.79     OK (THIS NODE)\npnn:1 192.168.6.77     UNHEALTHY\nGeneration:1919983054\nSize:2\nhash:0 lmaster:0\nhash:1 lmaster:1\nRecovery mode:NORMAL (0)\nRecovery master:0\n",
    "parsed": {
        "numOfNodes": "2",
        "nodes": [
            {
                "pnn": "0",
                "address": "192.168.6.79",
                "status": "OK"
            },
            {
                "pnn": "1",
                "address": "192.168.6.77",
                "status": "UNHEALTHY"
            }
        ],
        "generation": "1919983054",
        "size": "2",
        "recoveryMode": [
            "NORMAL",
            "0"
        ],
        "recoveryMaster": "0",
        "unparsable": [],
        "hash": "1"
    }
  }

Get CTDB conf

Call to /db/ctdb/conf to list the contents of /etc/ctdb/ctdb.conf

Request Object

+ URL
  /api/v2/db/ctdb/conf

+ Method
  GET

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {}

Response Object

Sending this should get you back a valid response, an object with the raw contents of the ctdb.conf

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {
    "raw": "# See ctdb.conf(5) for documentation\n#\n# See ctdb-script.options(5) for documentation about event script\n# options\n[logging]\n    # Enable logging to syslog\n    # location = syslog\n    # Default log level\n    # log level = NOTICE\n[cluster]\n    # Shared recovery lock file to avoid split brain.  Daemon\n    # default is no recovery lock.  Do NOT run CTDB without a\n    # recovery lock file unless you know exactly what you are\n    # doing.\n    #\n    # Please see the RECOVERY LOCK section in ctdb(7) for more\n    # details.\n    #\n    recovery lock = /lfsmnt/mother/.ctdb/recovery_lock\n"
  }

Set CTDB Conf

Call to /db/ctdb/conf to set the contents of /etc/ctdb/ctdb.conf with the raw contents in the Body

Request Object

+ URL
  /api/v2/db/ctdb/conf

+ Method
  POST

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {
    "raw":"# See ctdb.conf(5) for documentation\n#\n# See ctdb-script.options(5) for documentation about event script\n# options\n[logging]\n    # Enable logging to syslog\n    # location = syslog\n    # Default log level\n    # log level = NOTICE\n[cluster]\n    # Shared recovery lock file to avoid split brain.  Daemon\n    # default is no recovery lock.  Do NOT run CTDB without a\n    # recovery lock file unless you know exactly what you are\n    # doing.\n    #\n    # Please see the RECOVERY LOCK section in ctdb(7) for more\n    # details.\n    #\n    recovery lock = /lfsmnt/robin/.ctdb/recovery_lock\n"
  }

Response Object

Sending this should get you back a valid response, an empty object

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {}

Get CTDB nodes

Call to /db/ctdb/nodes to list the nodes of the CTDB Cluster

Request Object

+ URL
  /api/v2/db/ctdb/nodes

+ Method
  GET

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {}

Response Object

Sending this should get you back a valid response, an object with an array of the internal IP addresses of the Nodes in the CTDB Cluster

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {
    "nodes": [
        "192.168.6.79",
        "192.168.6.77"
    ]
  }

Set CTDB Nodes

Call to /db/ctdb/nodes with the list of internal Node addresses in the Body to set the list of Nodes in the CTDB Cluster

Request Object

+ URL
  /api/v2/db/ctdb/nodes

+ Method
  POST

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {
    "addresses": [
      "192.168.6.77",
      "192.168.6.79",
    ]
  }

Response Object

Sending this should get you back a valid response, an empty object

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {}

Get CTDB addresses

Call to /db/ctdb/addresses to list the external addresses of the CTDB Cluster

Request Object

+ URL
  /api/v2/db/ctdb/addresses

+ Method
  GET

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {}

Response Object

Sending this should get you back a valid response, an object with an array of the external addresses and virtual interfaces used for the CTDB Cluster

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {
    "addresses": [
        {
            "raw": "192.168.6.84/24 mother_ctdb0",
            "address": "192.168.6.84/24",
            "interface_name": "mother_ctdb0"
        },
        {
            "raw": "192.168.6.85/24 mother_ctdb0",
            "address": "192.168.6.85/24",
            "interface_name": "mother_ctdb0"
        }
    ]
  }

Set CTDB Addresses

Call to /db/ctdb/addresses with the list of addresses and associated virtual interfaces in the Body to set them in the CTDB Cluster. To create a virtual interface, please see the documentation for Network Interfaces.

Request Object

+ URL
  /api/v2/db/ctdb/addresses

+ Method
  POST

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {
    "addresses":[
        {
          "address":"192.168.6.85/24",
          "interface_name":"robin_ctdb0"
        }
        {
          "address":"192.168.6.86/24",
          "interface_name":"robin_ctdb0"
        }
    ]
  }

Response Object

Sending this should get you back a valid response, an empty object

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {}

Call to /db/ctdb/link to set the symbolic link of the nodes and external addresses file from the Distributed Filesystem name in the Body to the Node

Request Object

+ URL
  /api/v2/db/ctdb/link

+ Method
  POST

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {
    "dfsPath": "/lfsmnt/robin"
  }

Response Object

Sending this should get you back a valid response, an empty object

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {}

Get Logs of a CTDB Cluster

Call /db/ctdb/log to get the output of /var/log/ctdb/log.ctdb

Request Object

+ URL
  /api/v2/db/ctdb/log

+ Method
  GET

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {}

Response Object

Sending this should get you back a valid response, the output of the CTDB log

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {
    "raw": "2020/09/27 00:12:00.817799 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x0  was 0x2\n2020/09/27 00:12:01.277050 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 00:12:01.283075 ctdbd[4709]: Release of IP 192.168.6.85/24 on interface mother_ctdb0  node:1\n2020/09/27 00:12:01.616389 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 00:12:05.992377 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x2  was 0x0\n2020/09/27 00:12:06.291482 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 00:12:06.393355 ctdbd[4709]: Takeover of IP 192.168.6.85/24 on interface mother_ctdb0\n2020/09/27 00:12:06.558525 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 02:24:47.271662 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x0  was 0x2\n2020/09/27 02:24:47.836656 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 02:24:47.857819 ctdbd[4709]: Release of IP 192.168.6.85/24 on interface mother_ctdb0  node:1\n2020/09/27 02:24:48.234338 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 02:24:52.450731 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x2  was 0x0\n2020/09/27 02:24:52.830969 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 02:24:52.930633 ctdbd[4709]: Takeover of IP 192.168.6.85/24 on interface mother_ctdb0\n2020/09/27 02:24:53.117302 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 06:24:58.938942 ctdb-eventd[4711]: 05.system: WARNING: Filesystem / utilization 91% >= threshold 90%\n2020/09/27 09:40:02.372315 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x0  was 0x2\n2020/09/27 09:40:02.812140 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 09:40:02.818063 ctdbd[4709]: Release of IP 192.168.6.85/24 on interface mother_ctdb0  node:1\n2020/09/27 09:40:03.221096 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 09:40:07.516727 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x2  was 0x0\n2020/09/27 09:40:07.845642 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 09:40:07.958563 ctdbd[4709]: Takeover of IP 192.168.6.85/24 on interface mother_ctdb0\n2020/09/27 09:40:08.226615 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 14:57:59.660677 ctdb-eventd[4711]: 05.system: WARNING: Filesystem / utilization 92% >= threshold 90%\n2020/09/27 19:13:01.602692 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x0  was 0x2\n2020/09/27 19:13:02.196637 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 19:13:02.208715 ctdbd[4709]: Release of IP 192.168.6.85/24 on interface mother_ctdb0  node:1\n2020/09/27 19:13:02.490324 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 19:13:06.760367 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x2  was 0x0\n2020/09/27 19:13:07.200876 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 19:13:07.290694 ctdbd[4709]: Takeover of IP 192.168.6.85/24 on interface mother_ctdb0\n2020/09/27 19:13:07.434157 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 19:15:08.867714 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x0  was 0x2\n2020/09/27 19:15:09.469658 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 19:15:09.479209 ctdbd[4709]: Release of IP 192.168.6.85/24 on interface mother_ctdb0  node:1\n2020/09/27 19:15:09.744102 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 19:15:14.039075 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x2  was 0x0\n2020/09/27 19:15:14.480279 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 19:15:14.589152 ctdbd[4709]: Takeover of IP 192.168.6.85/24 on interface mother_ctdb0\n2020/09/27 19:15:14.729761 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 19:44:06.051355 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x0  was 0x2\n2020/09/27 19:44:06.762826 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 19:44:06.787294 ctdbd[4709]: Release of IP 192.168.6.85/24 on interface mother_ctdb0  node:1\n2020/09/27 19:44:07.216557 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 19:44:11.215314 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x2  was 0x0\n2020/09/27 19:44:11.811113 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 19:44:11.958451 ctdbd[4709]: Takeover of IP 192.168.6.85/24 on interface mother_ctdb0\n2020/09/27 19:44:12.226461 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 20:34:10.174607 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 80% >= threshold 80%\n2020/09/27 20:34:40.924072 ctdb-eventd[4711]: 05.system: NOTICE: System memory utilization 79% < threshold 80%\n2020/09/27 21:46:03.230270 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 80% >= threshold 80%\n2020/09/27 21:46:09.689912 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x0  was 0x2\n2020/09/27 21:46:10.109580 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 21:46:10.122785 ctdbd[4709]: Release of IP 192.168.6.85/24 on interface mother_ctdb0  node:1\n2020/09/27 21:46:10.318598 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 21:46:14.842389 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x2  was 0x0\n2020/09/27 21:46:15.116023 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 21:46:15.214014 ctdbd[4709]: Takeover of IP 192.168.6.85/24 on interface mother_ctdb0\n2020/09/27 21:46:15.429033 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 21:46:18.758714 ctdb-eventd[4711]: 05.system: NOTICE: System memory utilization 79% < threshold 80%\n2020/09/27 22:13:15.978725 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 80% >= threshold 80%\n2020/09/27 22:13:31.641189 ctdb-eventd[4711]: 05.system: NOTICE: System memory utilization 79% < threshold 80%\n2020/09/27 22:14:49.629330 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 80% >= threshold 80%\n2020/09/27 22:15:05.297995 ctdb-eventd[4711]: 05.system: NOTICE: System memory utilization 79% < threshold 80%\n2020/09/27 22:20:47.669650 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 80% >= threshold 80%\n2020/09/27 22:21:18.556452 ctdb-eventd[4711]: 05.system: NOTICE: System memory utilization 79% < threshold 80%\n2020/09/27 22:21:33.946330 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 80% >= threshold 80%\n2020/09/27 22:21:49.396394 ctdb-eventd[4711]: 05.system: NOTICE: System memory utilization 79% < threshold 80%\n2020/09/27 22:22:04.761475 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 80% >= threshold 80%\n2020/09/27 22:22:20.202115 ctdb-eventd[4711]: 05.system: NOTICE: System memory utilization 79% < threshold 80%\n2020/09/27 22:22:35.605809 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 80% >= threshold 80%\n2020/09/27 22:22:51.007145 ctdb-eventd[4711]: 05.system: NOTICE: System memory utilization 79% < threshold 80%\n2020/09/27 22:23:06.625739 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 80% >= threshold 80%\n2020/09/27 23:10:17.295022 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x0  was 0x2\n2020/09/27 23:10:18.150610 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 23:10:18.156778 ctdbd[4709]: Release of IP 192.168.6.85/24 on interface mother_ctdb0  node:1\n2020/09/27 23:10:18.372087 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 23:10:22.464028 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x2  was 0x0\n2020/09/27 23:10:23.170822 ctdb-recoverd[5035]: Takeover run starting\n2020/09/27 23:10:23.268917 ctdbd[4709]: Takeover of IP 192.168.6.85/24 on interface mother_ctdb0\n2020/09/27 23:10:23.416279 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/27 23:37:27.304145 ctdb-eventd[4711]: 05.system: WARNING: Filesystem / utilization 93% >= threshold 90%\n2020/09/27 23:38:14.678701 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 81% >= threshold 80%\n2020/09/27 23:38:30.611111 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 80% >= threshold 80%\n2020/09/28 00:50:57.791769 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x0  was 0x2\n2020/09/28 00:50:58.295366 ctdb-recoverd[5035]: Takeover run starting\n2020/09/28 00:50:58.299429 ctdbd[4709]: Release of IP 192.168.6.85/24 on interface mother_ctdb0  node:1\n2020/09/28 00:50:58.604606 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/28 00:51:02.941396 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x2  was 0x0\n2020/09/28 00:51:03.299678 ctdb-recoverd[5035]: Takeover run starting\n2020/09/28 00:51:03.398259 ctdbd[4709]: Takeover of IP 192.168.6.85/24 on interface mother_ctdb0\n2020/09/28 00:51:03.548167 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/28 01:04:57.799044 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x0  was 0x2\n2020/09/28 01:04:58.104116 ctdb-recoverd[5035]: Takeover run starting\n2020/09/28 01:04:58.119712 ctdbd[4709]: Release of IP 192.168.6.85/24 on interface mother_ctdb0  node:1\n2020/09/28 01:04:58.647242 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/28 01:05:02.956330 ctdb-recoverd[5035]: Node 1 has changed flags - now 0x2  was 0x0\n2020/09/28 01:05:03.099805 ctdb-recoverd[5035]: Takeover run starting\n2020/09/28 01:05:03.221812 ctdbd[4709]: Takeover of IP 192.168.6.85/24 on interface mother_ctdb0\n2020/09/28 01:05:03.312742 ctdb-recoverd[5035]: Takeover run completed successfully\n2020/09/28 01:55:11.685139 ctdb-eventd[4711]: 05.system: WARNING: System memory utilization 81% >="
  }

Enable or Disable CTDB Event Script

Call /db/ctdb/event with the service (samba, nfs, or winbind) and action (enable or disable) in the Body

Request Object

+ URL
  /api/v2/db/ctdb/event

+ Method
  POST

+ Headers
  Content-Type: application/json
  token: ThisIsNotARealTokenGenerateYourOwnToken

+ Body
  {
    "service":"samba",
    "action":"enable"
  }

Response Object

Sending this should get you back a valid response, an empty object

+ Headers
  X-Powered-By: OpenDrives
  Access-Control-Allow-Origin: *
  Content-Type: application/json; charset=utf-8

+ Body
  {}