3台CentOS虚拟机部署 StarRocks 1 FE+ 3 BE集群

背景:公司最近业务数据量上去了,需要做一个漏斗分析功能,实时性要求较高,mysql已经已经不在适用,做了个大数据技术栈选型调研后,决定使用StarRocks

StarRocks官网:StarRocks | A High-Performance Analytical Database

前置准备:

1、3台CentOS虚拟机(2c4g),确保机器间互相可以通信(192.168.0.94、192.168.0.95、192.168.0.245)

2、下载源码 StarRocks-3.4.2-centos-amd64.tar.gz(我使用的版本 3.4.2),上传到虚拟机里

下载地址:Download StarRocks Free | StarRocks

3、3台CentOS虚拟机安装了 Java 11

sudo yum install java-11-openjdk
java -version

tips:可以先在一台虚拟机上做好准备,然后复制虚拟机改下ip配置

4、下载一个mysql客户端,我用的是HeidiSQL,按自己喜欢的来就可以

官方文档的前期准备可以看一遍:前期准备 | StarRocks

安装部署:

这里操作的是 94机器(1FE+1BE)

1、在根目录下创建data文件夹,将StarRocks-3.4.2-centos-amd64.tar.gz文件放在里data下(可选)

2、解压StarRocks-3.4.2-centos-amd64.tar.gz

3、设置软连接(可选)

ln -s StarRocks-3.4.2-centos-amd64 starrocks

 4、配置FE节点信息

vi /data/starrocks/fe/conf/fe.conf

动了四个配置:

放开了LOG_DIR、meta_dir的注释,修改jvm内存为1024(默认是8096)

确保此路径存在并且拥有写入权限 

priority_networks修改为本机ip 

完整配置:

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.#####################################################################
## The uppercase properties are read and exported by bin/start_fe.sh.
## To see all Frontend configurations,
## see fe/fe-core/src/main/java/com/starrocks/common/Config.java# the output dir of stderr/stdout/gc
# 这里改了
LOG_DIR = ${STARROCKS_HOME}/logDATE = "$(date +%Y%m%d-%H%M%S)"
JAVA_OPTS="-Dlog4j2.formatMsgNoLookups=true -Xmx1024m -XX:+UseG1GC -Xlog:gc*:${LOG_DIR}/fe.gc.log.$DATE:time -XX:ErrorFile=${LOG_DIR}/hs_err_pid%p.log -Djava.security.policy=${STARROCKS_HOME}/conf/udf_security.policy"##
## the lowercase properties are read by main program.
### DEBUG, INFO, WARN, ERROR, FATAL
sys_log_level = INFO
# store metadata, create it if it is not exist.
# Default value is ${STARROCKS_HOME}/meta
# 这里改了
meta_dir = ${STARROCKS_HOME}/metahttp_port = 8030
rpc_port = 9020
query_port = 9030
edit_log_port = 9010
mysql_service_nio_enabled = true# Enable jaeger tracing by setting jaeger_grpc_endpoint
# jaeger_grpc_endpoint = http://localhost:14250# Choose one if there are more than one ip except loopback address.
# Note that there should at most one ip match this list.
# If no ip match this rule, will choose one randomly.
# use CIDR format, e.g. 10.10.10.0/24
# Default value is empty.
# 这里改了
priority_networks = 10.10.10.0/24;192.168.0.94/16# Advanced configurations
# log_roll_size_mb = 1024
# sys_log_dir = ${STARROCKS_HOME}/log
# sys_log_roll_num = 10
# sys_log_verbose_modules =
# audit_log_dir = ${STARROCKS_HOME}/log
# audit_log_modules = slow_query, query
# audit_log_roll_num = 10
# meta_delay_toleration_second = 10
# qe_max_connection = 1024
# max_conn_per_user = 100
# qe_query_timeout_second = 300
# qe_slow_log_ms = 5000

 5、配置BE节点信息

vi /data/starrocks/be/conf/be.conf

动了三个配置:

放开了storage_root_path 的注释,priority_networks修改为本机ip ,增加了限制jvm的内存 JAVA_OPTS="-Xmx1024"

确保此路径存在并且拥有写入权限

完整配置:

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.# INFO, WARNING, ERROR, FATAL
sys_log_level = INFO# ports for admin, web, heartbeat service
be_port = 9060
be_http_port = 8040
heartbeat_service_port = 9050
brpc_port = 8060
starlet_port = 9070# Enable jaeger tracing by setting jaeger_endpoint
# jaeger_endpoint = localhost:6831# Choose one if there are more than one ip except loopback address.
# Note that there should at most one ip match this list.
# If no ip match this rule, will choose one randomly.
# use CIDR format, e.g. 10.10.10.0/24
# Default value is empty.
# 这里改了
priority_networks = 10.10.10.0/24;192.168.0.94/16# data root path, separate by ';'
# you can specify the storage medium of each root path, HDD or SSD, seperate by ','
# eg:
# storage_root_path = /data1,medium:HDD;/data2,medium:SSD;/data3
# /data1, HDD;
# /data2, SSD;
# /data3, HDD(default);
#
# Default value is ${STARROCKS_HOME}/storage, you should create it by hand.
# 这里改了
storage_root_path = ${STARROCKS_HOME}/storage# Advanced configurations
sys_log_dir = ${STARROCKS_HOME}/log
# sys_log_roll_mode = SIZE-MB-1024
# sys_log_roll_num = 10
# sys_log_verbose_modules = *
# log_buffer_level = -1# JVM options for be
# eg:
# 这里改了
JAVA_OPTS="-Xmx1024"
# JAVA_OPTS="-Djava.security.krb5.conf=/etc/krb5.conf"
# For jdk 9+, this JAVA_OPTS will be used as default JVM options
# JAVA_OPTS_FOR_JDK_9_AND_LATER="-Djava.security.krb5.conf=/etc/krb5.conf"

6、配置94的防火墙(非必须)

因为是fe+be所以端口多点(直接关闭防火墙也是可以的)

sudo firewall-cmd --zone=public --add-port=9030/tcp --permanent
sudo firewall-cmd --zone=public --add-port=9020/tcp --permanent
sudo firewall-cmd --zone=public --add-port=9010/tcp --permanent
sudo firewall-cmd --zone=public --add-port=8030/tcp --permanent
sudo firewall-cmd --zone=public --add-port=8040/tcp --permanent
sudo firewall-cmd --zone=public --add-port=8050/tcp --permanent
sudo firewall-cmd --zone=public --add-port=8060/tcp --permanentsudo firewall-cmd --reloadsudo systemctl restart firewalld

7、95和245机器配置的be.config

与94节点的be一样配置,就是jvm内存变成了2048 

vi /data/starrocks/be/conf/be.conf

动了三个配置:放开了storage_root_path 的注释,priority_networks修改为本机ip(注意2台机器的ip不同) ,增加了限制jvm的内存 JAVA_OPTS="-Xmx2048"

完整配置:

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.# INFO, WARNING, ERROR, FATAL
sys_log_level = INFO# ports for admin, web, heartbeat service
be_port = 9060
be_http_port = 8040
heartbeat_service_port = 9050
brpc_port = 8060
starlet_port = 9070# Enable jaeger tracing by setting jaeger_endpoint
# jaeger_endpoint = localhost:6831# Choose one if there are more than one ip except loopback address.
# Note that there should at most one ip match this list.
# If no ip match this rule, will choose one randomly.
# use CIDR format, e.g. 10.10.10.0/24
# Default value is empty.
# 这里改了
priority_networks = 10.10.10.0/24;192.168.0.95/16# data root path, separate by ';'
# you can specify the storage medium of each root path, HDD or SSD, seperate by ','
# eg:
# storage_root_path = /data1,medium:HDD;/data2,medium:SSD;/data3
# /data1, HDD;
# /data2, SSD;
# /data3, HDD(default);
#
# Default value is ${STARROCKS_HOME}/storage, you should create it by hand.
# 这里改了
storage_root_path = ${STARROCKS_HOME}/storage# Advanced configurations
sys_log_dir = ${STARROCKS_HOME}/log
# sys_log_roll_mode = SIZE-MB-1024
# sys_log_roll_num = 10
# sys_log_verbose_modules = *
# log_buffer_level = -1# JVM options for be
# eg:
# 这里改了
JAVA_OPTS="-Xmx2048"
# JAVA_OPTS="-Djava.security.krb5.conf=/etc/krb5.conf"
# For jdk 9+, this JAVA_OPTS will be used as default JVM options
# JAVA_OPTS_FOR_JDK_9_AND_LATER="-Djava.security.krb5.conf=/etc/krb5.conf"

8、配置95和245的防火墙(非必须)

直接关闭防火墙也是可以的

