flink 读取 starrocks 数据

一些命令

./bin/stop-cluster.sh
./bin/start-cluster.sh
./bin/flink list running
新补充一些 jar 包,需要重启 cluster
Could not acquire the minimum required resources.提示资源不够,需要更改配置
https://blog.csdn.net/liupinyang/article/details/126287771

首先在 starrocks 上创建一个表,插入一些数据

CREATE TABLE `users` (
  `user_id` bigint(20) NOT NULL COMMENT "",
  `name` varchar(65533) NOT NULL COMMENT "",
  `email` varchar(65533) NULL COMMENT "",
  `address` varchar(65533) NULL COMMENT "",
  `age` tinyint(4) NULL COMMENT "",
  `sex` tinyint(4) NULL COMMENT "",
  `last_active` datetime NULL COMMENT "",
  `property0` tinyint(4) NOT NULL COMMENT "",
  `property1` tinyint(4) NOT NULL COMMENT "",
  `property2` tinyint(4) NOT NULL COMMENT "",
  `property3` tinyint(4) NOT NULL COMMENT ""
) ENGINE=OLAP
PRIMARY KEY(`user_id`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`user_id`) BUCKETS 4
PROPERTIES (
"replication_num" = "3",
"in_memory" = "false",
"storage_format" = "DEFAULT",
"enable_persistent_index" = "true",
"compression" = "LZ4"
);

insert into users (user_id,name,property0,property1,property2,property3) values(10, "jack",1,2,3,4);
insert into users (user_id,name,property0,property1,property2,property3) values(11, "mary",1,2,3,4);

在 flink 上创建表

CREATE TABLE flink_test2 (
    user_id bigint ,
    name string ,
    email string ,
    address string ,
    age tinyint ,
    sex tinyint ,
    last_active TIMESTAMP(10),
    property0 tinyint ,
    property1 tinyint ,
    property2 tinyint ,
    property3 tinyint 
) WITH (
   'connector'='starrocks',
   'scan-url'='172.26.194.119:8134',
   'jdbc-url'='jdbc:mysql://172.26.194.119:9132',
   'username'='root',
   'password'='',
   'database-name'='tn_test',
   'table-name'='users'
);

读取

Flink SQL> select * from flink_test2;

你可能感兴趣的:(flink,数据库,sql)