StarRocks 开发文档
镜舟数据库官网
Doris 介绍
SelectDB 官网
CentOS7安装部署Doris
CentOS7安装部署CDH6.2.1
CentOS基础操作命令
CentOS对换home分区与root分区的存储空间
CentOS7安装部署Java11
CentOS7安装部署MySQL80
系统架构 @ Architecture @ StarRocks Docs
StarRocks 存算分离架构 @ StarRocks Docs
对于 StarRocks 生产集群,建议至少部署三个 Follower FE 节点,以防止单点故障。
对于 StarRocks 生产集群,建议至少部署三个 BE 节点,这些节点会自动形成一个 BE 高可用集群,避免由于发生单点故障而影响数据可靠性和服务可用性。
通过增加 BE 节点的数量来实现查询的高并发。
检查环境配置 | StarRocks
端口 | 端口名称 | 端口说明 |
---|---|---|
8030 | http_port | FE HTTP Server 端口 |
9020 | rpc_port | FE Thrift Server 端口 |
9030 | query_port | FE MySQL Server 端口 |
9010 | edit_log_port | FE 内部通讯端口 |
端口 | 端口名称 | 端口说明 |
---|---|---|
9060 | be_port | BE Thrift Server 端口 |
8040 | webserver_port | BE HTTP Server 端口 |
9050 | heartbeat_service_port | BE 心跳服务端口 |
8060 | brpc_port | BE BRPC 端口 |
端口 | 端口名称 | 端口说明 |
---|---|---|
9060 | thrift_port | CN Thrift Server 端口 |
8040 | webserver_port | CN HTTP Server 端口 |
9050 | heartbeat_service_port | CN 心跳服务端口 |
8060 | brpc_port | CN BRPC 端口 |
meta_dir = /data/starrocks/metadata
storage_root_path = /data/starrocks/storage
集群名 | IP 地址 | 实例 |
---|---|---|
sr001 | 192.168.249.131 | FE |
sr002 | 192.168.249.132 | BE |
sr003 | 192.168.249.133 | BE |
sr004 | 192.168.249.134 | CN |
规划 StarRocks 集群 @ plan_cluster @ StarRocks Docs
通常,FE 服务不会消耗大量的 CPU 和内存资源。建议您为每个 FE 节点分配 8 个 CPU 内核和 16 GB RAM。
与 FE 服务不同,如果应用程序需要在大型数据集上处理高度并发或复杂的查询,BE 服务可能会使用大量 CPU 和内存资源。因此,建议为每个 BE 节点分配 16 个 CPU 内核和 64 GB RAM。
在 4 台服务器上执行基础环境的安装和配置
/opt/java/jdk-11.0.19
#-- sr001
hostnamectl set-hostname sr001 --static
hostnamectl set-hostname sr001 --transient
#-- sr002
hostnamectl set-hostname sr002 --static
hostnamectl set-hostname sr002 --transient
#-- sr003
hostnamectl set-hostname sr003 --static
hostnamectl set-hostname sr003 --transient
#-- sr004
hostnamectl set-hostname sr004 --static
hostnamectl set-hostname sr004 --transient
yum -y install gcc
gcc --version
swapon --show
# 备用:打开交换分区:swapon -a
swapoff -a
/etc/fstab
vim /etc/fstab
# /dev/mapper/centos-swap swap swap defaults 0 0
#安装rdate
yum -y install rdate
#同步时间
rdate -s time-b.nist.gov
#查看时间是否正确
date
yum -y install crontab
crontab -e
*/20 * * * * /usr/bin/rdate -s time-b.nist.gov > /dev/null 2>&1
service crond reload
节点位置 | 节点域名 |
---|---|
东南大学 | s1d.time.edu.cn |
清华大学 | s1e.time.edu.cn |
清华大学 | s2a.time.edu.cn |
清华大学 | s2b.time.edu.cn |
北京邮电大学 | s2c.time.edu.cn |
上海交通大学 | ntp.sjtu.edu.cn |
北京邮电大学 | s1a.time.edu.cn |
北京大学 | s1c.time.edu.cn |
香港中文大学 | clock.cuhk.edu.hk |
#--关闭防火墙
systemctl stop firewalld.service
#--开机禁用防火墙
systemctl disable firewalld.service
#--防火墙状态
systemctl status firewalld.service
sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
sed -i 's/SELINUXTYPE/#SELINUXTYPE/' /etc/selinux/config
setenforce 0
echo "export LANG=en_US.UTF8" >> /etc/profile
source /etc/profile
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock
ulimit -n 655350
ulimit -u 40960
echo 1 | sudo tee /proc/sys/net/ipv4/tcp_abort_on_overflow
1024
echo 1024 | sudo tee /proc/sys/net/core/somaxconn
echo 120000 > /proc/sys/kernel/threads-max
echo 262144 > /proc/sys/vm/max_map_count
echo 200000 > /proc/sys/kernel/pid_max
FE 服务器:192.168.249.131
mkdir /opt/starrocks
cd /opt/starrocks
2.5.13
Download StarRocks Free | StarRocks
wget https://releases.starrocks.io/starrocks/StarRocks-2.5.13.tar.gz
tar -xzvf StarRocks-2.5.13.tar.gz
/opt/starrocks/
mv /opt/starrocks/StarRocks-2.5.13/fe/ /opt/starrocks/
mkdir -p /data/starrocks/metadata
chmod -R 777 /data/starrocks/metadata
vim ./fe/conf/fe.conf
# JAVA_OPTS 上面一行
JAVA_HOME=/opt/java/jdk-11.0.19
# 绑定 IP
priority_networks=192.168.249.131/24
# 元数据目录
meta_dir=/data/starrocks/metadata
cd /opt/starrocks
# 启动
./fe/bin/start_fe.sh --daemon
# (备用)停止
# ./fe/bin/stop_fe.sh
cat fe/log/fe.log | grep thrift
thrift server started with port 9020.
浏览器访问:http://192.168.249.131:8030/api/bootstrap
成功提示:
{"replayedJournalId":0,"queryPort":0,"rpcPort":0,"feStartTime":0,"status":"OK","msg":"Success"}
FE 服务器:192.168.249.131
mkdir -p /opt/starrocks
scp -r /opt/starrocks/StarRocks-2.5.13/be [email protected]:/opt/starrocks/be
scp -r /opt/starrocks/StarRocks-2.5.13/be [email protected]:/opt/starrocks/be
scp -r /opt/starrocks/StarRocks-2.5.13/be [email protected]:/opt/starrocks/be
BE 服务器:192.168.249.132、192.168.249.133
cd /opt/starrocks
mkdir -p /data/starrocks/storage
chmod -R 777 /data/starrocks/storage
vim ./be/conf/be.conf
priority_networks=192.168.249.132/24
priority_networks=192.168.249.133/24
# 绑定 IP
priority_networks=192.168.249.132/24
# 存储目录
storage_root_path=/data/starrocks/storage
# JAVA_HOME
JAVA_HOME=/opt/java/jdk-11.0.19
vim /etc/sysctl.conf
vm.max_map_count=2000000
fs.file-max=6553560
sysctl -p
cd /opt/starrocks
# 启动
./be/bin/start_be.sh --daemon
# (备用)停止
# ./be/bin/stop_be.sh
cat be/log/be.INFO | grep heartbeat
thrift server started with port 9020.
http://192.168.249.132:8040/api/health
http://192.168.249.133:8040/api/health
{"status": "OK","msg": "To Be Added"}
BE 服务器:192.168.249.134
CN 节点是 StarRocks 的可选组件,CN 节点自 v2.4 版本起支持
cd /opt/starrocks
vim ./be/conf/cn.conf
# 绑定 IP
priority_networks=192.168.249.134/24
# JAVA_HOME
JAVA_HOME=/opt/java/jdk-11.0.19
vim /etc/sysctl.conf
vm.max_map_count=2000000
fs.file-max=6553560
sysctl -p
cd /opt/starrocks
# 启动
./be/bin/start_cn.sh --daemon
#(备用)停止
# ./be/bin/stop_cn.sh
cat be/log/cn.INFO | grep heartbeat
heartbeat has started listening port on 9050.
可忽略,使用 Navicat 替代
FE 服务器:192.168.249.131
mkdir /opt/mysql
cd /opt/mysql
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-community-common-8.0.25-1.el7.x86_64.rpm
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-community-libs-8.0.25-1.el7.x86_64.rpm
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-community-client-8.0.25-1.el7.x86_64.rpm
rpm -Uvh *.rpm --nodeps --force
mysql -h 192.168.249.131 -P 9030 -uroot -p
扩容缩容 StarRocks
All commands @ StarRocks Docs
# 备用(删除BE节点):ALTER SYSTEM DROPP BACKEND "192.168.249.132:9050";
ALTER SYSTEM ADD BACKEND "192.168.249.132:9050","192.168.249.133:9050";
# CN 节点(可选)
# 备用(删除CN节点):ALTER SYSTEM DROP COMPUTE NODE "192.168.249.134:9050";
ALTER SYSTEM ADD COMPUTE NODE "192.168.249.134:9050";
SET PASSWORD FOR 'root' = PASSWORD('srdb123');
设置时区 @ timezone @ StarRocks Docs
# 查询当前时间
select NOW();
# 查询时区
SHOW VARIABLES LIKE '%time_zone%';
# 设置时区
SET global time_zone = 'Asia/Shanghai';
# 查询 FE 节点状态
SHOW PROC '/frontends'\G
# 查询 BE 节点状态
SHOW PROC '/backends'\G
# 查询 CN
SHOW PROC '/compute_nodes'\G
create database demo;
CREATE TABLE IF NOT EXISTS example_tb
(
`user_id` LARGEINT NOT NULL COMMENT "用户id",
`date` DATE NOT NULL COMMENT "数据灌入日期时间",
`city` VARCHAR(20) COMMENT "用户所在城市",
`age` SMALLINT COMMENT "用户年龄",
`sex` TINYINT COMMENT "用户性别",
`last_visit_date` DATETIME REPLACE DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次访问时间",
`cost` BIGINT SUM DEFAULT "0" COMMENT "用户总消费",
`max_dwell_time` INT MAX DEFAULT "0" COMMENT "用户最大停留时间",
`min_dwell_time` INT MIN DEFAULT "99999" COMMENT "用户最小停留时间"
)
AGGREGATE KEY(`user_id`, `date`, `city`, `age`, `sex`)
DISTRIBUTED BY HASH(`user_id`) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
);
desc example_tb;
insert into example_tb values
(10000,"2017-10-01","北京",20,0,"2017-10-01 06:00:00",20,10,10),
(10000,"2017-10-01","北京",20,0,"2017-10-01 07:00:00",15,2,2),
(10001,"2017-10-01","北京",30,1,"2017-10-01 17:05:45",2,22,22),
(10002,"2017-10-02","上海",20,1,"2017-10-02 12:59:12",200,5,5),
(10003,"2017-10-02","广州",32,0,"2017-10-02 11:20:00",30,11,11),
(10004,"2017-10-01","深圳",35,0,"2017-10-01 10:00:15",100,3,3),
(10004,"2017-10-03","深圳",35,0,"2017-10-03 10:20:22",11,6,6);
SELECT * FROM example_tb;
starrocks-fe.service
,写入内容(根据实际情况修改 ExecStart
和 ExecStop
)cat > /etc/systemd/system/starrocks-fe.service <
cat /etc/systemd/system/starrocks-fe.service
starrocks-be.service
,写入内容(根据实际情况修改 ExecStart
和 ExecStop
)cat > /etc/systemd/system/starrocks-be.service <
cat /etc/systemd/system/starrocks-be.service
starrocks-cn.service
,写入内容(根据实际情况修改 ExecStart
和 ExecStop
)cat > /etc/systemd/system/starrocks-cn.service <
cat /etc/systemd/system/starrocks-cn.service
systemctl daemon-reload
systemctl start starrocks-fe
systemctl start starrocks-be
systemctl start starrocks-cn
systemctl enable starrocks-fe
systemctl enable starrocks-be
systemctl enable starrocks-cn
systemctl status starrocks-fe
systemctl status starrocks-be
systemctl status starrocks-cn