You can access the tutorial artifact including deployment script (Terraform), related source code, sample data and instruction guidance from the github project: https://github.com/alibabacloud-howto/solution-online-leaderboard-redis
More tutorial around Alibaba Cloud Database, please refer to: https://github.com/alibabacloud-howto/database
https://github.com/alibabacloud-howto/solution-online-leaderboard-redis
If you are the 1st time to use Terraform, please refer to https://github.com/alibabacloud-howto/terraform-templates to learn how to install and use the Terraform on different operating systems.
Use terraform to provision ECS and Redis instances that used in this solution against this .tf file: https://github.com/alibabacloud-howto/solution-online-leaderboard-redis/blob/main/deployment/terraform/main.tf
For more information about how to use Terraform, please refer to this tutorial: https://www.youtube.com/watch?v=zDDFQ9C9XP8
In the file: https://github.com/alibabacloud-howto/solution-online-leaderboard-redis/blob/main/deployment/terraform/main.tf If you do not specify the provider parameters in the environment, please set your Alibaba Cloud access key, secret key here.
provider "alicloud" {
# access_key = "${var.access_key}"
# secret_key = "${var.secret_key}"
region = "ap-southeast-1"
}
- Get the EIP of the ECS, and then logon to ECS via SSH. Please use the account root/N1cetest, the password has been predefined in Terraform script for this tutorial. If you changed the password, please use the correct password accordingly.
ssh root@<EIP_ECS>
- Run the following command to install required utilities on the instance, including JDK and Maven:
sudo apt-get update
sudo apt-get install openjdk-8-jdk
apt install maven
- Run the following command to download and untar the source code of the demo:
wget https://github.com/alibabacloud-howto/solution-online-leaderboard-redis/raw/main/source.tar.gz
tar xvf source.tar.gz && cd source
- Vim to modify the Java code to replace the Redis access endpoint URL and password accordingly in the Step 1.
vim src/main/java/test/GameRankSample.java
- Build the source code and package, then run the demo:
mvn clean package assembly:single -DskipTests
java -classpath target/demo-0.0.1-SNAPSHOT.jar test.GameRankSample
Running result: