> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# ALTER SYSTEM

> ALTER SYSTEM Manages FE, BE, CN, Broker nodes, and metadata snapshots in a cluster.

ALTER SYSTEM Manages FE, BE, CN, Broker nodes, and metadata snapshots in a cluster.

> **NOTE**
>
> Only the `cluster_admin` role has the privilege to perform this operation.

## Syntax and parameters

### FE

* Add a Follower FE.

  ```SQL theme={null}
  ALTER SYSTEM ADD FOLLOWER "<fe_host>:<edit_log_port>"
  ```

  You can check the status of the new Follower FE by executing `SHOW PROC '/frontends'\G`.

* Drop a Follower FE.

  ```SQL theme={null}
  ALTER SYSTEM DROP FOLLOWER "<fe_host>:<edit_log_port>"
  ```

* Add an Observer FE.

  ```SQL theme={null}
  ALTER SYSTEM ADD OBSERVER "<fe_host>:<edit_log_port>"
  ```

  You can check the status of the new Observer FE by executing `SHOW PROC '/frontends'\G`.

* Drop an Observer FE.

  ```SQL theme={null}
  ALTER SYSTEM DROP OBSERVER "<fe_host>:<edit_log_port>"
  ```

* Transfer the Leader role to another Follower FE (graceful in-place handoff).

  ```SQL theme={null}
  ALTER SYSTEM TRANSFER LEADER TO "<fe_host>:<edit_log_port>" [FORCE]
  ```

  The target must be an alive Follower FE. This statement runs on the current Leader FE and hands the Leader role to the target Follower; the previous Leader then transitions to a Follower in place instead of restarting. Check the new Leader with `SHOW PROC '/frontends'\G`. With `FORCE`, the statement supersedes a Leader transfer that is already in progress at the BDBJE layer; without `FORCE`, it fails if such a transfer is in progress. Concurrent `TRANSFER LEADER` statements are serialized on the Leader: a queued statement waits for the previous one to finish, and returns an error if this FE is no longer the Leader when it gets its turn (it does not trigger a second transfer).

  Failure semantics: if the transfer itself fails (for example, the target cannot catch up within the internal 30-second window, or its cluster membership is not fully acknowledged yet), the statement returns an error and the current Leader stays unchanged - a safe outcome you can simply retry. If the transfer succeeds but the old Leader cannot drain its in-flight work within `leader_demotion_drain_timeout_sec`, the old Leader process exits and restarts as a Follower; the new Leader is unaffected.

  This statement is not supported in shared-data clusters and returns an error there; to transfer leadership in shared-data mode, restart the current Leader FE to trigger an election.

| **Parameter** | **Required** | **Description** |
| - | - | - |
| fe\_host | Yes | The host name or IP address of the FE instance. Use the value of configuration item `priority_networks` if your instance has multiple IP addresses. |
| edit\_log\_port | Yes | BDB JE communication port of the FE node. Default: `9010`. |
| FORCE | No | Supersede a Leader transfer that is already in progress at the BDBJE layer. Without it, the statement fails if such a transfer is in progress. Concurrent `TRANSFER LEADER` statements are serialized and do not need `FORCE`. |

### BE

* Add a BE node.

  ```SQL theme={null}
  ALTER SYSTEM ADD BACKEND "<be_host>:<heartbeat_service_port>"[, ...]
  ```

  You can check the status of the new BE by executing [SHOW BACKENDS](/documents/4.2/sql-reference/sql-statements/cluster-management/nodes_processes/SHOW_BACKENDS.md).

* Drop a BE node.

  > **NOTE**
  >
  > Without `FORCE`, you cannot drop the BE node that stores the tablets of single-replica tables. With `FORCE`, the BE node is dropped without this check, and the tablets of single-replica tables on it may be lost.

  ```SQL theme={null}
  ALTER SYSTEM DROP BACKEND "<be_host>:<heartbeat_service_port>"[, ...] [FORCE]
  ```

* Decommission a BE node.

  ```SQL theme={null}
  ALTER SYSTEM DECOMMISSION BACKEND "<be_host>:<heartbeat_service_port>"[, ...]
  ```

  Unlike dropping a BE node, which is removing it forcibly from the cluster, decommissioning a BE means removing it safely. It is an asynchronous operation. When a BE is decommissioned, the data on the BE is first migrated to other BEs, and then the BE is removed from the cluster. Data loading and query will not be affected during the data migration. You can check whether the operation is successful using [SHOW BACKENDS](/documents/4.2/sql-reference/sql-statements/cluster-management/nodes_processes/SHOW_BACKENDS.md). If the operation is successful, the decommissioned BE will not be returned. If the operation fails, the BE will still be online. You can manually cancel the operation using [CANCEL DECOMMISSION](/documents/4.2/sql-reference/sql-statements/cluster-management/nodes_processes/CANCEL_DECOMMISSION.md).

| **Parameter** | **Required** | **Description** |
| - | - | - |
| be\_host | Yes | The host name or IP address of the BE instance. Use the value of configuration item `priority_networks` if your instance has multiple IP addresses. |
| heartbeat\_service\_port | Yes | BE heartbeat service port. BE uses this port to receive heartbeat from FE. Default: `9050`. |

### CN

* Add a CN node.

  ```SQL theme={null}
  ALTER SYSTEM ADD COMPUTE NODE "<cn_host>:<heartbeat_service_port>"[, ...]
  ```

  You can check the status of the new CN by executing [SHOW COMPUTE NODES](/documents/4.2/sql-reference/sql-statements/cluster-management/nodes_processes/SHOW_COMPUTE_NODES.md).

* Drop a CN node.

  ```SQL theme={null}
  ALTER SYSTEM DROP COMPUTE NODE "<cn_host>:<heartbeat_service_port>"[, ...]
  ```

> **NOTE**
>
> You cannot decommission a CN node using the `ALTER SYSTEM DECOMMISSION` command.

| **Parameter** | **Required** | **Description** |
| - | - | - |
| cn\_host | Yes | The host name or IP address of the CN instance. Use the value of configuration item `priority_networks` if your instance has multiple IP addresses. |
| heartbeat\_service\_port | Yes | CN heartbeat service port. CN uses this port to receive heartbeat from FE. Default: `9050`. |

### Broker

* Add Broker nodes. You can use Broker nodes to load data from HDFS or cloud storage into the database. For more information, see [Loading](/documents/4.2/loading/loading_introduction/loading_introduction.md).

  ```SQL theme={null}
  ALTER SYSTEM ADD BROKER <broker_name> "<broker_host>:<broker_ipc_port>"[, ...]
  ```

  You can add multiple Broker nodes with one SQL. Each `<broker_host>:<broker_ipc_port>` pair represents one Broker node. And they share a common `broker_name`. You can check the status of the new Broker node by executing [SHOW BROKER](/documents/4.2/sql-reference/sql-statements/cluster-management/nodes_processes/SHOW_BROKER.md).

* Drop Broker nodes.

> **CAUTION**
>
> Dropping a Broker node terminates the tasks currently running on it.

* Drop one or multiple Broker nodes with the same `broker_name`.

  ```SQL theme={null}
  ALTER SYSTEM DROP BROKER <broker_name> "<broker_host>:<broker_ipc_port>"[, ...]
  ```

* Drop all Broker nodes with the same `broker_name`.

  ```SQL theme={null}
  ALTER SYSTEM DROP ALL BROKER <broker_name>
  ```

| **Parameter** | **Required** | **Description** |
| - | - | - |
| broker\_name | Yes | The name of the Broker node(s). Multiple Broker nodes can use the same name. |
| broker\_host | Yes | The host name or IP address of the Broker instance. Use the value of configuration item `priority_networks` if your instance has multiple IP addresses. |
| broker\_ipc\_port | Yes | The thrift server port on the Broker node. The Broker node uses it to receive requests from FE or BE. Default: `8000`. |

### Create image

Create an image file. An image file is a snapshot of the FE metadata.

```SQL theme={null}
ALTER SYSTEM CREATE IMAGE
```

Creating an image is an asynchronous operation triggered on the Leader FE. You can check the start time and end time of the operation in the FE log file **fe.log**. A log like `triggering a new checkpoint manually...` in the **fe.log** of the Leader FE indicates that the image creation has started, and a log like `finished save image...` indicates the image has been created. From v3.4.0 onwards, the Leader FE selects an FE as the checkpoint worker to create the image, preferring FEs with lower heap usage over the Leader FE (unless `checkpoint_only_on_leader` is set to `true`), so the `finished save image...` log is printed in the **fe.log** of that FE. In earlier versions, the image is created on the Leader FE.

## Usage notes

* Adding and dropping FE, BE, CN, or Broker nodes are synchronous operations. You cannot cancel the node dropping operations.
* You cannot drop the FE node in a single-FE cluster.
* You cannot directly drop the Leader FE node in a multi-FE cluster. To drop it, you must first restart it. After the database elects a new Leader FE, you can then drop the previous one.
* In a shared-nothing cluster, you cannot decommission BE nodes if the number of the remaining available BE nodes is less than the number of data replicas. For example, if you have three BE nodes in your cluster and you store your data in three replicas, you cannot decommission any of the BE nodes. And if you have four BE nodes and three replicas, you can decommission one BE node. `DROP BACKEND` does not perform this check. Without `FORCE`, it only rejects a BE node that stores the tablets of single-replica tables.
* The difference between dropping and decommissioning a BE node is that, when you drop a BE node, the database removes it forcibly from the cluster and make up the dropped tablets after the removal, and when you decommission a BE node, the database first migrates the tablets on the decommissioned BE node to others, and then removes the node.

## Examples

Example 1: Add a Follower FE node.

```SQL theme={null}
ALTER SYSTEM ADD FOLLOWER "x.x.x.x:9010";
```

Example 2: Drop an Observer FE node.

```SQL theme={null}
ALTER SYSTEM DROP OBSERVER "x.x.x.x:9010";
```

Example 3: Add a BE node.

```SQL theme={null}
ALTER SYSTEM ADD BACKEND "x.x.x.x:9050";
```

Example 4: Drop two BE nodes simultaneously.

```SQL theme={null}
ALTER SYSTEM DROP BACKEND "x.x.x.x:9050", "x.x.x.x:9050";
```

Example 5: Decommission two BE nodes simultaneously.

```SQL theme={null}
ALTER SYSTEM DECOMMISSION BACKEND "x.x.x.x:9050", "x.x.x.x:9050";
```

Example 6: Add two Broker nodes with the same `broker_name` - `hdfs`.

```SQL theme={null}
ALTER SYSTEM ADD BROKER hdfs "x.x.x.x:8000", "x.x.x.x:8000";
```

Example 7: Drop two Broker nodes from `amazon_s3`.

```SQL theme={null}
ALTER SYSTEM DROP BROKER amazon_s3 "x.x.x.x:8000", "x.x.x.x:8000";
```

Example 8: Drop all Broker nodes in `amazon_s3`.

```SQL theme={null}
ALTER SYSTEM DROP ALL BROKER amazon_s3;
```

Example 9: Transfer the Leader role to a specific Follower FE.

```SQL theme={null}
ALTER SYSTEM TRANSFER LEADER TO "x.x.x.x:9010";
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.