tencent cloud

Feedback

CCN Connection

Last updated: 2023-12-27 10:05:39
    This document describes the method to connect to a database by using CCN.

    Background

    Once a MySQL instance is created, if the CVM and instance reside in different VPCs (including both same/different accounts and same/different regions), a CCN can be utilized to connect to the database. Under the same Tencent Cloud account, if the purchased server is a Lighthouse, it employs a Virtual Private Cloud(VPC) allocated automatically by Tencent Cloud for network isolation. By default, the private network is not interconnected with the MySQL in the VPC of the private network, thus direct access to the CDB via Lighthouse cannot be achieved. A connection to the database can be accomplished by using a CCN.
    Connection Methods
    Application Scenarios
    Description
    Billing
    The CVM and TencentDB for MySQL instances are in the same VPC in the same region under the same Tencent Cloud root account. For details, please refer to Scenario 1.
    The private network provides high-speed connectivity and low latency.
    No charge currently
    In scenarios where private network connections are unavailable, you can use public network connections. For details, please see Scenario 2.
    Note:
    Public network connections are more susceptible to network performance. If you have high network requirements, it is advisable to use Private Network Connection or CCN connection.
    
    
    Third-party application connection services are supported.
    The public network address must be manually enabled.
    Enabling the public network address will expose your database services to the public network, which may lead to database intrusions or attacks.
    Public network connection applies to development or auxiliary management of databases but is not recommended for formal business access scenarios. Because the potentially uncontrollable factors may lead to unavailability of the public network connection, such as DDoS attacks and bursts of high-traffic access.
    No charge currently
    CCN Connection
    This connection method applies when the CVM and MySQL are under different VPCs or if the Lighthouse is used for establishing the connection with MySQL. For details, please refer to Scenario 3.
    Whole network is interconnected.
    Provides low latency and high-speed transmission.

    Preparations

    Ensure that the MySQL instance is well-prepared. For detailed guidance, please refer to Creating MySQL Instance.
    Prepare your CVM instance. This document uses Lighthouse as an example. For more information, see Quickly Creating a Linux Lighthouse.

    Precautions

    The Lighthouse internal network interconnection function is provided for free, you only need to pay attention to the billing information of the CCN product. For details, see CCN Pricing Overview. For bandwidth within the same region below 5 GB/s, the service is free. For cross-region private network interconnection, you need to purchase Non-Cross-Border Bandwidth in CCN.
    Lighthouse does not support cross-border private network interconnection through associating CCN, even if cross-border bandwidth has been purchased for that CCN.
    Under the same account:
    All Lighthouse instances within the same region are housed within the same VPC. A single VPC can only be associated with one CCN simultaneously.
    Lighthouse instances in various regions reside in distinct VPCs, and each VPC must be independently associated with the CCN.
    If there are no Lighthouse instances in a given region, users cannot undertake the task of associating a CCN within that particular region.

    Operation Guide

    1. Log into the Lighthouse console and select Interconnection from the left-hand navigation bar.
    2. Select the region where your MySQL instance resides and apply for CCN Association.
    
    3. In the displayed CCN Association window, select Create CCN instance.
    
    4. Complete the creation of the CCN instance in the pop-up, return to the CCN association page in Lighthouse Interconnection, refresh to view the new CCN instance, and then click OK.
    Note:
    Only CCN under the same account can be associated.
    Upon submitting the association application, please log in to the CCN console within seven days to approve the application. Otherwise, the application expires after seven days and you need to submit a new association application.
    5. Log in to the CCN console, and click the ID/Name of the target CCN to navigate to its details page.
    6. On the CCN Details page, locate the row containing the association application and click Agree on the right side.
    By default, the Lighthouse VPC instance will be labelled as "Lighthouse VPC". Please ensure to make the correct selection.
    7. In the dialog box, add the VPC network address of the target MySQL, click on New Instance, choose the region, VPC, and then click Confirm.Then, on the intranet interconnection page, the status of this region will be displayed as "Connected".
    8. Navigate back to the Lighthouse console, refresh the intranet interconnection interface; a successful connection will be displayed.
    9. In the CCN console, click on the ID of the target CCN to enter the CCN details page to check whether the route is active. If any enabled route is found in a deactivated state, please activate it.
    10. In the Lighthouse console, locate the target Lighthouse, click Log in, choose password login, enter your username, port, and password, then click Log in once more.
    
    11. Upon successful login, run the following command to download and install MySQL.
    Method 1 (If Method 1 fails, proceed with Method 2):
    yum install mysql -y
    
    Method 2 (If Method 1 succeeds, you can ignore Method 2):
    Run the following command to download and install MariDB.
    yum -y install mariadb-server
    Upon successful installation, run the following command to start MariaDB. Then, you can use MySQL.
    systemctl start mariadb
    12. Run the following command to connect and log in to MySQL.
    mysql -h <internal IP address> -u <username, default is root> -P <port number, default is 3306> -p
    <Private network IP address>: Replace it with the private network address of your target MySQL instance, which can be viewed on the instance details page in the TencentDB for MySQL console.
    
    <Username, default is root>: Replace it with the account name of your target MySQL instance. The default account name is 'root'.
    
    <Private network port number>: Replace it with the private network port number of the target MySQL database instance. The default is 3306. If the port number has been changed, the new port number can be viewed on the instance details page in the TencentDB for MySQL console.
    
    13. Upon successful connection, the interface displays as follows:
    

    FAQs

    Do I have to pay for CCN connections?

    Yes. You should pay for CCN connections. For details, see CCN Billing Details.

    Under what circumstances should a CCN be used to connect to a MySQL?

    1. CCN can be used to connect to the database when the CVM and MySQL instances are in different VPCs, no matter under the same or different accounts, or in the same or different regions.
    2. If you have purchased a Lighthouse server, you can connect to the database only through CCN.

    How can private network interconnection be achieved when using Lighthouse instances?

    Lighthouse uses the VPC automatically assigned by Tencent Cloud for network isolation. By default, the private network does not interconnect with other Tencent Cloud resources in VPCs such as CVM and TencentDB. The interconnection can be implemented by associating with a CCN. For more information, please refer to Private Network Interconnection.
    Note:
    Lighthouse only supports associating with CCNs under the same account and does not support the association across different accounts.

    What is the service level of CCN?

    Tencent Cloud CCN offers three levels of availability: Platinum, Gold, and Silver.
    The service level for all intra-region instances is Gold, and cannot be modified.
    During cross-region intercommunication, three service levels—Platinum, Gold, and Silver—are available for you to choose from upon CCN creation. The costs differ with the service level. You can select the most suitable one based on your business requirements. For more information, see Pricing.

    How do I troubleshoot a CCN connection error myself?

    1. Check whether the route table for the CCN is valid by following the following steps:
    1.1 On the "Private Network Interconnection" page, click the "CCN ID" on the regional card to navigate to the details page of that CCN.
    1.2 On the CCN details page, select the Route Table tab.
    1.3 You need to ensure that the newly added route is marked as "Valid". If there are CIDR conflicts, the route could be invalid.
    Note:
    If you need to utilize an invalid route, see Disabling a Route and Enabling a Route. For Conflict rules and restrictions, see Route Limits.
    2. Upon logging in to Lighthouse, if you repeatedly fail to log into the cloud database via the command, you may need to check whether the username or password used for database access are correct.
    In the command line: mysql -h <private ip address> -u <username, default root> -P <port number, default 3306> -p, the account and password must be paired correctly. If you're logging in with a non-root account, then the password should also correspond to the non-root account. When entering your password in the Lighthouse interface, the password will not be displayed as you type. Enter it correctly all at once and press Enter. If you forget the password, you may reset the password and try again.
    3. Check whether there is an instance-related issue.
    If the MySQL instance disk is full, it may affect database connectivity. It's recommended to expand the disk capacity. For the procedure, please refer to Adjusting Database Instance Specification.
    When the error message "ERROR 1040(00000): Too many connections" is displayed, it indicates that the maximum number of connections for the current CDB instance has been reached. Common causes and solutions are as follows: i. If there are too many sleep threads, it's advised to decrease the values of the wait_timeout and interactive_timeout parameters via the console. For details, please refer to Setting Instance Parameters. ii. If there are few sleep threads and no slow query accumulation, it's suggested to increase the value of the max_connections parameter via the console. For details, please refer to Setting Instance Parameters.
    Check whether the MySQL instance is in a "master-slave switch state", as connection attempts will fail if the MySQL instance is in the middle of a master-slave switch. After the switch has completed, connect using the command again.
    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support