You can access the tutorial artifact, including the deployment script (Terraform), related source code, sample data, and instruction guidance from this GitHub project.
For more tutorials about Alibaba Cloud Database, please refer to this link.
Database Deployment Tutorials Series: https://community.alibabacloud.com/series/118
This is a demo of building an interactive Game of Thrones (https://github.com/andi1991/Atlas-Of-Thrones) map powered by Leaflet, PostgreSQL/PostGIS, and Redis on Alibaba Cloud.
Deployment architecture:
Run the Terraform script. Please specify the necessary information and region to deploy it.
After the Terraform script execution is finished, the ECS instance information is listed as below:
eip_ecs
: The public EIP of the ECS for game map application hostrds_pg_url
: The connection endpoint URL of the RDS PostgreSQL databaserds_pg_port
: The connection endpoint port of the RDS PostgreSQL databaseredis_url
: The connection endpoint URL of the RedisClick Elastic Compute Service
, as shown in the following figure:
We can see one running ECS instance in the China (Hong Kong) region.
Copy this ECS instance's Internet IP address and log on to this ECS (Ubuntu system) instance remotely. For more details about remote login, please refer to login.
The default account name and password of the ECS instance:
Account name: root
Password: Aliyun-test
After logging in successfully, enter the following command to download the pre-prepared data script:
wget https://cdn.patricktriest.com/atlas-of-thrones/atlas_of_thrones.sql
Enter the following command to install the PostgreSQL client:
apt update && apt -y install postgresql-client
Enter the following command to connect to the PostgreSQL instance. Please pay attention and replace YOUR-POSTGRESQL-ADDRESS with the connection address of the user's PostgreSQL instance:
psql -h YOUR-POSTGRESQL-ADDRESS -p 5432 -U patrick -d atlas_of_thrones
Password: the_best_passsword
Enter the following command to install the PostGIS extension. If the prompt already exists, it doesn’t matter; proceed to the following operations directly:
CREATE EXTENSION postgis;
Enter the following command to exit the client:
\q
Enter the following command, and load the downloaded SQL dump into your newly created database. Please pay attention and replace YOUR-POSTGRESQL-ADDRESS with the connection address of your PostgreSQL instance:
psql -h YOUR-POSTGRESQL-ADDRESS -p 5432 -U patrick -d atlas_of_thrones < atlas_of_thrones.sql
Password: the_best_passsword
Enter the following command to log in to the "atlas_of_thrones" database. Please pay attention and replace YOUR-POSTGRESQL-ADDRESS with the connection address of the user's PostgreSQL instance:
psql -h YOUR-POSTGRESQL-ADDRESS -p 5432 -U patrick -d atlas_of_thrones
Password: the_best_passsword
Enter the following command to get a list of available tables:
\dt
Enter the following command to inspect the schema of an individual table by running:
\d kingdoms
Enter the following command to query data:
SELECT name, claimedby, gid FROM kingdoms;
Enter the following command to exit the client:
\q
Enter the following command to download the Nodejs installation package:
wget http://labex-ali-data.oss-us-west-1.aliyuncs.com/nodejs/node-v12.13.0-linux-x64.tar.xz
Enter the following command to decompress the installation package:
tar -xf node-v12.13.0-linux-x64.tar.xz
Enter the following command to move the unzipped directory to the "/usr/local" directory:
mv node-v12.13.0-linux-x64 /usr/local/node
Enter the command: vim /etc/profile
and add the following content to the file:
export NODE_HOME=/usr/local/node
export PATH=$PATH:$NODE_HOME/bin
Enter the following command to make the modification effective:
source /etc/profile
Enter the following command to view the installed version, indicating that the installation is complete:
node -v
npm -v
Enter the following command to install the Git tool:
apt -y install git
Enter the following command to download the project:
git clone -b labex https://github.com/andi1991/Atlas-Of-Thrones.git
Enter the following command to enter the project directory:
cd Atlas-Of-Thrones
Enter the command: vim .env
, copy the following content to the file. Please pay attention and replace YOUR-POSTGRESQL-ADDRESS 、YOUR-REDIS-ADDRESS with the connection address of your instance:
PORT=5000
DATABASE_URL=postgres://patrick:the_best_passsword@YOUR-POSTGRESQL-ADDRESS:5432/atlas_of_thrones?ssl=false
REDIS_HOST=YOUR-REDIS-ADDRESS
REDIS_PORT=6379
CORS_ORIGIN=http://localhost:8080
Enter the following command to install related dependencies:
npm install
Enter the following command to install the dependent package that reported the error separately.
npm cache clean --force
npm i --unsafe-perm node-sass@4.14.1
Enter the following command to start the service:
npm run dev
Access the service in the browser and enter the link below. Please pay attention and replace YOUR-ECS-PUBLIC-IP with the user's ECS public IP address:
YOUR-ECS-PUBLIC-IP:8080
Game map service deployment is completed.
Best Practices for Setting the Parameter performance_schema: Overview
Deploy Application Stack Parse Server with MongoDB on Alibaba Cloud
Alibaba Clouder - March 19, 2019
Alibaba Clouder - March 22, 2019
Alibaba Clouder - March 18, 2019
digoal - December 18, 2020
Michelle - August 1, 2018
JJ Lim - December 6, 2021
Alibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.
Learn MoreAlibaba Cloud’s world-leading database technologies solve all data problems for game companies, bringing you matured and customized architectures with high scalability, reliability, and agility.
Learn MoreWhen demand is unpredictable or testing is required for new features, the ability to spin capacity up or down is made easy with Alibaba Cloud gaming solutions.
Learn MoreA key value database service that offers in-memory caching and high-speed access to applications hosted on the cloud
Learn MoreMore Posts by ApsaraDB