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
Step Two: Start Building
First log in to the account, and then click the first month one-yuan trial as shown below
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
Step 4: Check the service agreement
Check the service agreement, click to pay, and start a 1 yuan trial.
Step 5: The cluster is built successfully
Click Admin Console to get started. Note: It takes 10-15 minutes to open successfully
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
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
- Click the cluster ID as shown in the figure.
2. In the left navigation bar, click Configuration and Management > Cluster Whitelist .
3. On the cluster whitelist page, you can add an IP whitelist group or configure an existing whitelist.
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 .
Step 9: Create a database high-privilege account
- Go back to the PolarDB console .
- In the upper left corner of the console, select the region where the cluster is located.
- Find the target cluster and click the cluster ID.
- In the left navigation bar, select Configuration and Management > Account Management .
- Click Create Account .
- In the account creation panel, set the following parameters and click OK:
Step 10: Apply for a public network address
- Log in to the PolarDB console .
- In the upper left corner of the console, select the region where the cluster is located.
- Find the target cluster and click the cluster ID.
- 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 .
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.
- Log in to the PolarDB console .
- In the upper left corner of the console, select the region where the cluster is located.
- Find the target cluster and click the cluster ID.
- 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
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.
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
-
qualified for trial
Click to enter the Alibaba Cloud Product Trial Center , select the product in the picture below, and click Trial for 30 days.
-
Click to enter the ecs homepage without trial qualification , click to buy now as shown in the picture below, and the cost is about 0.08 yuan.
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:
select any image + high-efficiency cloud disk 40g as shown in the figure below, and then click Next
Step Two: Select a Network and Security Group
Choose to set the usage traffic to 80M, and click to confirm the order.
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.
Step 4: Set up security groups
As shown in the figure, enter the security group page
and click on the configuration rules
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
and release the port number 80 (the changed Tomcat port number) to the entrance:
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
, select reset system and mirror,
click to select the operating system from the mirror market as shown in the figure
, 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.
Set a custom password and confirm the order
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.
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.
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:
the test success interface is as follows:
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.
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.
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.