StarRocks新一代极速全场景MPP数据库三节点集群安装配置详解

环境:
[root@node181 ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@node181 ~]# uname -a
Linux node181 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux


集群节点:
node181  172.16.8.181
node131  172.16.8.131
node132  172.16.8.132

下载官方的tar包
https://www.starrocks.io/download/community

地址:https://releases.starrocks.io/starrocks/StarRocks-2.5.0-rc03.tar.gz


在Linux部署StarRocks(所有节点都一样配置)
1.首先需要Linux需要JDK环境,建议使用jdk8
yum install java-1.8.0-openjdk* -y


[root@node131 ~]# rpm -qa | grep java
tzdata-java-2022c-1.el7.noarch
java-1.8.0-openjdk-1.8.0.342.b07-1.el7_9.x86_64
java-1.8.0-openjdk-devel-1.8.0.342.b07-1.el7_9.x86_64
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.342.b07-1.el7_9.x86_64
java-atk-wrapper-0.30.4-5.el7.x86_64
java-1.8.0-openjdk-demo-1.8.0.342.b07-1.el7_9.x86_64
java-1.8.0-openjdk-src-1.8.0.342.b07-1.el7_9.x86_64
java-1.8.0-openjdk-javadoc-1.8.0.342.b07-1.el7_9.noarch
python-javapackages-3.4.1-11.el7.noarch
java-1.8.0-openjdk-accessibility-1.8.0.342.b07-1.el7_9.x86_64
java-1.8.0-openjdk-javadoc-zip-1.8.0.342.b07-1.el7_9.noarch

配置JAVA_HOME环境变量:
vim /etc/profile
在末尾处添加如下三行信息,路径为安装的路径
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

# 生效
source /etc/profile

[root@node181 lib]# echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64


安装之前先使用命令检查CPU是否支持,有信息输出则支持,没信息输出则不支持建议更换机器
cat /proc/cpuinfo |grep avx2
[root@node131 ~]# cat /proc/cpuinfo |grep avx2
flags                : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec arat pku ospke md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
flags                : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec arat pku ospke md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities

解压安装包:
cd /usr/local/src/
wget https://releases.starrocks.io/starrocks/StarRocks-2.5.0-rc03.tar.gz 
mkdir -p /usr/local/starrocks
tar -zxvf /usr/local/src/StarRocks-2.5.0-rc03.tar.gz -C /usr/local/starrocks


编辑fe.conf 根据实际情况分配内存资源:
[root@node181 conf]# pwd
/usr/local/starrocks/StarRocks-2.5.0-rc03/fe/conf
[root@node181 conf]# vim fe.conf
 官方默认是8G,可根据实际情况调整,这个修改成4G


DATE = "$(date +%Y%m%d-%H%M%S)"
JAVA_OPTS="-Dlog4j2.formatMsgNoLookups=true -Xmx4096m -XX:+UseMembar -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=7 -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -Xloggc:${LOG_DIR}/fe.gc.log.$DATE -XX:+PrintConcurrentLocks"


# For jdk 9+, this JAVA_OPTS will be used as default JVM options
JAVA_OPTS_FOR_JDK_9="-Dlog4j2.formatMsgNoLookups=true -Xmx4096m -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=7 -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -Xlog:gc*:${LOG_DIR}/fe.gc.log.$DATE:time"


在所有节点上都需要修改


fe目录下创建文件夹 meta
mkdir -p /usr/local/starrocks/StarRocks-2.5.0-rc03/fe/meta


[root@node132 fe]# pwd
/usr/local/starrocks/StarRocks-2.5.0-rc03/fe
[root@node132 fe]# ll
total 20
drwxr-xr-x 2 1007 1007    86 Jan 10 10:47 bin
drwxr-xr-x 2 1007 1007    61 Jan 16 17:36 conf
drwxr-xr-x 2 1007 1007 16384 Jan 10 10:47 lib
drwxr-xr-x 2 root root     6 Jan 16 17:37 meta
drwxr-xr-x 2 1007 1007    55 Jan 10 10:47 spark-dpp
drwxr-xr-x 4 1007 1007    30 Jan 10 10:47 webroot


.启动fe进程
/usr/local/starrocks/StarRocks-2.5.0-rc03/fe/bin/start_fe.sh --daemon
[root@node181 ~]# jps
16400 OtterLauncher
14040 Jps
3081 StandaloneSessionClusterEntrypoint
13467 StarRocksFE
16300 OtterManagerLauncher
3181 flink-streaming-web-1.4.0.RELEASE.jar
16254 QuorumPeerMain




使用mysql连接查看fe节点信息
[root@node181 ~]# mysql -uroot -P9030 -h172.16.8.181
查看节点信息:
mysql> SHOW PROC '/frontends'\G
*************************** 1. row ***************************
             Name: 172.16.8.181_9010_1673862614095
               IP: 172.16.8.181
      EditLogPort: 9010
         HttpPort: 8030
        QueryPort: 9030
          RpcPort: 9020
             Role: LEADER
        ClusterId: 1148654834
             Join: true
            Alive: true
ReplayedJournalId: 73
    LastHeartbeat: 2023-01-16 17:53:57
         IsHelper: true
           ErrMsg:
        StartTime: 2023-01-16 17:50:23
          Version: 2.5.0-RC03-f2dc50b
1 row in set (0.04 sec)


 添加其他节点的fe
然后在其它节点分别开启fe进程
node131:
/usr/local/starrocks/StarRocks-2.5.0-rc03/fe/bin/start_fe.sh --daemon
[root@node131 fe]# jps
18433 Jps
1618 TaskManagerRunner
18326 StarRocksFE
8439 TaskManagerRunner
14059 TaskManagerRunner


node132:
/usr/local/starrocks/StarRocks-2.5.0-rc03/fe/bin/start_fe.sh --daemon
[root@node132 fe]# jps
3079 TaskManagerRunner
3864 StarRocksFE
4986 TaskManagerRunner
25146 TaskManagerRunner
3996 Jps




在node181上操作:
[root@node181 ~]# mysql -uroot -P9030 -h172.16.8.181
mysql> ALTER SYSTEM ADD FOLLOWER "172.16.8.131:9010";
Query OK, 0 rows affected (10.03 sec)


mysql> ALTER SYSTEM ADD OBSERVER "172.16.8.132:9010";
Query OK, 0 rows affected (10.01 sec)


查看 SHOW PROC '/frontends'\G 就有三台机器都部署了fe节点
mysql>  SHOW PROC '/frontends'\G
*************************** 1. row ***************************
             Name: 172.16.8.132_9010_1673864029630
               IP: 172.16.8.132
      EditLogPort: 9010
         HttpPort: 8030
        QueryPort: 0
          RpcPort: 0
             Role: OBSERVER
        ClusterId: 1148654834
             Join: false
            Alive: false
ReplayedJournalId: 0
    LastHeartbeat: NULL
         IsHelper: false
           ErrMsg: got exception
        StartTime: NULL
          Version: NULL
*************************** 2. row ***************************
             Name: 172.16.8.131_9010_1673864004364
               IP: 172.16.8.131
      EditLogPort: 9010
         HttpPort: 8030
        QueryPort: 0
          RpcPort: 0
             Role: FOLLOWER
        ClusterId: 1148654834
             Join: false
            Alive: false
ReplayedJournalId: 0
    LastHeartbeat: NULL
         IsHelper: true
           ErrMsg: got exception
        StartTime: NULL
          Version: NULL
*************************** 3. row ***************************
             Name: 172.16.8.181_9010_1673862614095
               IP: 172.16.8.181
      EditLogPort: 9010
         HttpPort: 8030
        QueryPort: 9030
          RpcPort: 9020
             Role: LEADER
        ClusterId: 1148654834
             Join: true
            Alive: true
ReplayedJournalId: 450
    LastHeartbeat: 2023-01-16 18:15:05
         IsHelper: true
           ErrMsg:
        StartTime: 2023-01-16 17:50:23
          Version: 2.5.0-RC03-f2dc50b
3 rows in set (1 min 0.07 sec)


部署be节点
be目录下创建storage文件夹
mkdir -p /usr/local/starrocks/StarRocks-2.5.0-rc03/be/storage


在每台机器上启动be节点
/usr/local/starrocks/StarRocks-2.5.0-rc03/be/bin/start_be.sh --daemon


在8.181节点添加be节点


ALTER SYSTEM ADD BACKEND "172.16.8.181:9050";
ALTER SYSTEM ADD BACKEND "172.16.8.131:9050";
ALTER SYSTEM ADD BACKEND "172.16.8.132:9050";


删除:
ALTER SYSTEM DROP BACKEND "172.16.8.181:9050";


查看:
 show proc '/backends'\G;


部署broker节点:
 每台机器启动broker进程


/usr/local/starrocks/StarRocks-2.5.0-rc03/apache_hdfs_broker/bin/start_broker.sh --daemon


#添加
ALTER SYSTEM ADD BROKER broker1 "172.16.8.181:8000";
ALTER SYSTEM ADD BROKER broker1 "172.16.8.131:8000";
ALTER SYSTEM ADD BROKER broker1 "172.16.8.132:8000";

#删除:
ALTER SYSTEM DROP BROKER broker1 "172.16.8.181:8000";

查看:
show proc "/brokers"\G;


使用starrocks:
[root@node181 ~]# mysql -uroot -P9030 -h172.16.8.181
create database example_db;
use example_db;
CREATE TABLE IF NOT EXISTS detailDemo (
    make_time     DATE           NOT NULL COMMENT "YYYY-MM-DD",
    mache_verson  TINYINT        COMMENT "range [-128, 127]",
    mache_num     SMALLINT       COMMENT "range [-32768, 32767] ",
    de_code       INT            COMMENT "range [-2147483648, 2147483647]",
    saler_id      BIGINT         COMMENT "range [-2^63 + 1 ~ 2^63 - 1]",
    pd_num        LARGEINT       COMMENT "range [-2^127 + 1 ~ 2^127 - 1]",
    pd_type       CHAR(20)        NOT NULL COMMENT "range char(m),m in (1-255) ",
    pd_desc       VARCHAR(500)   NOT NULL COMMENT "upper limit value 65533 bytes",
    us_detail     STRING         NOT NULL COMMENT "upper limit value 65533 bytes",
    relTime       DATETIME       COMMENT "YYYY-MM-DD HH:MM:SS",
    channel       FLOAT          COMMENT "4 bytes",
    income        DOUBLE         COMMENT "8 bytes",
    account       DECIMAL(12,4)  COMMENT "",
    ispass        BOOLEAN        COMMENT "true/false"
) ENGINE=OLAP
DUPLICATE KEY(make_time, mache_verson)
PARTITION BY RANGE (make_time) (
    START ("2022-03-11") END ("2022-03-15") EVERY (INTERVAL 1 day)
)
DISTRIBUTED BY HASH(make_time, mache_verson) BUCKETS 8
PROPERTIES(
    "replication_num" = "3",
    "dynamic_partition.enable" = "true",
    "dynamic_partition.time_unit" = "DAY",
    "dynamic_partition.start" = "-3",
    "dynamic_partition.end" = "3",
    "dynamic_partition.prefix" = "p",
    "dynamic_partition.buckets" = "8"
);


desc detailDemo;

分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS