Buying an RDS for MariaDB Instance and Connecting to It Using a MariaDB Client
After you buy an RDS instance, you can use a Linux ECS with a MariaDB client installed to connect to the MariaDB instance through its floating IP address. This section describes how to access a DB instance from an ECS using a standard MariaDB client.
Operation Process
|
Process |
Description |
|---|---|
|
Select required basic settings and additional options and buy an RDS for MariaDB instance. |
|
|
If you want to connect to a DB instance using a MariaDB client, you need to prepare a server, install the MariaDB client on the server, and run the connection command. Purchase a Linux ECS that is in the same region and VPC as your DB instance. |
|
|
Test the network connectivity between the ECS and the floating IP address and port of the DB instance, and install a MariaDB client on the ECS. |
|
|
Step 4: Connect to the DB Instance Using a CLI (Non-SSL Connection) |
Use a command-line interface (CLI) to connect to the DB instance using the floating IP address and port. |
Step 1: Buy an RDS for MariaDB Instance
- Go to the Buy DB Instance page.
- Set Billing Mode to Pay-per-use, specify instance information, and click Buy.
- Basic settings
Table 1 Basic settings Parameter
Example Value
Description
Region
-
The region where your resources are located.
NOTE:Products in different regions cannot communicate with each other through a private network. After a DB instance is created, the region cannot be changed. Therefore, exercise caution when selecting a region.
Billing Mode
Pay-per-use
- Pay-per-use: A postpaid billing mode. You pay as you go and just pay for what you use. The instance usage is calculated by the second but billed every hour. If your instance has been used for less than one hour, you will be billed based on the actual duration. This mode allows you to adjust resource usage easily. You do not need to prepare resources in advance, and you never end up with excessive or insufficient resources.
- Engine options
Parameter
Example Value
Description
DB Engine
MariaDB
The DB engine of an instance.
DB Engine Version
10.5
Supported DB engine versions may vary by region. For the actual options, see them on the console.
DB Instance Type
Single
The architecture type of an instance.
- Primary/Standby: An HA architecture. In a primary/standby pair, each instance has the same instance class. When a primary instance is being created, a standby instance is provisioned along with it to provide data redundancy. The standby instance is invisible to you after being created.
- Single: A standalone architecture is less expensive than a primary/standby DB pair. It is only recommended for development and testing of microsites, and small and medium enterprises, or for learning about RDS.
Storage Type
Cloud SSD
The storage type determines the read/write speed of an instance. A higher maximum throughput enables faster I/O operations.
- Cloud SSD: cloud disks used to decouple storage from compute. The maximum throughput is 350 MB/s.
AZ
az1
An AZ is a physical region where resources use independent power supplies and networks. AZs are physically isolated but interconnected through an internal network.
You can deploy your primary and standby instances in a single AZ or across AZs to achieve failover and high availability.
- Instance configuration
Parameter
Example Value
Description
Instance Class
General-purpose | 2U | 4G
The vCPU and memory of an instance. Different instance classes support different numbers of database connections and maximum IOPS.
Storage Space
40 GB
It contains the system overhead required for inodes, reserved blocks, and database operation.
Storage space can range in size from 40 GB to 4,000 GB and can be scaled up only by a multiple of 10 GB.
- Basic settings and connectivity
Parameter
Example Value
Description
DB Instance Name
rds-1d43
Must start with a letter and consist of 4 to 64 characters. Only letters (case-sensitive), digits, hyphens (-), and underscores (_) are allowed.
Administrator
root
The default login name for the database is root.
Administrator Password
****
Must consist of 8 to 32 characters and contain the following character types: uppercase letters, lowercase letters, digits, and special characters (~!@#$%^*-_=+?,()&). Enter a strong password and periodically change it for security reasons.
If the password you provide is regarded as a weak password by the system, you will be prompted to enter a stronger password.
Keep this password secure. The system cannot retrieve it if it is lost.
Confirm Password
****
Must be the same as Administrator Password.
VPC
default_vpc
The virtual network in which your instance is located. A VPC can isolate networks for different workloads. You can select an existing VPC or create a VPC.
If no VPC is available, RDS allocates a VPC to you by default.
NOTICE:After a DB instance is created, the VPC cannot be changed.
Subnet
default_subnet
A subnet provides dedicated network resources that are logically isolated from other networks for network security. Subnets are only valid within a specific AZ. Dynamic Host Configuration Protocol (DHCP) is enabled by default for subnets where you plan to create DB instances and cannot be disabled.
A floating IP address is automatically assigned when you create a DB instance. You can also enter an unused IPv4 IP address in the subnet CIDR block.
Security Group
default
Enhances security by controlling access to your DB instance from other services. Ensure that the security group you select allows the client to access the DB instance.
If no security group is available or has been created, the system allocates a security group to you by default.
- Additional options
Parameter
Example Value
Description
Parameter Template
Default-MariaDB-10.5
Contains engine configuration values that can be applied to one or more DB instances. If you intend to create a primary/standby DB pair, they use the same parameter template. You can modify the instance parameters as required after the instance is created.
Time Zone
Select a time zone as required.
You need to select a time zone for your instance based on the region hosting your instance. You can change the time zone after the DB instance is created.
Table Name
Case insensitive
Specifies whether table names are case sensitive.
NOTE:The case sensitivity of table names for created instances cannot be changed.
Tag
test
Tags an RDS instance. This parameter is optional. Adding tags to RDS instances helps you better identify and manage the DB instances. A maximum of 20 tags can be added for each DB instance.
Quantity
1
The number of instances to be created in a batch.
- Basic settings and connectivity
- Basic settings
- Click Buy.
- Confirm the details, read and agree to the agreement, and click Submit. Go back to the Instances page and check for the purchased instance.
Figure 1 Instance successfully purchased
Step 2: Buy an ECS
- Log in to the ECS console.
- Check whether there is a Linux ECS.
- If yes, go to 3.
If the ECS image is CentOS, CentOS 7.4 64bit must be used.
- If no, purchase an ECS and select Linux (for example, CentOS 7.4 64bit) as its OS.
To download a MariaDB client to the ECS, bind an EIP to the ECS. The ECS must be in the same region, VPC, and security group as the RDS for MariaDB instance for mutual communications.
For details about how to purchase a Linux ECS, see "Purchasing an ECS" in Elastic Cloud Server User Guide.
- If yes, go to 3.
- Check whether the ECS and RDS for MariaDB instance are in the same region and VPC.
- ECS: Click the ECS name to go to the Summary page and find its VPC.
- RDS for MariaDB: Click the instance name to go to the Overview page and find its VPC.
- If they are not in the same region, buy another ECS. The ECS and DB instance in different regions cannot communicate with each other. To reduce network latency, deploy your DB instance in the region nearest to your workloads.
- If they are in different VPCs, change the VPC of the ECS to that of the DB instance. For details, see "Changing a VPC" in the Elastic Cloud Server User Guide.
Step 3: Test Connectivity and Install a MariaDB Client
- Log in to the ECS. For details, see "Logging In to a Linux ECS Using VNC" in Elastic Cloud Server User Guide.
- On the Instances page of the RDS console, check the floating IP address and database port of the DB instance.
- On the ECS, check whether the floating IP address and database port obtained in 2 can be connected.
curl -kv Floating_IP_address:Port
Example:
curl -kv 192.168.230.249:3306
- If yes, network connectivity is normal.
- If no, check the security group rules.
- Check the outbound rules of the ECS security group. By default, all outgoing network traffic is allowed.
If not all outgoing traffic is allowed, add an outbound rule for the floating IP address and port of the DB instance.
- If in the security group of the DB instance, there is no inbound rule allowing the access from the private IP address and port of the ECS, add an inbound rule for the private IP address and port of the ECS. For details, see Configuring a Security Group Rule.
- Check the outbound rules of the ECS security group. By default, all outgoing network traffic is allowed.
- Install the MariaDB client for Linux to the ECS. For details about the installation methods for other OSs, see the official documentation.
yum install MariaDB-client
Figure 2 Installing a MariaDB client
A MariaDB client running a version later than that of the RDS instance is recommended.
Step 4: Connect to the DB Instance Using a CLI (Non-SSL Connection)
- Run the following command on the ECS to connect to the DB instance:
mysql -h <host> -P <port> -u <userName> -p
Example:
mysql -h 192.168.230.249 -P 3306 -u root -p
- Enter the password of the database account if the following information is displayed:
Enter password:
Figure 3 Connection succeeded
- Create a database, for example, mydb.
create database mydb;
Figure 4 Creating a database
- Create a table, for example, my_table.
create table my_table(id int);
Figure 5 Creating a table
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.