检查环境配置
本主题列出了部署 StarRocks 前必须检查和设置的所有环境和系统配置项。 正确设置这些配置项可以使您的 StarRocks 集群以高可用性和高性能工作。
端口
StarRocks 对不同的服务使用特定的端口。 如果您在这些实例上部署了其他服务,请检查每个实例上的这些端口是否被占用。
FE 端口
在用于 FE 部署的实例上,您需要检查以下端口
8030
: FE HTTP 服务器端口 (http_port
)9020
: FE Thrift 服务器端口 (rpc_port
)9030
: FE MySQL 服务器端口 (query_port
)9010
: FE 内部通信端口 (edit_log_port
)6090
: FE 云原生元数据服务器 RPC 监听端口 (cloud_native_meta_port
)
在 FE 实例上运行以下命令以检查这些端口是否被占用
netstat -tunlp | grep 8030
netstat -tunlp | grep 9020
netstat -tunlp | grep 9030
netstat -tunlp | grep 9010
netstat -tunlp | grep 6090
如果上述任何端口被占用,您必须找到替代方案,并在以后部署 FE 节点时指定它们。 有关详细说明,请参阅部署 StarRocks - 启动 Leader FE 节点。
BE 端口
在用于 BE 部署的实例上,您需要检查以下端口
9060
: BE Thrift 服务器端口 (be_port
)8040
: BE HTTP 服务器端口 (be_http_port
)9050
: BE 心跳服务端口 (heartbeat_service_port
)8060
: BE bRPC 端口 (brpc_port
)9070
: BE 和 CN 的额外代理服务端口 (starlet_port
)
在 BE 实例上运行以下命令以检查这些端口是否被占用
netstat -tunlp | grep 9060
netstat -tunlp | grep 8040
netstat -tunlp | grep 9050
netstat -tunlp | grep 8060
netstat -tunlp | grep 9070
如果上述任何端口被占用,您必须找到替代方案,并在以后部署 BE 节点时指定它们。 有关详细说明,请参阅部署 StarRocks - 启动 BE 服务。
CN 端口
在用于 CN 部署的实例上,您需要检查以下端口
9060
: CN Thrift 服务器端口 (be_port
)8040
: CN HTTP 服务器端口 (be_http_port
)9050
: CN 心跳服务端口 (heartbeat_service_port
)8060
: CN bRPC 端口 (brpc_port
)9070
: BE 和 CN 的额外代理服务端口 (starlet_port
)
在 CN 实例上运行以下命令以检查这些端口是否被占用
netstat -tunlp | grep 9060
netstat -tunlp | grep 8040
netstat -tunlp | grep 9050
netstat -tunlp | grep 8060
netstat -tunlp | grep 9070
如果上述任何端口被占用,您必须找到替代方案,并在以后部署 CN 节点时指定它们。 有关详细说明,请参阅部署 StarRocks - 启动 CN 服务。
主机名
如果您想为您的 StarRocks 集群启用 FQDN 访问,您必须为每个实例分配一个主机名。
在每个实例上的 /etc/hosts 文件中,您必须指定集群中所有其他实例的 IP 地址和对应的主机名。
注意
/etc/hosts 文件中的所有 IP 地址必须是唯一的。
JDK 配置
StarRocks 依赖于环境变量 JAVA_HOME
来定位实例上的 Java 依赖项。
运行以下命令以检查环境变量 JAVA_HOME
echo $JAVA_HOME
按照以下步骤设置 JAVA_HOME
-
在 /etc/profile 文件中设置
JAVA_HOME
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 -
使更改生效
source /etc/profile
运行以下命令以验证更改
java -version
CPU 调频器
此配置项是可选的。 如果您的 CPU 不支持调频器,您可以跳过它。
CPU 调频器控制 CPU 电源模式。 如果您的 CPU 支持它,我们建议您将其设置为 performance
以获得更好的 CPU 性能
echo 'performance' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
内存配置
内存超额分配
内存超额分配允许操作系统将内存资源超额分配给进程。 我们建议您启用内存超额分配。
# Modify the configuration file.
cat >> /etc/sysctl.conf << EOF
vm.overcommit_memory=1
EOF
# Bring the change into effect.
sysctl -p
透明大页
默认情况下启用透明大页。 我们建议您禁用此功能,因为它会干扰内存分配器,从而导致性能下降。
# 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
交换空间
我们建议您禁用交换空间。
按照以下步骤检查和禁用交换空间
-
禁用交换空间。
swapoff /<path_to_swap_space>
swapoff -a -
从配置文件 /etc/fstab 中删除交换空间信息。
/<path_to_swap_space> swap swap defaults 0 0
-
验证是否已禁用交换空间。
free -m
Swappiness
我们建议您禁用 swappiness 以消除其对性能的影响。
# Modify the configuration file.
cat >> /etc/sysctl.conf << EOF
vm.swappiness=0
EOF
# Bring the change into effect.
sysctl -p
存储配置
我们建议您根据您使用的存储介质选择合适的调度器算法。
您可以运行以下命令来检查您正在使用的调度器算法
cat /sys/block/${disk}/queue/scheduler
# For example, run cat /sys/block/vdb/queue/scheduler
我们建议您对 SATA 磁盘使用 mq-deadline 调度器,对 SSD 和 NVMe 磁盘使用 kyber 调度器算法。
SATA
mq-deadline 调度器算法适合 SATA 磁盘。
# 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 和 NVMe
-
如果您的 NVMe 或 SSD 磁盘支持 kyber 调度器算法
# 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 -
如果您的 NVMe 或 SSD 磁盘支持 none (或 noop) 调度器。
# 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
我们建议您禁用 SELinux。
# 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
防火墙
如果您的防火墙已启用,请打开 FE 节点、BE 节点和 Broker 的内部端口。
systemctl stop firewalld.service
systemctl disable firewalld.service
LANG 变量
运行以下命令以手动检查和配置 LANG 变量
# Modify the configuration file.
echo "export LANG=en_US.UTF8" >> /etc/profile
# Bring the change into effect.
source /etc/profile
时区
根据您的实际时区设置此项。
以下示例将时区设置为 /Asia/Shanghai
。
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock
ulimit 配置
如果最大文件描述符和最大用户进程的值异常小,则 StarRocks 可能会出现问题。 我们建议您增大这些值。
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
文件系统配置
我们建议您使用 ext4 或 xfs 日志文件系统。 您可以运行以下命令来检查挂载类型
df -Th
网络配置
tcp_abort_on_overflow
如果系统当前因守护进程无法处理的新连接尝试而溢出,则允许系统重置新连接
# 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
将任何监听套接字的连接请求的最大排队数指定为 1024
# Modify the configuration file.
cat >> /etc/sysctl.conf << EOF
net.core.somaxconn=1024
EOF
# Bring the change into effect.
sysctl -p
NTP 配置
您必须配置 StarRocks 集群中节点之间的时间同步,以确保事务的线性一致性。 您可以使用 pool.ntp.org 提供的互联网时间服务,也可以使用脱机环境中内置的 NTP 服务。 例如,您可以使用云服务提供商提供的 NTP 服务。
-
检查 NTP 时间服务器或 Chrony 服务是否存在。
rpm -qa | grep ntp
systemctl status chronyd -
如果没有 NTP 服务,请安装 NTP 服务。
sudo yum install ntp ntpdate && \
sudo systemctl start ntpd.service && \
sudo systemctl enable ntpd.service -
检查 NTP 服务。
systemctl list-unit-files | grep ntp
-
检查 NTP 服务的连接性和监控状态。
netstat -tunlp | grep ntp
-
检查您的应用程序是否与 NTP 服务器同步。
ntpstat
-
检查网络中所有已配置的 NTP 服务器的状态。
ntpq -p
高并发配置
如果您的 StarRocks 集群具有高负载并发,我们建议您设置以下配置。
max_map_count
将进程可能拥有的最大内存映射区域数指定为 262144
# Modify the configuration file.
cat >> /etc/sysctl.conf << EOF
vm.max_map_count = 262144
EOF
# Bring the change into effect.
sysctl -p
其他
echo 120000 > /proc/sys/kernel/threads-max
echo 200000 > /proc/sys/kernel/pid_max