# Changing the Default Data Directory Post Installation for a Leaf Node

You can configure a custom location for the data directory of a leaf node. Some of the reasons this may be required include moving the leaf node's data directory to a file system that has ample room to grow or restructuring/aligning leaf node directories as part of a clean-up process.

## Example Directories

While the directories of your leaf node will vary, you can use the following example directories to help guide you through the following steps.

**Source**

```
        <memsql-dir> = /var/lib/memsql
     <leaf-node-dir> = /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310
<leaf-node-data-dir> = /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/data

```

**Destination**

```
        <dest-memsql-dir> = /opt/memsql
     <dest-leaf-node-dir> = /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310
<dest-leaf-node-data-dir> = /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/data
```

* *In a High Availability Setup*

  In a high availability (HA) setup, you can perform the procedure by just stopping one leaf node at a time. Repeat these steps for each leaf node as required.## Move the Data Directory of a Leaf NodePerform the following steps to move the data directory of a leaf node.1) **On the main deployment host** (the host where Toolbox is installed), display the cluster's nodes and their corresponding MemSQL IDs.
     ```shell
     sdb-admin list-nodes
     ```

  2) View the data directory of the source leaf node.
     ```shell
     sdb-admin describe-node --memsql-id <MEMSQL-ID> --property datadir 
     ```

  3) Stop the leaf node.
     ```shell
     sdb-admin stop-node --memsql-id <MEMSQL-ID> 
     ```

  4) **On the leaf node host**, create a destination directory in which to copy the leaf node's data directory.
     ```shell
     sudo mkdir -p <dest-leaf-node-dir>
     ```

  5) Copy the leaf node data directory to the destination leaf node directory.
     ```shell
     sudo cp -r <leaf-node-data-dir> <dest-leaf-node-dir>
     ```

  6) Update the user and group of the `<dest-memsql-dir>` directory (which will also update its sub-directories and files). While typically `memsql:memsql`, the user and group may vary based on the environment in which SingleStore was deployed.
     ```shell
     sudo chown -R <user>:<group> <dest-memsql-dir>
     ```

  7) **On the main deployment host**, update the leaf node's data directory to be the destination leaf node data directory.
     ```shell
     sdb-admin update-config --key datadir --value <dest-leaf-node-data-dir> --memsql-id <MEMSQL-ID>
     ```

  8) Update the location of the leaf node's `memsql.id` file to be the destination leaf node data directory.
     ```shell
     sdb-admin update-config --key pid_file --value <dest-leaf-node-data-dir>/memsql.pid --memsql-id <MEMSQL-ID>
     ```

  9) Confirm that the leaf node's data directory has been updated.
     ```shell
     sdb-admin describe-node --memsql-id <MEMSQL-ID> --property datadir
     ```

  10) Restart the leaf node.
      ```shell
      sdb-admin start-node --memsql-id <MEMSQL-ID>
      ```

  11) Confirm that the leaf node is up and running.
      ```shell
      sdb-admin list-nodes
      ```

  12) **On the leaf node host**, remove the leaf node data directory.
      ```shell
      sudo rm -rf <leaf-node-data-dir>
      ```## Move the Entire Leaf Node DirectoryPerform the following steps to move the entire leaf node directory.1) **On the main deployment host** (the host where Toolbox is installed), display the cluster's nodes and their corresponding MemSQL IDs.
     ```shell
     sdb-admin list-nodes
     ```

  2) View the current directory configuration of the source leaf node.
     ```shell
     sdb-admin describe-node --memsql-id <MEMSQL-ID>

     ```
     ```output

     [...]
     | memsqlConfig       | /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/memsql.cnf                 |
     | datadir            | /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/data                       |
     | plancachedir       | /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/plancache                  |
     | tracelogsdir       | /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/tracelogs                  |
     | auditlogsdir       | /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/auditlogs                  |
     [...]
     ```

  3) Stop the leaf node.
     ```shell
     sdb-admin stop-node --memsql-id <MEMSQL-ID>
     ```

  4) **On the leaf node host**, create a destination directory in which to copy the leaf node directory.
     ```shell
     sudo mkdir -p <dest-leaf-node-dir>
     ```

  5) Copy the leaf node directory to the `<dest-memsql-dir>` directory.
     ```shell
     sudo cp -r <leaf-node-dir> <dest-memsql-dir>
     ```

  6) Update the user and group of the `<dest-memsql-dir>` directory (which will also update its sub-directories and files). While typically `memsql:memsql`, the user and group may vary based on the environment in which SingleStore was deployed.
     ```shell
     sudo chown -R <user>:<group> <dest-memsql-dir>
     ```

  7) **On the main deployment host**, update the leaf node's base install directory to be the destination leaf node directory. This will also restart the leaf node and remove the `<leaf-node-dir>`.
     ```shell
     sdb-admin update-node-base-install-dir --memsql-id <MEMSQL-ID> --target-path <dest-leaf-node-dir>

     ```

  8) Confirm that the leaf node's directories have been updated.
     ```shell
     sdb-admin describe-node --memsql-id <MEMSQL-ID>

     ```
     ```output

     [...]
     | memsqlConfig       | /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/memsql.cnf                 |
     | datadir            | /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/data                       |
     | plancachedir       | /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/plancache                  |
     | tracelogsdir       | /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/tracelogs                  |
     | auditlogsdir       | /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/auditlogs                  |
     [...]
     ```

  9) Confirm that the leaf node is up and running.
     ```shell
     sdb-admin list-nodes
     ```

