环境
代码语言:javascript复制docker rm -f starrocks253
docker run -itd --name starrocks253 -h starrocks253
-p 9030:9030 -p 8030:8030
-v /sys/fs/cgroup:/sys/fs/cgroup
--privileged=true lhrbest/starrocks:2.5.3
/usr/sbin/init
docker exec -it starrocks253 bash
启动StarRocks
代码语言:javascript复制/usr/local/starrocks/fe/bin/start_fe.sh --daemon
/usr/local/starrocks/be/bin/start_be.sh --daemon
使用
代码语言:javascript复制mysql -h 127.0.0.1 -P9030 -uroot
SHOW frontends G
show backends G
web界面:http://172.18.0.14:8030/ 用户名:root 密码为空
代码语言:javascript复制[root@starrocks253 /]# mysql -h 127.0.0.1 -P9030 -uroot
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.1.0 StarRocks version 2.5.3
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MySQL [(none)]> SHOW frontends ;
------------------------------ ----------- ------------- ---------- ----------- --------- -------- ------------ ------ ------- ------------------- --------------------- ---------- -------- --------------------- ---------------
| Name | IP | EditLogPort | HttpPort | QueryPort | RpcPort | Role | ClusterId | Join | Alive | ReplayedJournalId | LastHeartbeat | IsHelper | ErrMsg | StartTime | Version |
------------------------------ ----------- ------------- ---------- ----------- --------- -------- ------------ ------ ------- ------------------- --------------------- ---------- -------- --------------------- ---------------
| 127.0.0.1_9010_1680064832570 | 127.0.0.1 | 9010 | 8030 | 9030 | 9020 | LEADER | 1723834094 | true | true | 2536 | 2023-03-29 15:15:47 | true | | 2023-03-29 15:13:57 | 2.5.3-46bf084 |
------------------------------ ----------- ------------- ---------- ----------- --------- -------- ------------ ------ ------- ------------------- --------------------- ---------- -------- --------------------- ---------------
1 row in set (0.02 sec)
MySQL [(none)]> show backends;
----------- ----------- --------------- -------- ---------- ---------- --------------------- --------------------- ------- ---------------------- ----------------------- ----------- ------------------ --------------- --------------- --------- ---------------- -------- --------------- -------------------------------------------------------- ------------------- ------------- ---------- ------------------- ------------ ------------
| BackendId | IP | HeartbeatPort | BePort | HttpPort | BrpcPort | LastStartTime | LastHeartbeat | Alive | SystemDecommissioned | ClusterDecommissioned | TabletNum | DataUsedCapacity | AvailCapacity | TotalCapacity | UsedPct | MaxDiskUsedPct | ErrMsg | Version | Status | DataTotalCapacity | DataUsedPct | CpuCores | NumRunningQueries | MemUsedPct | CpuUsedPct |
----------- ----------- --------------- -------- ---------- ---------- --------------------- --------------------- ------- ---------------------- ----------------------- ----------- ------------------ --------------- --------------- --------- ---------------- -------- --------------- -------------------------------------------------------- ------------------- ------------- ---------- ------------------- ------------ ------------
| 11001 | 127.0.0.1 | 9050 | 9060 | 8040 | 8060 | 2023-03-29 15:13:57 | 2023-03-29 15:15:52 | true | false | false | 79 | 27.525 KB | 519.123 GB | 1019.104 GB | 49.06 % | 49.06 % | | 2.5.3-46bf084 | {"lastSuccessReportTabletsTime":"2023-03-29 15:14:58"} | 519.123 GB | 0.00 % | 16 | 0 | 0.34 % | 0.0 % |
----------- ----------- --------------- -------- ---------- ---------- --------------------- --------------------- ------- ---------------------- ----------------------- ----------- ------------------ --------------- --------------- --------- ---------------- -------- --------------- -------------------------------------------------------- ------------------- ------------- ---------- ------------------- ------------ ------------
1 row in set (0.01 sec)
MySQL [(none)]>
mysql> show databases;
--------------------
| Database |
--------------------
| _statistics_ |
| example_db |
| information_schema |
| lhrdb |
| sbtest |
--------------------
5 rows in set (0.08 sec)
您可以运行以下 SQL 确认 StarRocks 是否部署成功。
代码语言:javascript复制CREATE DATABASE db1;
USE db1;
CREATE TABLE `sr_on_mac` (
`c0` int(11) NULL COMMENT "",
`c1` date NULL COMMENT "",
`c2` datetime NULL COMMENT "",
`c3` varchar(65533) NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`c0`)
PARTITION BY RANGE (c1) (
START ("2022-02-01") END ("2022-02-10") EVERY (INTERVAL 1 DAY)
)
DISTRIBUTED BY HASH(`c0`) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "DEFAULT"
);
insert into sr_on_mac values (1, '2022-02-01', '2022-02-01 10:47:57', '111');
insert into sr_on_mac values (2, '2022-02-02', '2022-02-02 10:47:57', '222');
insert into sr_on_mac values (3, '2022-02-03', '2022-02-03 10:47:57', '333');
select * from sr_on_mac where c1 >= '2022-02-02';
如果无错误返回,则表明您已成功在 Docker 环境中部署 StarRocks。
代码语言:javascript复制mysql> select * from sr_on_mac where c1 >= '2022-02-02';
------ ------------ --------------------- ------
| c0 | c1 | c2 | c3 |
------ ------------ --------------------- ------
| 3 | 2022-02-03 | 2022-02-03 10:47:57 | 333 |
| 2 | 2022-02-02 | 2022-02-02 10:47:57 | 222 |
------ ------------ --------------------- ------
2 rows in set (0.16 sec)