Project: StarRocks (App Definition and Development / Database)
File: environment_configurations.md

displayed_sidebar: "English" This topic lists all environment and system configuration items that you must check and set before deploying StarRocks. Setting these configuration items properly allows your StarRocks cluster to work with high availability and performance. StarRocks uses specific ports for different services. Check whether these ports are occupied on each instance if you have deployed other services on these instances. 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 (`editlogport`) Run the following commands on the FE instances to check whether these ports are occupied: ```Bash netstat -tunlp | grep 8030 netstat -tunlp | grep 9020 netstat -tunlp | grep 9030 netstat -tunlp | grep 9010 ``` 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 . 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 (`behttpport`) `9050`: BE heartbeat service port (`heartbeatserviceport`) `8060`: BE bRPC port (`brpc_port`) Run the following commands on the BE instances to check whether these ports are occupied: ```Bash netstat -tunlp | grep 9060 netstat -tunlp | grep 8040 netstat -tunlp | grep 9050 netstat -tunlp | grep 8060 ``` 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 . 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 (`behttpport`) `9050`: CN heartbeat service port (`heartbeatserviceport`) `8060`: CN bRPC port (`brpc_port`) `9070`: An extra agent service port for CN (BE in v3.0) in a shared-data cluster (`starlet_port`) Run the following commands on the CN instances to check whether these ports are occupied: ```Bash 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 . If you want to for your StarRocks 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. CAUTION All IP addresses in the file /etc/hosts must be

StarRocks 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 echo $JAVA_HOME ``` Follow these steps to set `JAVA_HOME`: Set `JAVA_HOME` in the file /etc/profile: ```Bash sudo vi /etc/profile export JAVAHOME=<pathto_JDK> export PATH=$PATH:$JAVA_HOME/bin ``` Bring the change into effect: ```Bash source /etc/profile ``` Run the following command to verify the change: ```Bash java -version ``` 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 echo 'performance' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor ``` Memory Overcommit allows the operating system to overcommit memory resources to processes. We recommend you enable Memory Overcommit. ```Bash cat >> /etc/sysctl.conf << EOF vm.overcommit_memory=1 EOF sysctl -p ``` 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 echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/enabled echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/defrag 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 ``` We recommend you disable Swap Space. Follow these steps to check and disable Swap Space: Disable Swap Space. ```SQL swapoff /<pathtoswap_space> swapoff -a ``` Delete the Swap Space information from the configuration file /etc/fstab. ```Bash /<pathtoswap_space> swap swap defaults 0 0 ``` Verify that Swap Space is disabled. ```Bash free -m ``` We recommend you disable swappiness to eliminate its impact on performance. ```Bash cat >> /etc/sysctl.conf << EOF vm.swappiness=0 EOF sysctl -p ``` 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 cat /sys/block/${disk}/queue/scheduler ``` We recommend you use the mq-deadline scheduler for SATA disks and the kyber scheduler algorithm for SSD and NVMe disks. The mq-deadline scheduler algorithm suits SATA disks. ```Bash echo mq-deadline | sudo tee /sys/block/${disk}/queue/scheduler 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 ``` If your NVMe or SSD disks support the kyber scheduler algorithm: ```Bash echo kyber | sudo tee /sys/block/${disk}/queue/scheduler 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 echo none | sudo tee /sys/block/vdb/queue/scheduler cat >> /etc/rc.d/rc.local << EOF echo none | sudo tee /sys/block/${disk}/queue/scheduler EOF chmod +x /etc/rc.d/rc.local ``` We recommend you disable

```Bash setenforce 0 sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config sed -i 's/SELINUXTYPE/#SELINUXTYPE/' /etc/selinux/config ``` Open the internal ports for FE nodes, BE nodes, and Broker if your firewall is enabled. ```Bash systemctl stop firewalld.service systemctl disable firewalld.service ``` Run the following command to check and configure the LANG variable manually: ```Bash echo "export LANG=en_US.UTF8" >> /etc/profile source /etc/profile ``` Set this item in accordance with your actual time zone. The following example sets the time zone to `/Asia/Shanghai`. ```Bash cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime hwclock ``` Problems can occur with StarRocks if the values of max file descriptors and max user processes are abnormally small. We recommend you enlarge these values. ```Bash 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 ``` We recommend you use the ext4 or xfs journaling file system. You can run the following command to check the mount type: ```Bash df -Th ``` 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 cat >> /etc/sysctl.conf << EOF net.ipv4.tcpaborton_overflow=1 EOF sysctl -p ``` Specify the maximum number of connection requests queued for any listening socket to `1024`: ```Bash cat >> /etc/sysctl.conf << EOF net.core.somaxconn=1024 EOF sysctl -p ``` You must configure time synchronization between nodes within your StarRocks 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. Check if the NTP time server or Chrony service exists. ```Bash rpm -qa | grep ntp systemctl status chrony ``` Install the NTP service if there is not one. ```Bash sudo yum install ntp ntpdate && \ sudo systemctl start ntpd.service && \ sudo systemctl enable ntpd.service ``` Check the NTP service. ```Bash systemctl list-unit-files | grep ntp ``` Check the connectivity and monitoring status of the NTP service. ```Bash netstat -tunlp | grep ntp ``` Check if your application is synchronized with the NTP server. ```Bash ntpstat ``` Check the state of all the configured NTP servers in your network. ```Bash ntpq -p ``` If your StarRocks cluster has a high load concurrency, we recommend you set the following configurations. Specify the maximum number of memory map areas a process may have as `262144`: ```bash cat >> /etc/sysctl.conf << EOF vm.maxmapcount = 262144 EOF sysctl -p ``` ```Bash echo 120000 > /proc/sys/kernel/threads-max echo 200000 > /proc/sys/kernel/pid_max ```