一、环境准备
1. 系统配置
bash
# 系统参数优化
cat >>/etc/sysctl.conf << EOF
vm.swappiness =0
vm.max_map_count =2000000
net.core.somaxconn =65535
EOF
sysctl -p
# 修改系统限制
cat >>/etc/security/limits.conf << EOF
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
EOF
2. 依赖安装
bash
# 安装必要依赖
apt update
apt install -y \
mysql-client \
gcc \
cmake \
byacc \
flex \
automake \
libtool \
binutils-dev \
libiberty-dev \
bison \
python
二、Doris安装
1. 编译安装
bash
# 下载源码
git clone https://github.com/apache/doris.git
cd doris
# 编译
./build.sh
2. 目录配置
bash
# 创建必要目录
mkdir -p /opt/doris/fe/meta
mkdir -p /opt/doris/be/storage
mkdir -p /opt/doris/fe/log
mkdir -p /opt/doris/be/log
# 设置权限
chown -R doris:doris /opt/doris
三、FE节点配置
1. FE配置文件
properties
# fe.conf
JAVA_OPTS="-Xmx8192m -XX:+UseG1GC"
meta_dir =/opt/doris/fe/meta
http_port =8030
rpc_port =9020
query_port =9030
edit_log_port =9010
2. 启动FE
bash
# 启动FE节点
bin/start_fe.sh --daemon
# 检查启动状态
curl http://localhost:8030/api/bootstrap
四、BE节点配置
1. BE配置文件
properties
# be.conf
PPROF_TMPDIR="/tmp"
BE_LOG_DIR =/opt/doris/be/log
storage_root_path =/opt/doris/be/storage
default_rowset_type = BETA
write_buffer_size =134217728
max_tablet_num_per_shard =1024
2. BE节点部署
bash
# 启动BE节点
bin/start_be.sh --daemon
# 添加BE节点到集群
mysql -h 127.0.0.1-P 9030-u root
> ALTER SYSTEM ADD BACKEND "host:port";
五、集群管理
1. 节点管理
sql
--查看节点状态
SHOW PROC '/backends';
--下线BE节点
ALTER SYSTEM DECOMMISSION BACKEND "host:port";
2. 表管理
sql
--创建数据库
CREATE DATABASE example_db;
--创建表
CREATE TABLE example_tbl (
id BIGINT,
name VARCHAR(32),
score DECIMAL(10,2)
)
DISTRIBUTED BY HASH(id) BUCKETS 10
PROPERTIES (
"replication_num"="3"
);
六、性能优化
1. 内存配置
properties
# fe.conf内存优化
heap_size =8192
write_buffer_size =134217728
# be.conf内存优化
chunk_reserved_bytes_limit =2147483648
max_compaction_concurrency =4
2. 查询优化
sql
--设置查询超时时间
SET query_timeout =3600;
--并行度设置
SET parallel_fragment_exec_instance_num =8;
七、监控配置
1. 监控指标
yaml
# prometheus.yml
scrape_configs:
- job_name:'doris_fe'
static_configs:
- targets:['localhost:8030']
- job_name:'doris_be'
static_configs:
- targets:['localhost:8040']
2. 告警配置
yaml
# alert.rules
groups:
- name: doris_alerts
rules:
- alert:DorisNodeDown
expr: up ==0
for:5m
labels:
severity: critical