Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Function calculates the specific operation of accessing MySQL database

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The following brings you about the specific operation of function calculation to access the MySQL database, I believe you must have read a similar article. What's the difference between what we bring to everyone? Let's take a look at the body part. I believe you will gain something after reading the function calculation and the specific operation of accessing the MySQL database.

Functional Computing (Function Compute): functional Computing is an event-driven fully managed computing service. Using function calculations, you don't need to purchase and manage infrastructure such as servers, just write and upload code. Function computing prepares computing resources for you, runs tasks flexibly and reliably, and provides functions such as log query, performance monitoring and alarm. With function computing, you can quickly build any type of application and service, and only pay for the resources actually consumed by the task.

Working mechanism

Access to IP is not fixed when you run the function, so you cannot access MySQL by setting a whitelist. Based on the principle of minimum permissions, it is not recommended to set all IP (0.0.0.0Univer 0) to the database whitelist in a production environment. Function computing already supports the proprietary network VPC feature. You can enable VPC access for the service where the function resides to access resources in the VPC securely.

You can place MySQL in a secure private network VPC and configure function computing to access resources in VPC. Function computing can securely access your cloud database through VPC.

The workflow for function calculation to access MySQL is shown as follows:

The function calculates the principle of visiting user VPC as follows:

The user's VPC is the user's private network, which requires user authorization to grant the elastic Nic ENI the ability to access the VPC, and insert the ENI into the machine that executes the user function in the FC, so that the function can access the resources in the user's VPC. Function calculation configuration VPC function, please refer to the details.

If the user's VPC resource is not in the current availability zone of the function calculation, you can create a VSwitch in the same availability zone as the function calculation in the user VPC environment, and set this VSwitchID in the VPC configuration of the function calculation service. Due to the intranet interworking between different switches in the same private network, the function calculation can access the resources in the user VPC in other availability zones through the VSwitch.

After the MySQL instance is created successfully, you need to set the whitelist and enter the corresponding instance. Click data Security on the left, select whitelist settings, and set the default in the private network to the configured private network IP segment of the VPC instance or configure the private network IP segment of the switch configured by FC.

Access MySQL database host as the private network address of the instance, and log in to the Aliyun console to view:

Configure public configuration to create a private network VPC to log in to the VPC console. See VPC to build a proprietary network to create VPC and switches. Create a security group

Create a new security group in the Security Group console, click create Security Group, set the security group name, select the private network for the network type, and select the private network you just created.

Create a MySQL instance. Create a new RDS instance in the RDS console, and click create instance. Basic configuration choose the configuration you need, there are no special requirements to choose the default configuration. Select the proprietary network for the network type, and select the VPC and switch that you have created. Select the storage space and purchase amount you need and buy it now. That is, the RDS instance is created successfully. After the instance is created successfully, you need to set the whitelist and enter the corresponding instance. Click data Security on the left, select whitelist settings, and set the default in the private network to the configured private IP segment of the VPC instance or configure the private IP segment of the switch configured by FC. After the whitelist is set successfully, click Database Management on the left, click create Database, and set the database name. Create a new account to access the database. Click on the left account management, fill in the database account, authorization database, login password. You can log in to the database through this account. On the instance details page, click the upper right corner to log in to the database and use the account you just created to log in to the database. (if you do not have DMS access, the console will pop up the authorization page and authorize according to the prompts.) After logging in to the DMS system, select the database in the upper left corner, and you can create tables, insert data, and so on.

So far, you have successfully created VPC, security group, and RDS.

Function calculates configuration VPC

Note: the area where the function calculation service is located is the same as that of the resources created in the public configuration.

Create a service in the function calculation console. For the steps to create a service, please refer to the "add, delete, modify" option of "proprietary Network configuration" in the article, and select the VPC network, switch and security group you created in step 1. In the "permission configuration" option, select "New role", click "Click Authorization", and then click "agree to Authorization" on the role Quick creation page. The operation of this step is to grant the function permission to operate on the ENI. To calculate the permissions required to access the resources in the VPC, please refer to the article configuring the function to calculate the click to access the resources in the VPC. The new service is completed. Installation module

In the function code, you need to use the third-party module that accesses the MySQL. You need to download the third-party module to the directory where the entry is located, put the third-party module and the entry function in the same folder, and then package and upload them together to the function calculation. Third-party module packaging please refer to the article to install third-party dependencies for the function.

For the above about the specific operation of function calculation to access the MySQL database, do you think it is what you want? If you want to know more about it, you can continue to follow our industry information section.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report