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

# Check environment configurations

> Environment and system configuration checklist to complete before deploying the database.

This topic lists all environment and system configuration items that you must check and set before deploying the database. Setting these configuration items properly allows your cluster to work with high availability and performance.

## Ports

The database uses specific ports for different services. Check whether these ports are occupied on each instance if you have deployed other services on these instances.

### FE ports

On the instances used for the FE deployment, you need to check the following ports:

* `8030`: FE HTTP server port (`http_port`)
* `9020`: FE Thrift server port (`rpc_port`)
* `9030`: FE MySQL server port (`query_port`)
* `9010`: FE internal communication port (`edit_log_port`)
* `6090`: FE cloud-native metadata server RPC listen port (`cloud_native_meta_port`)

Run the following commands on the FE instances to check whether these ports are occupied:

```Bash theme={null}
netstat -tunlp | grep 8030
netstat -tunlp | grep 9020
netstat -tunlp | grep 9030
netstat -tunlp | grep 9010
netstat -tunlp | grep 6090
```

If any of the above ports are occupied, you must find alternatives and specify them later when you deploy FE nodes. For detailed instructions, see [Deploy the database - Start the Leader FE node](/documents/4.2/deployment/deploy_manually.md#step-1-start-the-leader-fe-node).

### BE ports

On the instances used for the BE deployment, you need to check the following ports:

* `9060`: BE Thrift server port (`be_port`)
* `8040`: BE HTTP server port (`be_http_port`)
* `9050`: BE heartbeat service port (`heartbeat_service_port`)
* `8060`: BE bRPC port (`brpc_port`)
* `9070`: An extra agent service port for BE and CN (`starlet_port`)

Run the following commands on the BE instances to check whether these ports are occupied:

```Bash theme={null}
netstat -tunlp | grep 9060
netstat -tunlp | grep 8040
netstat -tunlp | grep 9050
netstat -tunlp | grep 8060
netstat -tunlp | grep 9070
```

If any of the above ports are occupied, you must find alternatives and specify them later when you deploy BE nodes. For detailed instructions, see [Deploy the database - Start the BE service](/documents/4.2/deployment/deploy_manually.md#step-2-start-the-be-service).

### CN ports

On the instances used for the CN deployment, you need to check the following ports:

* `9060`: CN Thrift server port (`be_port`)
* `8040`: CN HTTP server port (`be_http_port`)
* `9050`: CN heartbeat service port (`heartbeat_service_port`)
* `8060`: CN bRPC port (`brpc_port`)
* `9070`: An extra agent service port for BE and CN (`starlet_port`)

Run the following commands on the CN instances to check whether these ports are occupied:

```Bash theme={null}
netstat -tunlp | grep 9060
netstat -tunlp | grep 8040
netstat -tunlp | grep 9050
netstat -tunlp | grep 8060
netstat -tunlp | grep 9070
```

If any of the above ports are occupied, you must find alternatives and specify them later when you deploy CN nodes. For detailed instructions, see [Deploy the database - Start the CN service](/documents/4.2/deployment/deploy_shared_data_manually.md#step-2-start-the-cn-service).

## Hostnames

If you want to [enable FQDN access](/documents/4.2/administration/management/enable_fqdn.md) for your cluster, you must assign a hostname to each instance.

In the file **/etc/hosts** on each instance, you must specify the IP addresses and corresponding hostnames of all the other instances in the cluster.

**Important**

All IP addresses in the file **/etc/hosts** must be unique.

## JDK configuration

The database runs its Java-based components on a JDK. The Java-based components are:

* The FE
* The Java UDF, connector, and Java Extensions features on the BE and CN

Install the JDK version required by your version before deployment, and then point `JAVA_HOME` to it.

### JDK version by version

The minimum and recommended JDK versions depend on your version:

| version | Minimum JDK | Recommended JDK |
| - | - | - |
| v2.5, v3.0, v3.1, v3.2 | JDK 8 | JDK 11 |
| v3.3, v3.4 | JDK 11 | JDK 11 |
| v3.5, v4.0, v4.1 | JDK 17 | JDK 17 |
| v4.2 and later | JDK 17 | JDK 21 |

Additional notes:

* For v2.5, v3.0, v3.1, and v3.2, deployments on Ubuntu 22.04 require JDK 11.
* The FE compile target was raised from Java 11 to Java 17 in v3.5.0, which is why v3.5 and later require JDK 17 or later at runtime.
* As of v3.5.0, the database no longer ships JVM presets for specific JDK versions; all JDK versions share a single `JAVA_OPTS`. When upgrading to v3.5 or later from v3.4 or earlier, remove any `JAVA_OPTS` options in **fe.conf** that are incompatible with JDK 17 (for example, CMS-related options), and use the default `JAVA_OPTS` shipped with v3.5 and later.
* Starting with v4.2, JDK 21 is recommended. The minimum runtime version remains JDK 17 (the FE compile target is Java 17), and JDK 21 is backward-compatible with the JDK 17 runtime target.
* The minimum and recommended JDK follow the Java LTS calendar. The next change is scheduled for the first minor version released after October 2027, when the minimum JDK becomes JDK 21 and the recommended JDK becomes JDK 25. For details, see [JDK Support Policy](/documents/4.2/developers/versions.md#jdk-support-policy).

**Note**

The database does not support JRE. You must install a full JDK.

### Set JAVA\_HOME

The database relies on the environment variable `JAVA_HOME` to locate the Java dependency on the instance.

Run the following command to check the environment variable `JAVA_HOME`:

```Bash theme={null}
echo $JAVA_HOME
```

Follow these steps to set `JAVA_HOME`:

1. Set `JAVA_HOME` in the file **/etc/profile**:

   ```Bash theme={null}
   sudo vi /etc/profile
   # Replace <path_to_JDK> with the path where JDK is installed.
   export JAVA_HOME=<path_to_JDK>
   export PATH=$PATH:$JAVA_HOME/bin
   ```

2. Bring the change into effect:

   ```Bash theme={null}
   source /etc/profile
   ```

Run the following command to verify the change:

```Bash theme={null}
java -version
```

## CPU scaling governor

This configuration item is **optional**. You can skip it if your CPU does not support the scaling governor.

The CPU scaling governor controls the CPU power mode. If your CPU supports it, we recommend you set it to `performance` for better CPU performance:

```Bash theme={null}
echo 'performance' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
```

## Memory configurations

### Memory Overcommit

Memory Overcommit allows the operating system to overcommit memory resources to processes. We recommend you enable Memory Overcommit.

```Bash theme={null}
# Modify the configuration file.
cat >> /etc/sysctl.conf << EOF
vm.overcommit_memory=1
EOF
# Bring the change into effect.
sysctl -p
```

### Transparent Huge Pages

Transparent Huge Pages are enabled by default. We recommend you disable this feature because it can interfere with the memory allocator, and thereby lead to a drop in performance.

```Bash theme={null}
# Change the configuration temporarily.
echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/defrag
# Change the configuration permanently.
cat >> /etc/rc.d/rc.local << EOF
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo madvise > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo madvise > /sys/kernel/mm/transparent_hugepage/defrag
fi
EOF
chmod +x /etc/rc.d/rc.local
```

### Swap Space

We recommend you disable Swap Space.

Follow these steps to check and disable Swap Space:

1. Disable Swap Space.

   ```SQL theme={null}
   swapoff /<path_to_swap_space>
   swapoff -a
   ```

2. Delete the Swap Space information from the configuration file **/etc/fstab**.

   ```Bash theme={null}
   /<path_to_swap_space> swap swap defaults 0 0
   ```

3. Verify that Swap Space is disabled.

   ```Bash theme={null}
   free -m
   ```

### Swappiness

We recommend you disable swappiness to eliminate its impact on performance.

```Bash theme={null}
# Modify the configuration file.
cat >> /etc/sysctl.conf << EOF
vm.swappiness=0
EOF
# Bring the change into effect.
sysctl -p
```

## Storage configurations

We recommend that you choose your suitable scheduler algorithm in accordance with the storage medium you use.

You can run the following command to check the scheduler algorithm that you are using:

```Bash theme={null}
cat /sys/block/${disk}/queue/scheduler
# For example, run cat /sys/block/vdb/queue/scheduler
```

We recommend you use the mq-deadline scheduler for SATA disks and the kyber scheduler algorithm for SSD and NVMe disks.

### SATA

The mq-deadline scheduler algorithm suits SATA disks.

```Bash theme={null}
# Change the configuration temporarily.
echo mq-deadline | sudo tee /sys/block/${disk}/queue/scheduler
# Change the configuration permanently.
cat >> /etc/rc.d/rc.local << EOF
echo mq-deadline | sudo tee /sys/block/${disk}/queue/scheduler
EOF
chmod +x /etc/rc.d/rc.local
```

### SSD and NVMe

* If your NVMe or SSD disks support the kyber scheduler algorithm:

  ```Bash theme={null}
  # Change the configuration temporarily.
  echo kyber | sudo tee /sys/block/${disk}/queue/scheduler
  # Change the configuration permanently.
  cat >> /etc/rc.d/rc.local << EOF
  echo kyber | sudo tee /sys/block/${disk}/queue/scheduler
  EOF
  chmod +x /etc/rc.d/rc.local
  ```

* If your NVMe or SSD disks support the none (or noop) scheduler.

  ```Bash theme={null}
  # Change the configuration temporarily.
  echo none | sudo tee /sys/block/vdb/queue/scheduler
  # Change the configuration permanently.
  cat >> /etc/rc.d/rc.local << EOF
  echo none | sudo tee /sys/block/${disk}/queue/scheduler
  EOF
  chmod +x /etc/rc.d/rc.local
  ```

## SELinux

We recommend you disable SELinux.

```Bash theme={null}
# Change the configuration temporarily.
setenforce 0
# Change the configuration permanently.
sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
sed -i 's/SELINUXTYPE/#SELINUXTYPE/' /etc/selinux/config
```

## Firewall

Open the internal ports for FE nodes, BE nodes, and Broker if your firewall is enabled.

```Bash theme={null}
systemctl stop firewalld.service
systemctl disable firewalld.service
```

## LANG variable

Run the following command to check and configure the LANG variable manually:

```Bash theme={null}
# Modify the configuration file.
echo "export LANG=en_US.UTF8" >> /etc/profile
# Bring the change into effect.
source /etc/profile
```

## Time zone

Set this item in accordance with your actual time zone.

The following example sets the time zone to `/Asia/Shanghai`.

```Bash theme={null}
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock
```

## ulimit configurations

Problems can occur with the database if the values of **max file descriptors** and **max user processes** are abnormally small. We recommend you enlarge these values.

```Bash theme={null}
cat >> /etc/security/limits.conf << EOF
* soft nproc 65535
* hard nproc 65535
* soft nofile 655350
* hard nofile 655350
* soft stack unlimited
* hard stack unlimited
* hard memlock unlimited
* soft memlock unlimited
EOF

cat >> /etc/security/limits.d/20-nproc.conf << EOF 
*          soft    nproc     65535
root       soft    nproc     65535
EOF
```

## File system configuration

We recommend you use the ext4 or xfs journaling file system. You can run the following command to check the mount type:

```Bash theme={null}
df -Th
```

## Network configuration

### tcp\_abort\_on\_overflow

Allow the system to reset new connections if the system is currently overflowed with new connection attempts that the daemon(s) can not handle:

```Bash theme={null}
# Modify the configuration file.
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_abort_on_overflow=1
EOF
# Bring the change into effect.
sysctl -p
```

### somaxconn

Specify the maximum number of connection requests queued for any listening socket to `1024`:

```Bash theme={null}
# Modify the configuration file.
cat >> /etc/sysctl.conf << EOF
net.core.somaxconn=1024
EOF
# Bring the change into effect.
sysctl -p
```

## NTP configuration

You must configure time synchronization between nodes within your cluster to ensure linear consistency of transactions. You can either use the internet time service provided by pool.ntp.org, or use the NTP service built in an offline environment. For example, you can use the NTP service provided by your cloud service provider.

1. Check if the NTP time server or Chrony service exists.

   ```Bash theme={null}
   rpm -qa | grep ntp
   systemctl status chronyd
   ```

2. Install the NTP service if there is not one.

   ```Bash theme={null}
   sudo yum install ntp ntpdate && \
   sudo systemctl start ntpd.service && \
   sudo systemctl enable ntpd.service
   ```

3. Check the NTP service.

   ```Bash theme={null}
   systemctl list-unit-files | grep ntp
   ```

4. Check the connectivity and monitoring status of the NTP service.

   ```Bash theme={null}
   netstat -tunlp | grep ntp
   ```

5. Check if your application is synchronized with the NTP server.

   ```Bash theme={null}
   ntpstat
   ```

6. Check the state of all the configured NTP servers in your network.

   ```Bash theme={null}
   ntpq -p
   ```

## High concurrency configurations

If your cluster has a high load concurrency, we recommend you set the following configurations.

### max\_map\_count

Specify the maximum number of memory map areas a process may have as `262144`:

```bash theme={null}
# Modify the configuration file.
cat >> /etc/sysctl.conf << EOF
vm.max_map_count = 262144
EOF
# Bring the change into effect.
sysctl -p
```

### Other

```Bash theme={null}
echo 120000 > /proc/sys/kernel/threads-max
echo 200000 > /proc/sys/kernel/pid_max
```


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