หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา
- Service Overview
- Billing
- Getting Started
-
User Guide
- Overview
- Permissions Management
- Environment Management
- Application Management
- Component Management
- Instance Management
- Component Configurations
- Component O&M
- System Settings
- Key Operations Recorded by CTS
-
Best Practices
- CAE Best Practices
- Using CAE to Host Nginx Static File Servers
- Interconnecting GitLab with Jenkins for Automatic Build and Deployment on CAE
- Deploying Components Based on the Dependency Sequence Using the Jenkins Pipeline
- Deploying Spring Cloud Applications to CAE to Automatically Connect to the Nacos Engine
- Graceful Startup of a Spring Cloud Application
- Health Check
- Lifecycle Management
- Sending Event Alarms to WeCom
-
Connecting to the CodeArts Pipeline to Automatically Upgrade CAE Components
- Overview
- Upgrading a CAE Component After Uploading a Software Package Built Using the Pipeline to a CodeArts Release Repo
- Upgrading a CAE Component After Uploading a Software Package Built Using the Pipeline to the OBS Bucket
- Upgrading a CAE Component After Uploading an Image Built Using the Pipeline to the SWR Image Repository
- Configuring PromQL to Implement Custom Auto Scaling
- Configuring the Interconnection Between CAE and DEW to Help Applications Obtain Encrypted Secrets from DEW
- Deploying ASP.NET Core Applications to CAE
- Connecting the Network Through Enterprise Routes
- API Reference
-
FAQs
- Component Management FAQs
- Environment Management
-
Component Configuration FAQs
- Is Manual Scaling Still Effective When a Scaling Policy Is Configured?
- Can Components Be Scaled Without a Scaling Policy?
- Why Is My Instance Abnormal After Cloud Storage Is Configured?
- What Do I Do If a Component Becomes Not Ready?
- How Does CAE Support Dark Launch?
- How Do I Provide Prometheus Metrics for a Java Application?
- System Configuration FAQs
- Service Resources FAQs
- General Reference
Show all
Copied.
Configuring RDS
To store application data permanently, you need to use Relational Database Service (RDS). Based on the cloud computing platform, CAE provides RDS for MySQL which is reliable, scalable, easy to manage, and ready for use. RDS for MySQL enables you to easily set and scale relational databases on the cloud. Using the RDS service, you can perform nearly all necessary tasks without programming. This service simplifies operation procedures and reduces routine O&M workloads, so that you can focus on application and service development.
You can bind a cloud database in component configuration. Then, you can read environment variables to obtain MySQL information during application running to access MySQL.
The cloud database to be bound must be in the same VPC as the environment.
Prerequisites
You have created an RDS MySQL DB instance. For details, see Buy a DB Instance.
Procedure
- Log in to CAE.
- Choose Component Configurations.
- Select the target component from the drop-down list in the upper part of the page.
Figure 1 Selecting a component
- Click Configure in the Relational Database Service (RDS) module.
- You need to set RDS environment variables in your code when configuring an RDS instance for the first time. Available variables:
Variable
Description
RDS_ADDRESS
Private IP address of the RDS database instance
RDS_DB_NAME
Database name
RDS_USER_NAME
Database username
RDS_PASSWORD
Database password
RDS_PORT
Database port
After the configurations take effect, user code can obtain RDS database parameters through environment variables and use these parameters to connect to the databases for adding, deleting, modifying, and querying data.
For example, use GORM to connect to postgreg:func initDB() (*gorm.DB, error) { // Obtain parameters from environment variables. dbAddress := os.Getenv("RDS_ADDRESS") dbName := os.Getenv("RDS_DB_NAME") dbUserName := os.Getenv("RDS_USER_NAME") dbPassword := os.Getenv("RDS_PASSWORD") dbPort := os.Getenv("RDS_PORT") // Use the obtained parameters to build DSN. dbDSN := fmt.Sprintf("host=%s port=%s user=%s dbname=%s sslmode=disable password=%s",dbAddress, 5432, dbUserName, dbName, dbPassword) // Connect to a database. instance, err := gorm.Open("postgres", dbDSN) if err != nil { log.Println("connect db failed : " + err.Error()) return nil, err } return instance, nil }
- In the right pane, select an RDS instance.
If the existing RDS instances do not meet service requirements:
1. Click Go to RDS Console to create an RDS instance.
2. Click Next to configure and buy the instance.
- Set the parameters by referring to Table 1.
Table 1 Configuring RDS Parameter
Description
RDS Instance
You can select an RDS database instance in the same VPC as CAE.
Database
Select the target database.
Database Username
Select a user under the database.
Database Password
Enter a database password. The password is mandatory.
Confirm Password
Enter the password again.
Database Port
Enter a database port.
- Click Save.
- Make the configurations take effect.
- If the component has been deployed, click Activate Settings in the upper part of the page. In the dialog box displayed on the right, confirm the configurations and click OK for the configurations to take effect.
- If the component has not been deployed, click Set and Deploy Component in the upper part of the page. In the dialog box displayed on the right, click OK. After the deployment is complete, the configurations take effect.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot