tencent cloud

Serverless Cloud Function

Release Notes and Announcements
Release Notes
Announcements
User Guide
Product Introduction
Overview
Related Concepts
How It Works
Strengths
Scenarios
Related Products
Purchase Guide
Billing Overview
Billing Mode
Billable Items and Billing Modes
Function Computing Power Support
Free Tier
SCF Pricing
Billing Example
Payment Overdue
Getting Started
Creating Event Function in Console
User Guide
Quota Management
Managing Functions
Web Function Management
Log Management
Concurrence Management
Trigger Management
Function URL
A Custom Domain Name
Version Management
Alias Management
Permission Management
Running Instance Management
Plugin Management
Managing Monitors and Alarms
Network Configuration
Layer Management
Execution Configuration
Extended Storage Management
DNS Caching Configuration
Resource Managed Mode Management
Near-Offline Resource Hosting Model
Workflow
Triggers
Trigger Overview
Trigger Event Message Structure Summary
API Gateway Trigger
COS Trigger
CLS Trigger
Timer Trigger
CKafka Trigger
Apache Kafka Trigger
MQTT Trigger
Trigger Configuration Description
MPS Trigger
CLB Trigger Description
TencentCloud API Trigger
Development Guide
Basic Concepts
Testing a Function
Environment Variables
Dependency Installation
Using Container Image
Error Types and Retry Policies
Dead Letter Queue
Connecting SCF to Database
Automated Deployment
Cloud Function Status Code
Common Errors and Solutions
Developer Tools
Serverless Web IDE
Calling SDK Across Functions
Third-Party Tools
Code Development
Python
Node.js
Golang
PHP
Java
Custom Runtime
Deploying Image as Function
Web Framework Development
Deploying Framework on Command Line
Quickly Deploying Egg Framework
Quickly Deploying Express Framework
Quickly Deploying Flask Framework
Quickly Deploying Koa Framework
Quickly Deploying Laravel Framework
Quickly Deploying Nest.js Framework
Quickly Deploying Next.js Framework
Quickly Deploying Nuxt.js Framework
Quickly Deploying Django Framework
Use Cases
Overview
Solutions with Tencent Cloud Services
Business Development
TRTC Practices
COS Practices
CKafka Practice
CLS
CLB Practice
MPS
CDN
CDWPG
VOD
SMS
ES
Scheduled Task
Video Processing
Success Stories
Tencent Online Education
Online Video Industry
Tencent Online Education
Best Practice of Tencent IEG Going Global
API Documentation
History
Introduction
API Category
Making API Requests
Other APIs
Namespace APIs
Layer Management APIs
Async Event Management APIs
Trigger APIs
Function APIs
Function and Layer Status Description
Data Types
Error Codes
SDK Documentation
FAQs
General
Web Function
Billing FAQs
Network FAQs
Log FAQs
SCF utility class
Event Handling FAQs
API Gateway Trigger FAQs
Related Agreement
Service Level Agreement
Contact Us
Glossary
DokumentasiServerless Cloud FunctionUse CasesCKafka PracticeSCF + CKafka for Message Dump to TencentDB for MySQL

SCF + CKafka for Message Dump to TencentDB for MySQL

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2024-12-02 16:35:34

Overview

CKafka allows you to dump messages to TencentDB for MySQL to persistently store filtered data.

Prerequisites

Currently, this feature relies on the SCF and TencentDB for MySQL services, which should be activated first before you can use this feature.

Directions

Message dump to TencentDB for MySQL will be performed with the CKafka trigger in SCF.
1. Log in to the CKafka console.
2. Click Instance List on the left sidebar and click the ID/Name of the target instance to enter the instance details page.
3. On the instance details page, select the Topic Management tab and click Message Dump in the Operation column.
4. Click Add Message Dump and select General template as the dump type.
Dump Type: select General template.
Starting Position: the topic offset of historical messages when dumping.
SCF Authorization: indicate your consent to activating SCF and create a function. Then, you need to go to the function settings to set more advanced configuration items and view monitoring information.
5. After the creation is completed, click the Function Management link to enter the SCF console for the next step.
6. Upload the code of the CKafkaToMysql template (available on GitHub) to the SCF console.


7. Add the following environment variables in Function Configuration of the function.


dbhost=172.16.0.59 // Databases VPC host address
dbuser=tabor // Database username
dbpwd=1237018 // Database password
dbdatabase=canmengtest // Database name
dbtable=123321 // Table name
8. Modify the VPC in Function Configuration to make the VPC of the function the same as that of TencentDB.


9. In the TencentDB for MySQL DMC console, add the relevant databases, tables, and table structures.
Create a database with the same name as in the environment variables:
Create a table with the same name as in the environment variables:
Create a table structure with the same insertion structure as in the function code. offset and Megs will be inserted to by default. You can modify the insertion structure on line 33 in the index.py file. You can also run a TencentDB for MySQL command to directly create tables and data structures:
CREATE TABLE `test_table` ( `offset` VARCHAR(255) NOT NULL , `Megs` LONGTEXT NOT NULL ) ENGINE = InnoDB;
10. Enable the CKafka trigger on the trigger management page in the SCF console.

Restrictions and Billing

The dump speed is subject to the limit of the peak bandwidth of the CKafka instance. If the consumption is too slow, check the peak bandwidth settings.
The CKafkaToMySQL scheme uses the CKafka trigger. For more information on related settings such as retry policy and maximum number of messages, see CKafka Trigger.
When the dump to MySQL feature is used, the dumped messages are the offset and msgBody data of the CKafka trigger by default. If you want to process the logic by yourself, see Event Message Structure for CKafka Trigger.
This feature is provided based on the SCF service that provides a free tier. For more information on the fees for excessive usage, see the billing rules of SCF.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan