Quickly deploy projects to the cloud, and take you to play with ECS and PolarDB

Project cloud

The coding test of the website has been completed in the early stage, so how to deploy the project to the cloud server? This blog takes Alibaba Cloud Server ECS and PolarDB as examples, follows the principle that pictures are better than text, and explains how to quickly migrate projects to the cloud. It can be called a nanny-level tutorial, teaching you to deploy projects step by step, and play with cloud databases and cloud servers at the same time. Xiaobai can also get started quickly, so don't talk nonsense, just come to practice directly, hoping to help someone who is destined.

Chapter 1 Cloud Database Construction

Step 1: Enter the official website

click to enter

Step Two: Start Building

First log in to the account, and then click the first month one-yuan trial as shown below

insert image description here

Step 3: Adjust configuration

New users can try 2-core 8G for one month for 1 yuan, as shown in the picture, click to buy now

insert image description here

Step 4: Check the service agreement

Check the service agreement, click to pay, and start a 1 yuan trial.

insert image description here

Step 5: The cluster is built successfully

Click Admin Console to get started. Note: It takes 10-15 minutes to open successfully

[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-6xCeMT0p-1627959671000)(../Typora/Typora-images/image-20210723160705376.png)]
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-HSBrRtWr-1627959671003)(../Typora/Typora-images/image-20210723160730145.png)]

Step 6: Enter the console

Switch to the regional console as shown in the figure, and you can observe the list of database clusters being created

[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-p7VlFx0v-1627959671004)(../Typora/Typora-images/image-20210723160813912.png)]

Step 7: Set the cluster whitelist

You need to set the IP whitelist of the cluster and create the initial account of the cluster before you can connect and use the cluster

  1. Click the cluster ID as shown in the figure.
    image-20210723160913213.png
    2. In the left navigation bar, click Configuration and Management > Cluster Whitelist .
    insert image description here
    3. On the cluster whitelist page, you can add an IP whitelist group or configure an existing whitelist.
    [External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-OJK1D3tN-1627959671005)(../Typora/Typora-images/image-20210723161252785.png)]
    4. Click Add IP Whitelist Group .
    In the Add IP whitelist group panel, enter the group name and the IP whitelist addresses that are allowed to be accessed.
    The IP address in the white list includes: the IP address of your own computer, the public IP address of the cloud server (it will be mentioned later when deploying the cloud server). The way to obtain the

    IP address of your computer is to enter the IP in Baidu.

Step 8: Set up the cluster security group

If there is no optional security group, please skip this step for now

On the Cluster Whitelist page in Step 7 , click the Configure button in the Select Security Group or Target Security Group action bar to change the security group settings. In the pop-up Select Security Group panel, select the target security group and click OK .
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-hiQAFJ3I-1627959671007)(../Typora/Typora-images/image-20210723161550059.png)]

Step 9: Create a database high-privilege account

  1. Go back to the PolarDB console .
  2. In the upper left corner of the console, select the region where the cluster is located.
  3. Find the target cluster and click the cluster ID.
  4. In the left navigation bar, select Configuration and Management > Account Management .
  5. Click Create Account .
  6. In the account creation panel, set the following parameters and click OK:
    [External link image transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the image and upload it directly (img-49J7CrMf-1627959671008)(../Typora/Typora-images/image-20210723161727601.png)]

Step 10: Apply for a public network address

  1. Log in to the PolarDB console .
  2. In the upper left corner of the console, select the region where the cluster is located.
  3. Find the target cluster and click the cluster ID.
  4. In the link address area of ​​the basic information page , click the icon in the upper right corner to switch views. Click Apply . In the displayed dialog box, set the connection address prefix and click OK .
    [External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-2D3B4R1B-1627959671010)(../Typora/Typora-images/image-20210723162134327.png)]

Step 11: Use DMS to connect to the cluster

