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.pswp.cn/news/902744.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/902744.shtml
英文地址,請注明出處:http://en.pswp.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…