sudo firewall-cmd --zone=public --add-port=9050/tcp --permanent
sudo firewall-cmd --zone=public --add-port=9060/tcp --permanent
sudo firewall-cmd --zone=public --add-port=8040/tcp --permanent
sudo firewall-cmd --zone=public --add-port=8060/tcp --permanentsudo firewall-cmd --reloadsudo systemctl restart firewalld

9、启动94机器fe节点和be节点

./data/starrocks/fe/bin/start_fe.sh --daemon
./data/starrocks/be/bin/start_be.sh --daemon

查看fe节点是否启动成功

cat /data/starrocks/fe/log/fe.log | grep thrift

 如果日志打印以下内容,则说明该 FE 节点启动成功:

"2022-08-10 16:12:29,911 INFO (UNKNOWN x.x.x.x_9010_1660119137253(-1)|1) [FeServer.start():52] thrift server started with port 9020."

查看be节点是否启动成功

cat /data/starrocks/be/log/be.INFO | grep heartbeat

如果日志打印以下内容,则说明该 BE 节点启动成功:

"I0614 17:41:39.782819 3717531 thrift_server.cpp:388] heartbeat has started listening port on 9050"

10、启动95和245的be节点

./data/starrocks/be/bin/start_be.sh --daemon

 11、使用客户端连接94节点的fe,端口9030

一开始默认用户是root,密码为空,这里是我进去后加上了密码

连接后

12、查看fe节点状态

在sql窗口运行即可

-- 查看 Leader FE 节点状态
SHOW PROC '/frontends'

Alive=true证明是好的 

 13、将be节点加入集群

-- 将BE节点加入集群
ALTER SYSTEM ADD BACKEND "192.168.0.94:9050", "192.168.0.95:9050", "192.168.0.245:9050";

加错了可以删除

-- 将be节点删除
ALTER SYSTEM DROP BACKEND "192.168.0.97:9050";

14、查看be状态

2个语句一样的效果

-- 查看 BE/CN 节点状态,alive=true
SHOW PROC '/backends'
-- 查看 BE/CN 节点状态,alive=true
SHOW backends

 Alive=true证明是好的 

 失败了可以看看原因,这里是因为我的ip搞错了

15、建表及查询

-- 设置root密码
SET PASSWORD = PASSWORD('root123')-- 创建数据库
CREATE DATABASE IF NOT EXISTS david;-- 删除表
DROP TABLE david.ad_events-- 创建表
CREATE TABLE `ad_events` (
-- 数据类型,https://docs.mirrorship.cn/zh/docs/sql-reference/data-types/`event_time` DATETIME NOT NULL COMMENT '时间',`event_time_hour` DATETIME NOT NULL COMMENT '时间(分、秒为0)',`event_type` TINYINT NOT NULL COMMENT '事件类型(1:请求,2:展示,3:点击)',`user_id` INT NOT NULL COMMENT '用户ID(映射为整数)',`jhn_more` TINYINT NOT NULL COMMENT '是否聚合',`ad_site_id` VARCHAR(128) NOT NULL COMMENT '代码jihuoniaojihuoniaojihuoniao位id',`client_type` TINYINT NOT NULL COMMENT '客户端类型',`my_app_id` VARCHAR(64) NOT NULL COMMENT '应用id',`ad_type` VARCHAR(32) NOT NULL COMMENT '广告类型',`platform` TINYINT NOT NULL COMMENT '广告源',`device_id` VARCHAR(64) NOT NULL COMMENT '设备号'
)
-- 表类型(明细表),https://docs.mirrorship.cn/zh/docs/table_design/table_types/duplicate_key_table/
ENGINE=OLAP
-- 按月分区, https://docs.mirrorship.cn/zh/docs/table_design/data_distribution/expression_partitioning/
PARTITION BY date_trunc('month', event_time)
-- 数据分桶,https://docs.mirrorship.cn/zh/docs/table_design/data_distribution/#%E8%AE%BE%E7%BD%AE%E5%88%86%E6%A1%B6%E6%95%B0%E9%87%8F
DISTRIBUTED BY HASH(user_id) BUCKETS 100
PROPERTIES (-- 分区保留12个月"partition_live_number" = "12",-- 3个副本,根据be节点数据来,生产推荐3个"replication_num" = "3"
);-- 插入表数据
INSERT INTO ad_events (event_time, event_time_hour, event_type, user_id, more, ad_site_id, client_type, my_app_id, ad_type, platform, device_id) 
VALUES 
('2025-04-24 11:38:01', '2025-04-24 11:00:00', 3, 10018, 0, 'jhn_ad_site_id', 1, 'jhn_my_app_id', 'banner', 0, '214685fd-63d3-7f4b-f43d-beb48b5f59be'),
('2025-04-24 11:27:01', '2025-04-24 11:00:00', 2, 10018, 0, 'jhn_ad_site_id', 1, 'jhn_my_app_id', 'banner', 0, '214685fd-63d3-7f4b-f43d-beb48b5f59be')-- 统计分析sql
select event_type, COUNT(*) as num, COUNT(DISTINCT device_id) dau FROM ad_events GROUP by event_type-- 查看表当前的分区情况
SHOW PARTITIONS FROM ad_events;