DMS is a graphical data management tool provided by Alibaba Cloud. It is a data management service that integrates data management, structure management, access security, BI charts, data trends, data traces, performance and optimization, and server management. It supports the management of relational databases (MySQL, SQL Server, PostgreSQL, etc.) and NoSQL databases (MongoDB, Redis, etc.), and also supports Linux server management.

  1. Log in to the PolarDB console .
  2. In the upper left corner of the console, select the region where the cluster is located.
  3. Find the target cluster and click the cluster ID.
  4. In the upper right corner of the basic information page, click Login Database . In the pop-up dialog box, enter the database account and database password
    [External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-N2dFAdJd-1627959671011)(../Typora/Typora-images/image-20210723162410623.png)]
    created in the PolarDB MySQL cluster , and click Login . Note: Remember the database account and password, which will be used later. 1. After logging in, click to authorize to authorize. 2. Click the logged-in instance . In the list of logged-in instances , click the name of the target cluster, find and double-click the name of the target database to switch to the target database for management.




    [External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-4iK48TMp-1627959671013)(../Typora/Typora-images/image-20210723162547132.png)]

Step 12: Create a database

1. Right-click the logged-in instance name and select Database Management

2. Click Create Library

3. Enter the database name and click OK

Step Thirteen: Import Data

Just import the SQL file

other (no action required)

Supports main address links and cluster address (recommended) links, the differences are as follows

  • Cluster address and master address
address type address description Supported Network Types
Cluster address (recommended) Applications only need to connect to a cluster address to connect to multiple nodes. With the read-write separation function, the write request will be automatically sent to the master node, and the read request will be automatically sent to the master node or read-only node according to the load of each node. Explain that PolarDB includes a default cluster address, and you can also create multiple custom cluster addresses according to business needs. The custom cluster address can be connected to a specified node, and set the read-write mode, etc. For details, see Modifying and releasing cluster addresses . Private network Public network Private network (classic network)
primary address Always connected to the master node, supports read and write operations. When the master node fails, the master access address will automatically switch to the new master node.
  • Private network address and public network address
Network Type illustrate scenes to be used
private network The best performance of PolarDB can be exerted by accessing the connection address of the private network. When creating a cluster, a private network connection address is generated by default. This address supports modification but cannot be released. For how to modify it, see Modifying the connection address and port . For example, if the ECS and the database cluster are located in the same VPC, then the ECS can access the database cluster through the private network address. Use DMS to access the database cluster through VPC
public net You can apply for or release a connection address of the public network. For details, see Applying for a connection address and releasing a connection address . The public network is the Internet, accessing through the public network will not achieve the best performance of PolarDB. For example: Access the database cluster through the public network for maintenance operations.
Private network (classic network) You can apply for or release a private network (classic network) connection address. For details, see Applying for a connection address and releasing a connection address . Clusters are not isolated through the network, and can only rely on the whitelist policy of the cluster itself to block illegal access. For details, see Setting the cluster whitelist . Only when the business is in the classic network, the database cluster can be accessed through the private network address (classic network).

If you have reached this point, congratulations, you have completed the construction of the cloud database, and let's start to build the Alibaba Cloud server.

Chapter 2 Cloud Server Construction

2.1 URL entry built by the server

2.2 Start building

For trial students, please select the trial specification and any image, and then jump to step 3

Step 1: Select the basic configuration

When purchasing, select pay-as-you-go as shown in the figure, select cpu and memory:
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-JSWSlzf0-1627962119907)(../Typora/Typora-images/image-20210723192829267.png)]
select any image + high-efficiency cloud disk 40g as shown in the figure below, and then click Next
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-XvCHN1aq-1627962119909)(../Typora/Typora-images/image-20210723192924510.png)]

Step Two: Select a Network and Security Group

Choose to set the usage traffic to 80M, and click to confirm the order.
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-LzxJxM8e-1627962119910)(../Typora/Typora-images/image-20210723193044361.png)]

Step 3: Jump to the management console page