* *In a Non-High Availability Setup*

  In a non-high availability (HA) setup, stop all the nodes before performing the following steps.## Move the Data Directory of a Leaf NodePerform the following steps to move the data directory of a leaf node.1) **On the main deployment host** (the host where Toolbox is installed), display the cluster's nodes and their corresponding MemSQL IDs.
     ```shell
     sdb-admin list-nodes

     ```

  2) View the data directory of the source leaf node.
     ```shell
     sdb-admin describe-node --memsql-id <MEMSQL-ID> --property datadir

     ```

  3) Stop all nodes in the cluster.
     ```shell
     sdb-admin stop-node --all
     ```

  4) **On the leaf node host**, create a destination directory in which to copy the leaf node's data directory.
     ```shell
     sudo mkdir -p <dest-leaf-node-dir>
     ```

  5) Copy the leaf node data directory to the destination leaf node directory.
     ```shell
     sudo cp -r <leaf-node-data-dir> <dest-leaf-node-dir>
     ```

  6) Update the user and group of the `<dest-memsql-dir>` directory (which will also update its sub-directories and files). While typically `memsql:memsql`, the user and group may vary based on the environment in which SingleStore was deployed.
     ```shell
     sudo chown -R <user>:<group> <dest-memsql-dir>
     ```

  7) **On the main deployment host**, update the leaf node's data directory to be the destination leaf node data directory.
     ```shell
     sdb-admin update-config --key datadir --value <dest-leaf-node-data-dir> --memsql-id <MEMSQL-ID>
     ```

  8) Update the location of the leaf node's `memsql.id` file to be the destination leaf node data directory.
     ```shell
     sdb-admin update-config --key pid_file --value <dest-leaf-node-data-dir>/memsql.pid --memsql-id <MEMSQL-ID>
     ```

  9) Confirm that the leaf node's data directory has been updated.
     ```shell
     sdb-admin describe-node --memsql-id <MEMSQL-ID> --property datadir
     ```

  10) Restart all nodes in the cluster.
      ```shell
      sdb-admin start-node --all
      ```

  11) Confirm that the leaf node is up and running.
      ```shell
      sdb-admin list-nodes
      ```

  12) **On the leaf node host**, remove the leaf node data directory.
      ```shell
      sudo rm -rf <leaf-node-data-dir>
      ```## Move the Entire Leaf Node DirectoryPerform the following steps to move the entire leaf node directory.1) **On the main deployment host** (the host where Toolbox is installed), display the cluster's nodes and their corresponding MemSQL IDs.
     ```shell
     sdb-admin list-nodes
     ```

  2) View the current directory configuration of the source leaf node.
     ```shell
     sdb-admin describe-node --memsql-id <MEMSQL-ID>

     ```
     ```output

     [...]
     | memsqlConfig       | /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/memsql.cnf                 |
     | datadir            | /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/data                       |
     | plancachedir       | /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/plancache                  |
     | tracelogsdir       | /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/tracelogs                  |
     | auditlogsdir       | /var/lib/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/auditlogs                  |
     [...]
     ```

  3) Stop all nodes in the cluster.
     ```shell
     sdb-admin stop-node --all
     ```

  4) **On the leaf node host**, create a destination directory in which to copy the leaf node directory.
     ```shell
     sudo mkdir -p <dest-leaf-node-dir>
     ```

  5) Copy the leaf node directory to the `<dest-memsql-dir>` directory.
     ```shell
     sudo cp -r <leaf-node-dir> <dest-memsql-dir>
     ```

  6) Update the user and group of the `<dest-memsql-dir>` directory (which will also update its sub-directories and files). While typically `memsql:memsql`, the user and group may vary based on the environment in which SingleStore was deployed.
     ```shell
     sudo chown -R <user>:<group> <dest-memsql-dir>
     ```

  7) **On the main deployment host**, update the leaf node's base install directory to be the destination leaf node directory. This will also restart the leaf node and remove the `<leaf-node-dir>`.
     ```shell
     sdb-admin update-node-base-install-dir --memsql-id <MEMSQL-ID> --target-path <dest-leaf-node-dir>

     ```

  8) Confirm that the leaf node's directories have been updated.
     ```shell
     sdb-admin describe-node --memsql-id <MEMSQL-ID>

     ```
     ```output

     [...]
     | memsqlConfig       | /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/memsql.cnf                 |
     | datadir            | /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/data                       |
     | plancachedir       | /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/plancache                  |
     | tracelogsdir       | /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/tracelogs                  |
     | auditlogsdir       | /opt/memsql/d3cb2012-77b3-48a0-8875-ade2813b1310/auditlogs                  |
     [...]
     ```

  9) Restart the Master Aggregator node.
     ```shell
     sdb-admin start-node --memsql-id <MEMSQL-ID>
     ```

  10) Confirm that the leaf node is up and running.
      ```shell
      sdb-admin list-nodes
      ```

***

Modified at: February 12, 2024

Source: [/db/v9.1/user-and-cluster-administration/maintain-your-cluster/changing-the-default-data-directory-post-installation-for-a-leaf-node/](https://docs.singlestore.com/db/v9.1/user-and-cluster-administration/maintain-your-cluster/changing-the-default-data-directory-post-installation-for-a-leaf-node/)

(An index of the documentation is available at /llms.txt)