查询结果

总结:按照官网的文档自己琢磨一下就可以部署成功了,官网文档的部署前提一定要看一遍,线上部署最好是3fe+3be保证高可用。

部署前提条件 | StarRocks

参考文档:

表类型:明细表 | StarRocks

数据类型:Data type overview | StarRocks

数据分区:表达式分区(推荐) | StarRocks

数据分桶:数据分布 | StarRocks

sql参考:SQL 参考 | StarRocks

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/902744.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

软件设计师/系统架构师---计算机网络

概要 什么是计算机网络? 计算机网络是指将多台计算机和其他设备通过通信线路互联,以便共享资源和信息的系统。计算机网络可以有不同的规模,从家庭网络到全球互联网。它们可以通过有线(如以太网)或无线(如W…

1.5软考系统架构设计师:架构师的角色与能力要求 - 超简记忆要点、知识体系全解、考点深度解析、真题训练附答案及解析

超简记忆要点 角色职责 需求规划→架构设计→质量保障 能力要求 技术(架构模式/性能优化) 业务(模型抽象→技术方案) 管理(团队协作/风险控制) 知识体系 基础:CAP/设计模式/网络协议案例&am…

基于STM32的汽车主门电动窗开关系统设计方案

芯片和功能模块选型 主控芯片 STM32F103C8T6:基于 ARM Cortex - M3 内核,有丰富的 GPIO 接口用于连接各类外设,具备 ADC 模块可用于电流检测,还有 CAN 控制器方便实现 CAN 总线通信。它资源丰富、成本低,适合学生进行 DIY 项目开发。按键模块 轻触按键:用于控制车窗的自…

第十三届蓝桥杯 2022 C/C++组 修剪灌木

目录 题目: 题目描述: 题目链接: 思路: 核心思路: 思路详解: 代码: 代码详解: 题目: 题目描述: 题目链接: P8781 [蓝桥杯 2022 省 B] 修…

6.学习笔记-SpringMVC-拦截器(P71-P74)

1.拦截器简介 拦截器的底层思想是AOP思想 2.拦截器入门案例 (一)制作拦截器的功能类 一般情况下,拦截器都是给表现层用的,所以创建在controller下。 (二)配置拦截器的执行位置 在projectinterceptor.…

GAIA-2:用于自动驾驶的可控多视图生成世界模型

25年3月来自英国创业公司 Wayze 的论文“GAIA-2: A Controllable Multi-View Generative World Model for Autonomous Driving”。(注:23年9月其发布GAIA-1) 生成模型为模拟复杂环境提供一种可扩展且灵活的范例,但目前的方法不足…

《算法笔记》10.4小节——图算法专题->最短路径 问题 D: 最短路径

题目描述 有n个城市m条道路&#xff08;n<1000, m<10000)&#xff0c;每条道路有个长度&#xff0c;请找到从起点s到终点t的最短距离和经过的城市名。 输入 输入包含多组测试数据。 每组第一行输入四个数&#xff0c;分别为n&#xff0c;m&#xff0c;s&#xff0c;t…

深度解析 Kubernetes 配置管理:如何安全使用 ConfigMap 和 Secret

目录 深度解析 Kubernetes 配置管理&#xff1a;如何安全使用 ConfigMap 和 Secret一、目录结构二、ConfigMap 和 Secret 的创建1. 创建 ConfigMapconfig/app-config.yaml&#xff1a;config/db-config.yaml&#xff1a; 2. 创建 Secretsecrets/db-credentials.yaml&#xff1a…

数据库之mysql优化

1.引擎&#xff1a; 1.1查看引擎&#xff1a; mysql> show engines; mysql> SHOW VARIABLES LIKE %storage_engine%; mysql> show create table t1; ---查看建表信息1.2 临时指定引擎&#xff1a; mysql> create table innodb1(id int)engineinnodb; 1.3修改…

【Yii2】Yii2框架的一次BUG排查

因为项目需要&#xff0c;最近学习了使用Yii2框架的使用。但毕竟刚上手&#xff0c;好多地方都不清楚。所以就有了这个博客。 1、需求 有这么一个需求&#xff1a; 后台需要访问用户的一个界面。为了界面不出问题&#xff0c;需要传递一个真实存在的Token。但对这个Token没有…

卡尔曼滤波解释及示例

卡尔曼滤波的本质是用数学方法平衡预测与观测的可信度 &#xff0c;通过不断迭代逼近真实状态。其高效性和鲁棒性&#xff0c;通常在导航定位中&#xff0c;需要融合GPS、加速度计、陀螺仪、激光雷达或摄像头数据&#xff0c;来提高位置精度。简单讲&#xff0c;卡尔曼滤波就是…

Python 学习路线与笔记跳转(持续更新笔记链接)

这里写目录标题 Python 学习路线与笔记Python 简介学习路线第一阶段&#xff1a;Python 基础第二阶段&#xff1a;Python 进阶第三阶段&#xff1a;实用库与框架第四阶段&#xff1a;DevOps 与 Python第五阶段&#xff1a;最佳实践与高级技巧 学习资源官方资源在线学习平台书籍…

决策卫生问题:考公考编考研能补救高考选取职业的错误吗

对于决策者来说&#xff0c;“认识你自己”是一个永恒的主题&#xff1b;警惕认知中的缺陷&#xff0c;比什么都重要。在判断与决策问题上&#xff0c;管理者和专业人士往往都非常自信。人类远远不如我们想象的那么理性&#xff0c;人类的判断也远远不如我们想象的那么完美。在…

React19源码阅读之commitRoot

commitRoot入口 在finishConcurrentRender函数&#xff0c;commitRootWhenReady函数&#xff0c;commitRoot函数。 commitRoot流程图 commitRoot函数 commitRoot 函数是 React 渲染流程中用于提交根节点的关键函数。它的主要作用是设置相关的优先级和状态&#xff0c;然后调…

利用Python爬虫实现百度图片搜索的PNG图片下载

在图像识别、训练数据集构建等场景中&#xff0c;我们经常需要从互联网上批量下载图片素材。百度图片是中文搜索中最常用的来源之一。本文将介绍如何使用Python构建一个稳定、可扩展的百度图片爬虫&#xff0c;专门用于下载并保存高清PNG格式图片。 一、项目目标 本项目的目标…

Axure复选框组件的深度定制:实现自定义大小、颜色与全选功能

在产品设计中&#xff0c;复选框作为用户与界面交互的重要元素&#xff0c;其灵活性直接影响到用户体验。本文将介绍如何利用Axure RP工具&#xff0c;通过高级技巧实现复选框组件的自定义大小、颜色调整&#xff0c;以及全选功能的集成&#xff0c;为产品原型设计增添更多可能…

深度理解spring——BeanFactory的实现

BeanFactory Spring之BeanFactory什么是BeanFactoryApplicationContext相对BeanFactory实现的功能性扩展1. MessageSource2. ResourcePatternResolver3. ApplicationEventPublisher4. EnvironmentCapable通用ApplicationContext实践实现BeanFactoryBeanFactory后处理器排序让谁…

跑MPS产生委外采购申请(成品)

问题&#xff1a;跑MPS产生委外采购申请&#xff08;成品&#xff09;&#xff0c;更改BOM和跑MRP&#xff0c;但物料需求清单中无新增物料复合膜的需求。截图如下&#xff1a; 解决方法&#xff1a;更改委外采购申请的批准日期为BOM的生效日和重新展开bom。 重新展开后&#x…

“在中国,为中国” 英飞凌汽车业务正式发布中国本土化战略

3月28日&#xff0c;以“夯实电动化&#xff0c;推进智能化&#xff0c;实现高质量发展”为主题的2025中国电动汽车百人会论坛在北京举办。众多中外机构与行业上下游嘉宾就全球及中国汽车电动化的发展现状、面临的挑战与机遇&#xff0c;以及在技术创新、市场布局、供应链协同等…

优雅实现网页弹窗提示功能:JavaScript与CSS完美结合

在现代Web开发中&#xff0c;弹窗提示是提升用户体验的重要元素之一。本文将深入探讨如何实现一个优雅、可复用的弹窗提示系统&#xff0c;避免常见问题如重复触发、样式混乱等。 核心代码解析 // 控制弹窗是否可以显示的标志 let alertStatus true;// 显示提示信息 functio…