Page address: Click to enter , select the geographical location of the server for trial or purchase, and the rendering effect is as shown in the figure below.
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-v8XnadTh-1627962119913)(../Typora/Typora-images/image-20210723193143250.png)]

Step 4: Set up security groups

As shown in the figure, enter the security group page
[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-Bg1fVQpH-1627962119914)(../Typora/Typora-images/image-20210723193637519.png)]
and click on the configuration rules
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-m9fgwroE-1627962119916)(../Typora/Typora-images/image-20210723193722622.png)]
as shown in the figure below to release port 8888 (the default port of the pagoda) for your ip. What is a pagoda is not the pagoda of the pagoda town river demon. It will be mentioned later. Then Baidu enters the ip to get the computer ip
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-dyIKEIN6-1627962119918)(../Typora/Typora-images/image-20210723194336358.png)]
and release the port number 80 (the changed Tomcat port number) to the entrance:
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-sM0uwEXE-1627962119919)(../Typora/Typora-images/image-20210723194428629.png)]

Step Five: Reset the OS and Image

Go back to the console page, page address: click to enter . Then close the server as shown in the figure
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-GwGffS7O-1627962119920)(../Typora/Typora-images/image-20210723194524068.png)]
, select reset system and mirror,
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-YBWBYdbG-1627962119921)(../Typora/Typora-images/image-20210723194953174.png)]
click to select the operating system from the mirror market as shown in the figure
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-HJZ8PAEV-1627962119923)(../Typora/Typora-images/image-20210723195035108.png)]
, select pagoda, the pagoda control panel is a linux server management software, you can use this management tool to build an environment and install programming software.
[External link image transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the image and upload it directly (img-x6KYaTUD-1627962119924)(../Typora/Typora-images/image-20210723195113238.png)]
Set a custom password and confirm the order
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-rrDDD1S5-1627962119925)(../Typora/Typora-images/image-20210723195154338.png)]

Step 6: Connect to the server to obtain the initial information of the pagoda

Click Remote Connection, enter the user name and password, click OK, enter: bt default, press Enter, the pagoda interface address, user name, and password will be generated, access this address through Baidu, enter the login interface, enter the user name and password (generated) to proceed Log in.
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-Bhk8tFme-1627962119926)(../Typora/Typora-images/image-20210723195224876.png)]

Step 7: Set up the server environment

After entering the pagoda control panel, enter the software store, search for tomcat and click install, select tomcat9 version, after installation, search for tomcat as shown in the figure, and set the port number to 80, then restart.
[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-JTLd5wUc-1627962119928)(../Typora/Typora-images/image-20210723195310304.png)]

Step 8: Deploy the project

After tomcat is installed, visit: http://public network ip, if the tomcat interface appears, it means the installation is successful.
The public network ip is as follows:
insert image description here
the test success interface is as follows:
insert image description here

Click to enter the folder where tomcat is installed, and enter the webapps folder, clear the contents of the ROOT folder in webapps, and upload the project to ROOT.

Chapter 3 project released and launched

Modify the database information of the configuration file,
mainly including the database ip address and port, user name, password, and database name.
insert image description here
How to obtain the database address?
Go to the cloud database console, click on the basic information , copy the public network address of the cluster address , if not, you can create a custom address, and then obtain it.
insert image description here

Chapter 4 Global Thousand Cities Optimization Acceleration (Optional)

Requirement: Accelerate the website

Technology: Alibaba Cloud—Site Accelerated DCDN

Prerequisite: domain name required

On the basis of providing CDN static acceleration, DCDN further provides dynamic acceleration, TCP/UDP four-layer acceleration, WebSocket acceleration and other capabilities to comprehensively improve the network experience of websites and APPs; at the same time, you can quickly integrate security, edge computing and other capabilities To 2800+ edge nodes around the world.


At this point, your website can be officially launched. If you encounter any problems during the deployment process, please leave a message in the comment area, and the blogger will answer you as soon as possible.

Guess you like

Origin blog.csdn.net/weixin_44490884/article/details/119345624