Hi everyone welcome to the fourth chapter in our Tencent Cloud Developer Associate course, cloud application development. At the end of this chapter, you'll be able to use TencentDB for MySQL. Implement, read and write separation with TencentDB for MySQL. Use TencentDB for MongoDB and use Cloud Object Storage, COS. In this chapter we'll cover three sections TencentDB for MySQL, TencentDB for MongoDB and COS. Let's get started with section 1, overview of Tencent Cloud. In this video, we'll cover an overview of databases, TencentDB for MySQL, data migration and read and write separation. First, let's take a look at an overview of databases. Databases can generally be categorized according to its data organization or structure. If we categorize according to data organization, databases can be separated into relational and non-relational. A relational database is a type of database that uses a relational model to organize data, whereas a nonrelational database uses key value pairs to store data. The data organization of relational databases consists of two dimensions, the dimensional tables and their connections. In terms of database architecture, databases can be divided into centralized databases and distributed databases. For centralized databases data storage is physically separated from data processing and disaster recovery can be achieved by mirroring. For instance, distributed database systems usually use smaller computer nodes. Each computer has individual local databases and computers are connected to each other through a network to form a complete system. For centralized databases Tencent Cloud mainly offers TencentDB for MySQL and TencentDB for Redis. In particular TencentDB for MySQL supports solid state drive, SSD storage. MySQL, SQL server and the Tencent distributed SQL TDSQL engine which is compatible with MariaDB. Compared with traditional databases TencentDB is easier to deploy, manage and expand since it provides a full range of database solutions, including disaster recovery, backup monitoring and migration. For distributed databases Tencent Cloud provides TDSQL for MySQL, TencentDB for MongoDB, HBase, TID B and TData. First, TDSQL is a high performance distributed database architecture that supports automatic horizontal scaling, whereas traditional databases only allow for vertical scaling. Second as a no SQL database MongoDB provides stable monitoring management and features high flexibility and automatic disaster recovery. Third, HBase is a non relational distributed database for data analysis with high performance and scalability. Fourth, TiDB is another distributed database based on the popular open source TiDB. Fifth TData is Tencents private cloud data system designed for clients. In addition, Tencent Cloud also offers data transfer service DTS for data migration, synchronization and data replication. It is an excellent toolkit to use to migrate data to the cloud or replicate data between databases. As mentioned TencentDB is a relational database cloud service provided by Tencent cloud based on SSD storage. It supports TencentDB for my SQL, Tencent DB for SQL server, TDSQL and TencentDB for PostgreSQL. TencentDB provides a very robust performance of up to 245,509 queries per second. Q P s. In terms of features, Tencent D B provides cloud services for relational databases, supports data migration via D T S and provides command line and web management consoles. It also provides enterprise level high availability including multi availability zone disaster recovery, cold backup, real time hot backup and automatic downtime detection. Data reliability in case of disasters is greatly enhanced. Since the data is saved through multiple backup mechanisms, data is automatically backed up daily and my SQL can roll back to any point in time in the Past three days based on the backup files. Lastly. Tencent DB also supports automatic downtime detection and fail over so that the switch and fail over processes are totally transparent to the users. Okay, let's move on and discuss 10 cent dB for my SQL. Tencent dB for my SQL makes it easy for you to deploy and use the my SQL database, one of the world's most popular open source relational databases in the cloud. 10 cent dB for my SQL is very cost efficient and flexible. It only takes minutes to deploy a scalable. My SQL database instance and you can resize your hardware capacity without shutting down your machines as mentioned. Tencent DB for my SQL comes with a full set of streamlined database operations solutions with very high performance. It's Colonel optimization. Primary and secondary synchronization and multithreaded optimization helps solve the bottleneck problem of synchronous performance between databases for disaster tolerance. It minimizes data risk by supporting multi availability zones and cross city disaster recovery and hot and cold backup as well. in terms of security monitoring. 1st 10cent DB for my SQL provides multiple layers of security protection for each database by default. When a database instance that can be accessed from a public network is under distributed denial of service. DDOS attacks. The attack traffic can be filtered out to ensure normal business operations. Database attacks such as SQL injections and brute force attacks can be fended off to minimize business interruptions and losses caused by those attacks. Second, you can run your database instances in virtual private cloud VPc which enables you to isolate database instances and connect them to your current I D C s via industry standard encrypted internet protocol security via industry standard encrypted Internet protocol security. VPN or direct connect 3rd. 10 cent DB for my SQL also supports granular permission control for the administrator accounts. To eliminate security risks. Various permission controls on the object levels such as tables functions and storage processes are offered restricting your allocated accounts access to only authorized resources and keeping the risks under control. Tencent dB for my SQL has four advantages compared with self built databases. First, you can manage massive databases with ease. 2nd. Tencent DB for my SQL supports automatic data import back up and roll back Third, it provides multidimensional monitoring and alarms, allowing you to set custom resource threshold alerts and perform query analysis. Lastly, it supports a wide variety of connection methods, including out of network access and VPC networks that connect cloud databases to your i D c. S, and private clouds. To illustrate the use cases of Tencent dB. For my SQL, let's take a look at an e commerce example. As the chart shows, cloud load balancer CLB provides service integration through CVM with the database support from TencentDB in the back end. In e-commerce use cases, TencentDB for MySQL offers high performance and fast Redis reads and writes, allowing you to handle high concurrency access traffic and business peaks during sales and marketing campaigns with ease. There are several other advantages of using TencentDB for MySQL in place of self built MySQL. First, you can reduce your costs without having to pay for the overhead cost of the underlying infrastructure. Instead, you can pay on demand with reduced costs and better performance since the storage devices use the powerful non volatile memory express and VME protocol and therefore have better storage capability. Second, TencentDB for my SQL also supports data backup and encryption for enhanced security. Third, it is also highly available and reliable. The process of using TencentDB for MySQL involves the following steps. First, log into Tencent cloud, then purchase Tencent DB for MySQL, initialize the database and migrate your local data to it. If you don't have any data to migrate, you can build a database from scratch and configure its schema. Next,you need to modify the application configuration and finally deploy the application for access. This is the user interface you'll see when you go through the process. You can log into TencentDB from the console and click the create button to enter the purchase page. It displays multiple different regions you can access to create your instances. Okay, now enter the initial configuration information to initialize the database and then click OK to begin the initialization. You can configure the supported character set by selecting a character set supported by the MySQL database. You can also configure the table name, case sensitivity and change the default custom ports as you need. Then you need to set the password of the root account and confirm the password. If your cloud servers are deployed on the same region as your cloud database, you don't need to request an off grid address. Otherwise you need to turn on and off your off grid address to connect with Tencent cloud which will be your public network address. However, note that enabling the public network address for your database may cause security issues. So you need to put in place additional protections against the public network, especially when there is sensitive data in your database. There are two billing modes for TencentDB for MySQL, monthly subscription and pay as you go. We recommend the monthly subscription billing mode for mature businesses that are stable since the billing mode lowers the costs for the business in the long term. In contrast, pay as you go is more suitable for businesses that are less stable. As a review of what you've learned in this subsection, let's go over the following reflection questions. What are the different types of TencentDB products? What are the strengths of TencentDB for MySQL? What are the use cases of TencentDB for MySQL? What are the common APIs of TencentDB for MySQL? What are the steps of using TencentDB for my SQL? Can the public network access be enabled for TencentDB for MySQL? You can pause the video for a few minutes and think about how you would answer these questions. Let's take a look at some common issues with data migration. Your service downtime may interrupt the progress of your data synchronization and lead to incomplete data. If the amount of data is large, the migration will be time consuming, making it more likely for such problems to occur during migration. So, how can you mitigate failures during data migration? Since migrating a large amount of data is time consuming and prone to errors, you have to plan your data migration solution ahead of time. Here, we focus on how MySQL files are imported and migrated online. SQL file import is suitable for small amounts of data, such as when each file does not exceed two gigabytes. For online data migration, you can use DTS for real time nonstop synchronization. And when you restore a database offline, we recommend using MySQL command lines to restore your data through backup files. SQL file import involves the following five steps. First, you need to enter the management page of the corresponding database instance and then select the SQL file to be imported. Next, select the target database and confirm the data import. Lastly, you can complete the data import and access the database. When the initialization of the database is complete, you can select the database management tab and click the data import button in the console. You can also choose data transfer service, DTS to input the data and support the database. DTS supports continuous data migration and replication from yourself built MySQL databases on public networks with public IPs. Self built databases connected to Tencent cloud through VPN or direct connect lines and self built databases on cloud virtual machine. It can be accessed through multiple network environments such as public networks, VPNs and direct connect lines. And covers main data migration links from local IDCs to the cloud, helping you easily build a hybrid cloud environment for real time data synchronization. DTS is currently available in international regions free of charge. And you can reach out to our technical support team and customer support when you encounter any issues. You can easily set up data migration through DTS in just a few simple steps. During the migration process, the replication of incremental data updates ensures the consistency of migrated data, allowing the source database to continue providing services externally and minimizing the impact of the clarification process on your business. DTS can also provide disaster recovery sink for disaster recovery instances in the cloud database, which allows for mutual redundancy between data centers in different regions. When a data center is faulty or fails to provide services due to force majeure, another data center can quickly take over. The optimization of database replication via DTS significantly reduces synchronization delays and minimizes the risk of data loss resulting from sync delay and disasters. Using DTS to import data online requires the following six steps. First, enter the DTS console to select a linkage region for free migration. Then select the source and target databases and select the type and database list. Next, you can check the task and complete the data migration. This screenshot shows the DTS page where you can click on data migration and create the database migration task. The migration process has been completed after it has been configured. But if the migration is in the not completed status, both the migration task and data sync will continue. After the migration is 100% completed, you can click complete on the right to complete the migration task. As a review of what you've learned in this section, let's take a look at the following reflection questions. What are the common solutions for data migration to TencentDB for MySQL. What are the basic steps for using DTS for data migration. Can DTS only be used for data migration to TencentDB for MySQL? You can pause the video for a few minutes and think about how you would answer these questions. Okay next, let's move on to read and write separation. For many large websites,70% of the businesses handled our operations related to query and select such as inserting news and querying operations for news websites. And the rest of the business is right operations, such as inserting, updating and deleting. As long as the operations can change the MySQL data, they can be called write operations. After using the load balancing cluster. The overall performance of the website can be greatly improved but the final data processing pressure will still fall on the MySQL database. Therefore some techniques need to be used to improve the load capacity of MySQL. This technique is called read and write separation. Here's an overview of read and write separation. Read and write separation works by letting the source database perform transactional operations such as insertion, update and deletion. And letting the replica database perform select query operations. Database replication is used to sync changes caused by transactional operations to the replica database in the cluster. For instance, if you write to your primary database you can synchronize the updates by inserting updating or deleting from your primary database to your secondary database. And the read can take place in the secondary database? In this way you can separate the read and write and your different types of transactions can be optimized. Okay next let's take a look at the concept of the read only database. Which is a replica of your primary database. TencentDB for MySQL allows you to create one or more read only instances. Which are suitable for read and write separation and one source multiple replica use cases. Read only instances are also capable of greatly enhancing the reload capacity of your database. For example when you import data or export to your data warehouse you can pull the data from your read only database without having to change your primary database. TencentDB for MySQL currently supports the automatic separation of read and write requests. So read only instances need to be accessed with separate IPs and ports. Since all read only instances have single node architecture, repeated attempts to restore a failing read only instance will be made. Therefore we recommend you choose a read only group over a read only instance for higher availability. A read only group consists of one or more load balancing enabled read only instances. And provides IPs and ports for access to databases. In terms of the steps for using a read only instance you will first enter the instance details page, select a cloud database that needs to be created as read only and then click add read only instance. Then you will be automatically redirected to the read only instance, list page. After the replica is created successfully. You can view its architecture next you can go to the purchase page and select the appropriate configuration for the cloud database read only instance. After confirming that it is correctly configured, click buy now to purchase the instance. Here are step by step instructions to implement read and write separation. First, you need to purchase a TencentDB for MySQL instance. And then create a read only instance. The next step is to modify the applications, data source configuration and modify the code to support read and write separation. After re compiling and deploying the application, you will be ready to verify the effect. How does the architecture change after the introduction of TencentDB for MySQL and read and write separation? Here we take the book management system as an example which uses CLB and CVM clusters based on scaling. As you can see this system queries read only instances on the back end. However, when you add delete or modify the data changes take place in the primary database and are automatically synchronized to the read only instances. By configuring read only instances in this manner, you can greatly improve the read load capacity and adapt the product to scenarios where there are more reads than writes. As a review of what you've learned in this section let's take a look at the following reflection questions. Why do we need to implement read and write separation? What is the relationship between TencentDB for MySQL read only instances and read and write separation? What are the basic steps of using TencentDB for MySQL to implement read and write separation? You can pause the video for a few minutes and think about how you would answer these questions.