After you configure a Fluss catalog, you can read Fluss metadata directly in the Realtime Compute development console. You no longer need to register Fluss tables manually, which speeds up job development and keeps the data accurate. This topic describes how to create, view, use, and delete a Fluss catalog.
Prerequisites
-
A Fluss cluster is created. For more information, see Create a Fluss cluster.
-
The Fluss cluster and the Flink workspace are in the same region and can reach each other over the network, either in the same VPC or with network connectivity configured.
Limits
-
A catalog cannot be modified. To change it, delete the existing catalog and create it again.
-
A catalog created with the password method connects to the Fluss cluster as the administrator. All jobs that use this catalog access data with administrator permissions, so data access cannot be isolated per user.
-
A catalog created with the password-free method authenticates permissions based on the identity of the current user. When different users share the same catalog, each user can access only the data they are authorized for in Fluss.
Create a Fluss catalog
The way you create a catalog depends on the version of the Fluss cluster:
-
Fluss cluster earlier than 0.9-ali-5.0: only the password method is supported. You must provide the administrator username and password.
-
Fluss cluster 0.9-ali-5.0 or later: the password-free method is recommended. No username or password is required, and permissions are authenticated automatically based on the identity of the current user. The password method still works but is not recommended.
After a catalog is created, its configuration cannot be modified. To change it, delete the catalog and create it again.
Password-free method
Applies to Fluss clusters of version 0.9-ali-5.0 or later.
-
Log on to the Realtime Compute console.
-
In the Actions column of the target workspace, click Console.
-
In the left-side navigation pane, click .
In the Create Catalog dialog box, click the Built-in Catalog tab, select Fluss from the Catalog type list, and then click Next.
-
Configure the parameters.
Parameter
Description
Required
Remarks
name
The name of the Fluss catalog.
Yes
Enter a custom name in English.
cluster
The name of the Fluss cluster.
Yes
Select an existing Fluss cluster from the drop-down list. The connection address and authentication information are configured automatically, so you do not need to enter a username or password.
-
Click Confirm. After the catalog is created, you can view it under Catalogs.
For a catalog created with the password-free method, permissions on the Fluss cluster are authenticated automatically based on the identity of the current user when the Flink job runs. When different users share the same catalog, each user can access only the data they are authorized for in Fluss, so you do not need to create a separate catalog for each user.
Password method
Applies to Fluss clusters earlier than version 0.9-ali-5.0.
Console
-
Log on to the Realtime Compute console.
-
In the Actions column of the target workspace, click Console.
-
In the left-side navigation pane, click .
In the Create Catalog dialog box, click the Built-in Catalog tab, select Fluss from the Catalog type list, and then click Next.
-
Configure the parameters.
Parameter
Description
Required
Remarks
name
The name of the Fluss catalog.
Yes
Enter a custom name in English.
cluster
The name of the Fluss cluster.
No
Select an existing Fluss cluster from the drop-down list.
bootstrap.serversis then filled in automatically.default-database
The name of the database to connect to by default.
No
The default value is
fluss, which is pre-filled.bootstrap.servers
The list of server addresses of the Fluss cluster.
Yes
Separate multiple addresses with commas (,). The value is filled in automatically after you select a cluster, and you can also enter it manually.
client.security.sasl.username
The administrator username of the Fluss instance.
Yes
Enter the administrator username of the Fluss cluster.
client.security.sasl.password
The administrator password of the Fluss instance.
Yes
We recommend that you use a project variable to avoid exposing the password in plaintext. For more information, see Project variables.
-
Click Confirm. After the catalog is created, you can view it under Catalogs.
SQL
The SQL method relies on a session cluster, and the session cluster version must be VVR 11.7 or later. If the version is earlier than VVR 11.7, you cannot create a catalog by using SQL. Use the console instead.
In the Scripts editor, enter the following statement.
CREATE CATALOG fluss_catalog WITH (
'type' = 'fluss',
'bootstrap.servers' = '<bootstrap.servers>',
'default-database' = 'fluss',
'client.security.protocol' = 'SASL',
'client.security.sasl.mechanism' = 'PLAIN',
'client.security.sasl.username' = '<username>',
'client.security.sasl.password' = '${secret_values.fluss_password}'
);
After you enter the statement, click Run in the upper-right corner to create the catalog.
The following table describes the parameters.
|
Parameter |
Description |
Required |
Remarks |
|
type |
The catalog type. |
Yes |
Fixed value: |
|
bootstrap.servers |
The list of server addresses of the Fluss cluster. |
Yes |
Separate multiple addresses with commas (,). |
|
default-database |
The name of the database to connect to by default. |
No |
The default value is |
|
client.security.protocol |
The security authentication protocol. |
Yes |
Fixed value: |
|
client.security.sasl.mechanism |
The SASL authentication mechanism. |
Yes |
Fixed value: |
|
client.security.sasl.username |
The administrator username of the Fluss instance. |
Yes |
None. |
|
client.security.sasl.password |
The administrator password of the Fluss instance. |
Yes |
We recommend that you use a project variable to avoid exposing the password in plaintext. |
Create a custom catalog
Fluss iterates faster than Realtime Compute for Apache Flink. This topic provides the latest custom catalog package. You can use it to try out Fluss catalog features that have not been released with a VVR version.
Use a custom catalog only when the Fluss feature you need depends on a VVR version that is not yet released. In all other cases, use the built-in Fluss catalog.
A custom catalog can be created only by uploading a JAR file in the console. After it is created, you use it in the same way as a built-in Fluss catalog.
-
Download the custom catalog JAR file: fluss-ali-vvr-11-0.9-ali-catalog-6.0.jar
-
In the Create Catalog dialog box, click the Custom Catalog tab.
-
Click Create Custom Catalog Type, upload the downloaded JAR file, and then click Next.
-
After the JAR file is loaded, set Catalog Type to
fluss-latestand click OK. -
Select this catalog, and then click Next to create the custom catalog.
CREATE CATALOG fluss_catalog WITH ( 'type' = 'fluss-latest', 'bootstrap.servers' = '<bootstrap.servers>', 'default-database' = 'fluss', 'client.security.protocol' = 'SASL', 'client.security.sasl.mechanism' = 'PLAIN', 'client.security.sasl.username' = '<username>', 'client.security.sasl.password' = '<password>' );Parameter
Description
Required
Remarks
type
The catalog type.
Yes
Fixed value:
fluss-latest.bootstrap.servers
The list of server addresses of the Fluss cluster.
Yes
You can view it on the cluster details page of the Fluss console.
default-database
The name of the database to connect to by default.
No
The default value is
fluss.client.security.protocol
The security authentication protocol.
Yes
Fixed value:
SASL.client.security.sasl.mechanism
The SASL authentication mechanism.
Yes
Fixed value:
PLAIN.client.security.sasl.username
The administrator username of the Fluss instance.
Yes
You can view them on the cluster details page of the Fluss console.
client.security.sasl.password
The administrator password of the Fluss instance.
Yes
View a Fluss catalog
After the Fluss catalog is configured, perform the following steps to view Fluss metadata.
-
Log on to the Realtime Compute console.
-
In the Actions column of the target workspace, click Console.
-
In the left-side navigation pane, click Catalogs.
-
On the Catalog List page, view the catalog name and type.
-
Click View to view the databases and tables in the target catalog.
Use a Fluss catalog
Create a Fluss table
After the Fluss catalog is configured, you can reference the table information of the Fluss catalog in a job. You do not need to declare the table DDL when the table is used as a source table, result table, or dimension table.
In the Scripts editor, enter the following CREATE TABLE statement.
Syntax:
CREATE TABLE `${catalog_name}`.`${db_name}`.`${table_name}` (
...
);
Example:
-- Create a primary key table
CREATE TABLE `fluss_catalog`.`fluss`.`product` (
shop_id BIGINT,
user_id BIGINT,
num_orders INT,
total_amount INT,
PRIMARY KEY (shop_id, user_id) NOT ENFORCED
) WITH (
'bucket.num' = '4'
);
-- Create a log table
CREATE TABLE `fluss_catalog`.`fluss`.`orders` (
order_id BIGINT,
item_id BIGINT,
amount INT,
address STRING
);
You can also switch to the target catalog and database first, and then create the table:
USE CATALOG fluss_catalog;
USE fluss;
CREATE TABLE product (
shop_id BIGINT,
user_id BIGINT,
num_orders INT,
total_amount INT,
PRIMARY KEY (shop_id, user_id) NOT ENFORCED
) WITH (
'bucket.num' = '4'
);
Read from and write to a Fluss table
Write data from a source table to a Fluss table.
Syntax:
INSERT INTO `${catalog_name}`.`${db_name}`.`${table_name}`
SELECT ...
FROM ${other_source_table};
Example:
INSERT INTO `fluss_catalog`.`fluss`.`product`
SELECT shop_id, user_id, num_orders, total_amount
FROM source_table;
Read data from a Fluss table and write it to a result table.
Syntax:
INSERT INTO ${other_sink_table}
SELECT ...
FROM `${catalog_name}`.`${db_name}`.`${table_name}`;
Example:
INSERT INTO sink_table
SELECT shop_id, user_id, num_orders, total_amount
FROM `fluss_catalog`.`fluss`.`product`;
Delete a Fluss catalog
Deleting a Fluss catalog does not affect running jobs, but it does affect jobs that are not yet deployed or that need to be suspended and resumed. Proceed with caution.
Console
-
Log on to the Realtime Compute console.
-
In the Actions column of the target workspace, click Console.
-
In the left-side navigation pane, click Catalogs.
-
On the Catalog List page, click Delete in the Actions column of the target catalog.
-
In the dialog box that appears, click Delete.
-
After the deletion is complete, check whether the target catalog is removed from the Catalogs section on the left.
SQL
In the Scripts editor, enter the following statement.
DROP CATALOG ${catalog_name};
${catalog_name} is the name of the Fluss catalog to delete, as displayed in the Realtime Compute development console.
Select the statement that deletes the catalog, and then click Run in the upper-right corner.
In the Catalogs section on the left, check whether the target catalog is removed.