Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

2021-2022 Huawei ICT Competition

Global Finals

Cloud Track Exam

Hands-on Practice

Huawei Technologies CO., LTD.


All Rights Reserved
2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Contents

1 Background of Task Design ................................................................................................. 3


2 Exam Description .................................................................................................................... 3
2.1 Weighting ...................................................................................................................................................................... 3
2.2 Exam Requirements ................................................................................................................................................... 3
2.3 Exam Platform ............................................................................................................................................................. 3
2.4 Saving Tasks ................................................................................................................................................................. 4

3 Exam Questions ...................................................................................................................... 4


3.1 Cloud Services .............................................................................................................................................................. 4
3.1.1 Scenarios ............................................................................................................................................................. 4
3.1.2 Network Topology ........................................................................................................................................... 4
3.1.3 Exam Requirements ........................................................................................................................................ 5
3.1.4 Exam Resources ................................................................................................................................................ 5
3.1.5 Exam Tasks ......................................................................................................................................................... 7
3.2 Storage .........................................................................................................................................................................18
3.2.1 Scenarios ...........................................................................................................................................................18
3.2.2 Network Topology .........................................................................................................................................19
3.2.3 Exam Requirements ......................................................................................................................................19
3.2.4 Exam Resources ..............................................................................................................................................19
3.2.5 Exam Tasks .......................................................................................................................................................20
3.3 Big Data .......................................................................................................................................................................24
3.3.1 Scenarios ...........................................................................................................................................................24
3.3.2 Exam Requirements ......................................................................................................................................24
3.3.3 Exam Resources ..............................................................................................................................................24
3.3.4 Exam Tasks .......................................................................................................................................................25
3.4 AI ....................................................................................................................................................................................33
3.4.1 Scenarios ...........................................................................................................................................................33
3.4.2 Exam Requirements ......................................................................................................................................33
3.4.3 Exam Resources ..............................................................................................................................................34
3.4.4 Exam Tasks .......................................................................................................................................................34

2022-06-17 Huawei confidential. No spreading without permission. Page 2 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

1 Background of Task Design


A city designs its smart city platform on Huawei Cloud using ICT such as big data, cloud
computing, and storage. After deploying its information infrastructure, the city aims to
converge data of different applications for its long-term plans.

The smart city platform must provide data analysis and AI processing, including the following
features:

1. Quick data upload, sharing, and storage in the cloud.


2. Persistent storage and remote replication DR for data security and reliability.
3. The collection, processing, storage, and analysis of massive amounts of unstructured and
structured data for pandemic prevention.
4. AI data processing and analysis for informed decision-making.

In this exam, use Huawei Cloud to build an architecture of cloud services, storage, big data,
and AI for a smart platform with these features.

2 Exam Description

2.1 Weighting
The exam consists of four parts: Cloud Services, Storage, Big Data, and AI. There are 1,000
points possible in this exam.

Domain Weight Points

Cloud Services 45% 450

Storage 20% 200

Big Data 20% 200

AI 15% 150

2.2 Exam Requirements


 Read the Exam Guide and exam tasks carefully before taking the exam.
 If multiple solutions are available for a task, select the best one.
 Set the password of all resources in the exam to ict2022@ICT##.

Note: Follow the instructions as written to avoid being penalized.

2.3 Exam Platform


The lab exam environment is Huawei Cloud official website:
https://www.huaweicloud.com/intl/en-us/

2022-06-17 Huawei confidential. No spreading without permission. Page 3 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

 The exam account and password have been sent to your Email. For how to log in, see the
Exam Guide.
 Cloud resources needed for the exam are already available. You will be informed of any
resources you will need to purchase on your own. When purchasing any resources, select
Pay-per-use for Billing Mode.
 After completing operations on the ECS, do not stop the ECS.
 If resources of a required flavor are sold out, purchase resources of a similar flavor.

2.4 Saving Tasks


Take full screenshots of task results. After completing the tasks, do not release the cloud
service resources of this account. For details, see the Exam Guide.

3 Exam Questions
3.1 Cloud Services
3.1.1 Scenarios
A user deploys a WordPress website on Huawei Cloud in pursuit of website auto scaling,
operation log audit, data backup and migration.

Design an appropriate solution for this scenario and complete the following lab tasks.

3.1.2 Network Topology

2022-06-17 Huawei confidential. No spreading without permission. Page 4 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

In this experiment, the environment is as follows:

The enterprise environment is established in AZ 1 of the Huawei Cloud Hong Kong region,
and an Elastic Cloud Server (ECS) is used to set up the WordPress website. Distributed
Database Middleware (DDM) will be used to connect Relational Database Service (RDS) DB
instances. Auto Scaling (AS) and Elastic Load Balance (ELB) are used to ensure availability and
reliability in the same AZ. Log Tank Service (LTS) and CES are used to store and monitor the
website, and Object Storage Service (OBS) is used to store website data.

You need to set up an ECS ecs-migration in VPC-migration, and use VPC peering connection
to connect VPC-wordpress and VPC-migration. You also need to migrate the source server
wordpress-server to ecs-migration, create a NAT gateway for ecs-migration and configure
rules so that ecs-migration can be accessed over the Internet.

3.1.3 Exam Requirements


1. Take screenshots of all key steps and save them in .png format. Name screenshots in the
following format: 1-1-1xx.png, 1-1-2xx.png, ...
2. Strictly follow the configuration and naming requirements described in the exam.
3. PuTTY and WinSCP are recommended for logging in to Linux servers and transferring
files.
4. Use resources in the Hong Kong region or Singapore region as required.
5. Set the password of all resources in the exam to ict2022@ICT##. ## refers to your exam
account. For example, if your account is 01. All the password would be ict2022@ICT01.

3.1.4 Exam Resources

3.1.4.1 Lab Environment


A few cloud resources have been ready for you, but for most of the resources required in lab
tasks, you will have to purchase from Huawei Cloud.

3.1.4.2 Cloud Resources


The following cloud resources have been ready for you.

Resource Name Specifications Description

Virtual Private Cloud N/A VPC-wordpress: 192.168.0.0/16


(VPC) subnet-wordpress: 192.168.100.0/24

Security Group N/A sg-wordpress uses the General-purpose web


server template, and includes default rules that
allow all inbound ICMP traffic and inbound
traffic on ports 22, 80, 443, and 3389. TCP
ports 5066 and 3306 are manually allowed.

RDS DB instance 2 vCPUs | 4 GB rds-wordpress

2022-06-17 Huawei confidential. No spreading without permission. Page 5 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Resource Name Specifications Description


Password: root/ict2022@ICT##

Image Management N/A Select the shared image Wordpress_for_ICT.


Service (IMS) image

OBS N/A obs-result-ict##


For example, if your exam account is 01. Your
obs should be obs-result-ict01.

The cloud resources listed in the following table are for you to purchase.

Resource Name Specifications Description

Virtual Private Cloud N/A VPC-migration: 10.1.0.0/16


(VPC) subnet-migration: 10.1.0.0/24

Security Group N/A sg-migration uses the General-purpose web


server template, and includes default rules
that allow all inbound ICMP traffic and
inbound traffic on ports 22, 80, 443, and
3389. TCP port 5066 is manually allowed.

ECS 2 vCPUs | 4GB | wordpress_server


CentOS 7.6 64bit Login password: ict2022@ICT##

ECS 1 vCPU | 2GB | migration-server


Windows Server Login password: ict2022@ICT##
2012 R2 Standard
64bit English

Elastic IP (EIP) Dynamic BGP | Billed Two EIPs are needed.


by traffic | 5 Mbit/s

RDS DB instance rds-wordpress


2 vCPUs | 4 GB
Password: ict2022@ICT##

DDM instance N/A None

ELB load balancer Shared None

AS group N/A None

CES N/A None

SMS N/A None

2022-06-17 Huawei confidential. No spreading without permission. Page 6 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

3.1.4.3 Tools
For this test, you will need the tool described in the table here.

Tool Remarks

PuTTY Remote login tool

3.1.5 Exam Tasks

3.1.5.1 Lab Tasks


Each step in each task is scored independently. Please arrange your time appropriately.

Task 1: Deploying a WordPress website production environment (60 points)


 Subtask 1: Buy a DDM instance.
a. Buy a DDM instance, name it ddm-wordpress, and set the following parameters. For
parameters that are not specified, use the default settings.

Billing Mode Pay-per-use

Region CN-Hong Kong

Instance Name ddm-wordpress

Node Class Select the minimal specifications, for example, 8 vCPUs | 16 GB

Instance Nodes 1

VPC vpc-wordpress /subnet-wordpress

Security Group sg-wordpress

Screenshot requirements:
a. Take a screenshot of the basic information of ddm-wordpress and save it as 1-1-
1ddm.
 Subtask 2: Create a schema and an account.
a. Create a schema based on ddm_wordpress, and set the following parameters. For
parameters that are not specified, use the default settings.

Sharding Unsharded

Schema Name db_wordpress

RDS DB Instance rds_wordpress


Note: The RDS DB instance named rds_wordpress
has been created for you.

RDS DB account and password root/ict2022@ICT##

2022-06-17 Huawei confidential. No spreading without permission. Page 7 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

b. Create a DDM account based on ddm_wordpress.

Username ICT_user##

Password ict2022@ICT##

Schema db_wordpress

Permissions All

Screenshot requirements:
a. Take a screenshot of the page showing the schema is in the Running state and save
it as 1-2-1schema.
b. Take a screenshot of the DDM account created and save it as 1-2-2account.
 Subtask 3: Create an ECS to access WordPress.
a. Create an ECS named wordpress-server with the following details. For parameters
that are not specified, use the default settings.

VPC vpc-wordpress

Security Group sg-wordpress

CPU Architecture X86

Specifications General computing-plus, 2 vCPUs | 4 GB

Image Use the shared full-ECS image named


Wordpress_for_ICT.

Cloud Backup and Recovery Not required

Password ict2022@ICT##

EIP Auto assign, Dynamic BGP, Billed by traffic, 5


Mbit/s

b. Use the EIP of wordpress-server to access WordPress in the browser.


Screenshot requirements:
a. Take a screenshot of wordpress-server details and save it as 1-3-1wordpress-server.
b. Enter http://wordpress-server EIP/wordpress in the address box of the browser, take
a screenshot of the page and save it as 1-3-2wordpress-setup.
 Subtask 4: Configure the WordPress database.
a. Access http://wordpress-server EIP/wordpress, click Let's go!, and enter the
following DDM database information.

Database Name The schema name

Username The DDM account

Password The password of the DDM account

2022-06-17 Huawei confidential. No spreading without permission. Page 8 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Database Name The schema name

Database Host The Connection Address of DDM

Table Prefix Keep the default settings

b. Click Submit, and click Run the installation, and then enter the following
information. And click Log In.

Site Title Welcome to ICT competition

Username The DDM account

Password The password of the DDM account

Your Email ICT##@huawei.com

Screenshot requirements:
a. Take a screenshot of the database configuration page and save it as 1-4-1ddm
configuration.
b. Take a screenshot of the page showing successful access to WordPress and save it as
1-4-2wordpress.

Task 2: Backing up the ECS (50 points)


 Subtask 1: Configure an auto backup policy.
a. Search Cloud Server Backup Service in the search bar. Buy a cloud server backup
vault (For parameters that are not specified, use the default settings.

Billing Mode Pay-per-use

Protection Type Backup

Vault Capacity 100 GB

Associated Server Skip

Auto Backup Skip

Automatic Association Skip

Auto Capacity Expansion Skip

Vault Name vault-wordpress

b. Create an auto backup policy named policy-auto with the following details.

Execution Time 07:00

Backup Cycle Week-based cycle: Sunday

Retention Rule Time period: 1 month

c. Apply policy-auto to vault-wordpress.

2022-06-17 Huawei confidential. No spreading without permission. Page 9 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

d. Associate wordpress-server to vault-wordpress.


Screenshot requirements:
a. Take a screenshot of policy-auto and save it as 2-1-1policy-auto.
b. Take a screenshot of vault-wordpress details, including the associated server and
backup policy, and save it as 2-1-2vault-wordpress.
 Subtask 2: Manually back up data.
Create a manual backup task named manualbk-vault-wordpress. Ensure that the
associated server is wordpress-server.
Screenshot requirements:
a. Take a screenshot of the backup list and save it as 2-2-1manualbk-vault.
 Subtask 3: Create an image using backup.
a. Use manualbk-vault-wordpress to create a Full-ECS image named image-from-
backup.
Screenshot requirements:
a. Take a screenshot of image-from-backup details and save it as 2-3-1image-from-
backup.
 Subtask 4: Restore the ECS using backup.
a. Use manualbk-vault-wordpress to restore the ECS.
Screenshot requirements:
a. Take a screenshot of the task list and save it as 2-4-1tasks.

Task 3: Configuring website load balancing and auto scaling (120 points)
 Subtask 1: Create an ELB load balancer.
a. Unbind the EIP from wordpress_server.
b. Buy an ELB load balancer and set the following parameters. For parameters that are
not specified, use the default settings.

Region CN-Hong Kong

Type Shared

Network Type Public network

VPC/Subnet vpc-wordpress /subnet-wordpress

Private IP Address Automatically assigned IP address

EIP New EIP, Billed by traffic, 5 Mbit/s

Name elb-wordpress

c. Configure a listener named listener-wordpress and set the frontend protocol and
port to TCP and 80.
d. Configure a backend server group named server_group-wordpress. Do not enable
health check and retain the default settings for other parameters.

2022-06-17 Huawei confidential. No spreading without permission. Page 10 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

e. Add the backend server wordpress-server and configure the backend port to 80.
f. Access http://EIP of elb-wordpress/wordpress to verify that the configuration was
successful.
Screenshot requirements:
a. Take a screenshot of wordpress-server details after you unbind its EIP and save it as
3-1-1wordpress-server-noeip.
b. Take a screenshot of elb-wordpress in the load balancer list and save it as 3-1-2elb-
wordpress.
c. Take a screenshot of the basic information about listener-wordpress and save it as
3-1-3listener.
d. Take a screenshot of the basic information about server_group-wordpress and save
it as 3-1-4server group.
e. Access http://EIP of elb-wordpress/wordpress, take a full-page screenshot (including
the IP address in the browser) and save it as 3-1-5elb-wordpress.
Note: The IP address in the browser must be the same as the EIP of elb-wordpress.
 Subtask 2: Create an AS group and configure scaling rules.
a. Create an AS configuration named as-config-wordpress with the following details.
For parameters that are not specified, use the default settings.

Name as-config-wordpress

Configuration Create new template


Template

CPU Architecture x86

Specifications General computing-plus, 2 vCPUs | 4 GB

Image select the created private image image-from-backup you


created.

Security Group sg-wordpress

Login Mode Password

Password ict2022@ICT##

b. Create an AS group with the following details. For parameters that are not specified,
use the default settings.

Name as-group-wordpress

Max. Instances 4

Expected 1
Instances

Min. Instances 1

AS Configuration Select as-config-wordpress.

2022-06-17 Huawei confidential. No spreading without permission. Page 11 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

VPC VPC-wordpress/subnet_wordpress

Load Balancing Select Elastic load balancer.


Select load balancer elb-wordpress and backend ECS group
server_group-wordpress.
Set Backend Port to 80.
Set Weight to 1.

c. Manually add wordpress-server to the AS instance.


d. Create an AS policy.
e. Add an auto scaling policy named as-policy-expanding with the following details.
For parameters that are not specified, use the default settings.

Policy Type Alarm

Rule Name as-policy-expanding

Monitoring Type System monitoring

Trigger Condition The maximum CPU usage is greater than or equal to 40%.

Monitoring Interval 5 minutes

Consecutive 1
Occurrences

Scaling Action Add 1 instance

Cooldown Period (s) 120

Screenshot requirements:
a. Take a screenshot of the as-config-wordpress list and save it as 3-2-1as-config-
wordpress.
b. Take a screenshot of the as-group-wordpress overview and save it as 3-2-2as-
group-wordpress.
c. Take a screenshot of the instance details of as-group and save it as 3-2-3as-
instances.
d. Take a screenshot of the as-policy-expanding list and save it as 3-2-4as-policy-
details.
 Subtask 3: Verify the auto scaling.
a. Manually scale out the scaling group. Set Expected Instances to 4, view the AS
instance list and verify the results.
b. Manually scale in the scaling group. Set Expected Instances to 2, view the AS
instance list and verify the results.
c. Verify the AS policy. Manually execute as-policy-expanding.
d. During the auto scaling, view the AS group information on the Monitoring tab page
of as-group-web.

2022-06-17 Huawei confidential. No spreading without permission. Page 12 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Note: After you set the Expected Instances, please wait for a few minutes until it has
been changed and you can view the results. After you can view the results, go the next step.
Screenshot requirements:
a. Take a screenshot of Scaling Action tab page of as-group-web after the verification
is complete and save it as 3-3-1scaling-actions.
b. After you finish the steps above, wait for at least 10 minutes until the change of
instances take effect in the Monitoring tab page, and then take a screenshot of all
monitoring curves on the Monitoring tab page of as-group-web and save it as 3-3-
2as-group-web-monitoring.

Task 4: Monitoring websites and logs (90 points)


 Subtask 1: Install the Agent, a monitoring plug-in.
a. Install the Agent for two ECSs as-config-wordpress-xxx (Created by AS group). For
details about the installation, see Appendix 2.
b. Ensure that the Agent has been installed correctly. Log in to the Cloud Eye (CES)
console, click Server Monitoring, and check whether Agent of as-config-wordpress-
xxx is Running.
Screenshot requirements:
a. Take a screenshot of the host monitoring list after the Agent is installed, and save it
as 4-1-1installed-agent.
 Appendix 2:
Installing and Configuring the Agent
a. Log in to the ECS remotely from the ECS console as root.
b. Install the Agent:
cd /usr/local && curl -k -O https://obs.ap-southeast-1.myhuaweicloud.com/uniagent-
ap-southeast-1/script/agent_install.sh && bash agent_install.sh
 Subtask 2: Configure server monitoring alarm rules.
a. Create alarm rules alarm-rule1 for one of the servers as-config-wordpress-xxx,
alarm-rule2 for other one of the servers named as-config-wordpress-xxx .And
configure as follows. For parameters that are not specified, use the default settings.
Metric Name: (Agent) CPU Usage (Recommended)
Alarm Policy: Raw data, 3 consecutive periods, >= 40%, Every 5 minutes
b. Log in to as-config-wordpress-xxx and run the following command to cause CPU
usage to increase (the change can be seen in 5 to 10 minutes):
for i in `seq 1 $(cat /proc/cpuinfo |grep "physical id" |wc -l)`; do dd if=/dev/zero
of=/dev/null & done
c. In the navigation pane, choose Alarm Management > Alarm Records. Refresh the
Alarm Records page, and the status of alarms changes to Alarm.
Screenshot requirements:
a. Take a screenshot of the alarm policy and save it as 4-2-1alarm-rules.

2022-06-17 Huawei confidential. No spreading without permission. Page 13 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

b. Take a screenshot of the alarm record page and save it as 4-2-2history alarm.
 Subtask 3: Configure a log monitoring policy for ECSs.
a. Create a log group named lts-group-wordpress and set the logs to be retained for 7
days.
b. Create a log stream named lts-topic-wordpress in lts-group-wordpress.
c. Install ICAgent for wordpress-server with the following details:
OS: Linux
Installation Mode: Obtain AK/SK
You can obtain the AK/SK from the My Credentials page of your exercise account.
d. Configure log ingestion. On the Select Ingestion Type page, select Host, and then
select the newly created log group and log stream. Create a host group and
configure collection.

Host Group hostgroup-wordpress

Host OS Linux

Hosts Select wordpress-server where ICAgent has


been installed.

Collection Configuration Name collect_wordpress

Configuration Paths /var/log/messages

Log Format Single-line

Log Time System time

e. On the Log Management page, click the log group name and log stream name,
select Original Log, and enter successful in the text box to search for related logs.
Screenshot requirements:
a. Take a screenshot of the page for creating the log stream and save it as 4-3-1Log
Stream.
b. Take a screenshot of the host list displayed on the Hosts tab and save it as 4-3-
2ICAgent Hosts.
c. Click the ingestion configuration name, take a screenshot of configuration details and
save it as 4-3-3collect-wordpress.
d. Take a screenshot of the page where you search for successful logs and save it as 4-
3-4realtime log.
 Subtask 4: Transfer logs to OBS.
a. Create a log transfer rule as the following parameters. Retain the default settings for
other parameters.

Log Source Account Current

Log Group Name Its-group-wordpress

2022-06-17 Huawei confidential. No spreading without permission. Page 14 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Log Source Account Current

Log Stream Name Its-topic-wordpresss

Transfer Destination OBS

OBS Bucket The created obs-result-ict##.


For example, if your exam account is 01. Your
OBS bucket is obs-result-ict01.

Log Prefix log-wordpress

Format Raw Log Format

Log Transfer Interval 2 minutes

b. Log in to OBS Console and view the log folder automatically uploaded to the bucket.
Screenshot requirements:
a. Take a screenshot of the log transfer and save it as 4-4-1logs-transfer-config.
b. After a few minutes, take a screenshot of logs stored in the OBS bucket and save it
as 4-4-2logs-in-bucket.

Task 5: Migrating hosts across VPCs (130 points)


 Subtask 1: Create a VPC and a security group.
a. Create a VPC named vpc-migration in the Hong Kong region, with IPv4 CIDR block
set to 10.1.0.0/16, and use the default subnet name subnet-migration with its IPv4
CIDR block set to 10.1.0.0/24.
b. Create a security group named sg-migration in the Hong Kong region, use the
General-purpose web server template, and manually allow TCP port 5066.
Screenshot requirements:
a. Take a screenshot of vpc-migration details and save it as 5-1-1vpc-migration.
b. Take a screenshot of the inbound rule page of sg-migration and save it as 5-1-2sg-
migration.
 Subtask 2: Create a VPC peering connection.
a. Create a VPC peering connection named peering-wordpress, with the local VPC set
to vpc-wordpress, and peer VPC set to vpc-migration.
b. Add a local route. The destination address is the IP address segment of vpc-
migration, and the next hop is peering-wordpress.
c. Add a peer route. The destination address is the IP address segment of vpc-
wordpress, and the next hop is peering-wordpress.
Screenshot requirements:
a. Take a screenshot of peering-wordpress details and save it as 5-2-1peering-
wordpress.

2022-06-17 Huawei confidential. No spreading without permission. Page 15 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

b. Take a screenshot of the local route and save it as 5-2-2local route.


c. Take a screenshot of the peer route and save it as 5-2-3peer route.
 Subtask 3: Create a target ECS.
Create an ECS named ecs-migration with details shown here. Retain the default settings
for parameters that are not specified.

VPC vpc-migration

Security Group sg-migration

Specifications 2 vCPUs | 4 GB

Billing Mode Pay-per-use

Image Public image CentOS 7.6 64bit (40 GB)

Cloud Backup and Recovery Not required

Password ict2022@ICT##

EIP Not required

Screenshot requirements:
a. Take a screenshot of ecs-migration details and save it as 5-3-1wordpress-server.
 Subtask 4: Migrate wordpress-server to another VPC.
a. Bind an EIP to wordpress_server again.
b. Install the migration Agent on wordpress-server. For details about the installation,
see Appendix 3.
c. On the Servers page of Server Migration Service (SMS), you can see wordpress-
server with the Agent installed.
d. Configure the target server with the following details. For parameters that are not
specified, use the default settings.

Migration Templates SystemProject

Network Private

Migration Rate Limit 0 Mbit/s

Linux Migration Linux file-level

Partition Resizing No

Region CN-Hong Kong

Project Select the corresponding project of your account.

Server Using existing, ecs-migration

e. Save the settings and start migration.

2022-06-17 Huawei confidential. No spreading without permission. Page 16 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Note: The migration may take a few minutes. You can come back to take the screenshot
showing a successful migration after the migration is complete.
Screenshot requirements:
a. After Agent is installed, take a screenshot containing the "sms agent start up
successfully!" and save it as 5-4-1agent.

b. After the migration is done, take a screenshot of the migration subtask page and
save it as 5-4-2migration task.
 Appendix 3
1. Log in to wordpress-server.
2. Download and install Agent and rsync:
wget -t 3 -T 15 https://sms-agent-2-0.obs.ap-southeast-1.myhuaweicloud.com/SMS-
Agent.tar.gz
wget -t 3 -T 15 https://sms-agent-2-0.obs.ap-southeast-1.myhuaweicloud.com/SMS-
Agent.tar.gz.sha256
yum install -y rsync
tar -xvf SMS-Agent.tar.gz
cd SMS-Agent
./startup.sh
Enter y, access key ID, and secret access key as prompted.
Note: You can create an access key by choosing your test account > My Credentials >
Access Keys and saving the access key file to your computer.
 Subtask 5: Configure a NAT gateway.
In this subtask, you need to create a NAT gateway and configure a DNAT rule for ecs-
migration in the VPC-migration subnet to be accessed over the Internet.
a. Buy a public network NAT gateway with following details..

Billing Mode Pay-per-use

Region CN-Hong Kong of your account

Name NATGW-HK

VPC vpc-migration

Subnet subnet-migration

Type Small

2022-06-17 Huawei confidential. No spreading without permission. Page 17 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

b. Buy two EIPs with the following details.

Billing Mode Pay-per-use

Region CN-Hong Kong of your account

Billed By Traffic

Bandwidth 5 Mbit/s

Bandwidth Name bandwidth-hk1/bandwidth-hk2

Quantity 2

c. Configure an SNAT rule for subnet-migration and select bandwidth-hk1 as EIP.


d. Configure a DNAT rule for subnet-migration with details shown here.

Scenario VPC

Port Type All ports

Protocol All

EIP bandwidth-hk2

Private IP Address Private IP address of ecs-migration

e. Visit http://bandwidth-hk2 IP address/wordpress using a browser to check whether


ecs-migration can be accessed with an EIP.
f. Log in to ecs-migration, ping www.huaweicloud.com, and view the ping result.
Screenshot requirements:
a. Take a screenshot of the DNAT rule of NATGW-HK and save it as 5-5-1DNAT-RULE.
b. Take a screenshot of the SNAT rule of NATGW-HK and save it as 5-5-2SNAT-RULE.
c. Take a screenshot of accessing ecs-migration using the bandwidth-hk2 EIP and save
it as 5-5-3migration.
d. Take a screenshot of the ping result and save it as 5-5-4ping result.

3.2 Storage
3.2.1 Scenarios
To permanently store data on the Smart City platform and offer massive storage, a storage
solution needs to be established at the platform's bottom layer. In addition, a remote
replication disaster recovery solution is required to guarantee high reliability.

2022-06-17 Huawei confidential. No spreading without permission. Page 18 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

3.2.2 Network Topology

3.2.3 Exam Requirements


1. Take screenshots of all key steps and save them in .png format. Name screenshots in the
following format: 1-1-1xx.png, 1-1-2xx.png, ...
2. Strictly follow the configuration and naming requirements described in the exam.
3. PuTTY and WinSCP are recommended for logging in to Linux servers and transferring
files.
4. Unless otherwise specified, use resources in the AP-Hong Kong region.
5. Ignore the license expiration message if there is one.

3.2.4 Exam Resources

3.2.4.1 Cloud Resources


Resource Name Specifications Description

VPC N/A Three subnets:


VPC-HK HK-Storage-Mgmt: 10.0.3.0/24
HK-Storage-Service: 10.0.4.0/24
HK-Storage-Replication:
10.0.5.0/24

ECS 2 vCPUs | 4 GB | CentOS Login password: ict2022@ICT##


Linux host-LinuxStorage 7.6 64bit

ECS 2 vCPUs | 4 GB | Windows Login password: ict2022@ICT##


Windows host 1-
WindowsStorage 1

2022-06-17 Huawei confidential. No spreading without permission. Page 19 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Resource Name Specifications Description

ECS 2 vCPUs | 4 GB | Windows Login password: ict2022@ICT##


Windows host 2-
WindowsStorage 2

ECS 8 vCPUs | 16 GB | Username: admin; password:


Storage A-estor1 Preinstall eStor. ict2022@ICT##

ECS 8 vCPUs | 16 GB | Username: admin; password:


Storage B-estor2 Preinstall eStor. ict2022@ICT##

EIP Dynamic BGP | Pay-per-use 5 public IP addresses


| 5 Mbit/s

Security group N/A default

3.2.4.2 Tools
Tool Description

PuTTY Remote login tool

WinSCP File transfer tool

3.2.5 Exam Tasks

3.2.5.1 Lab Tasks


Each step in a task is scored separately. Please arrange your exam time appropriately.

Task 1: Initializing storage (20 points)


Subtask 1: Initialize the storage pool.

a. Log in to the web management page of two storage devices individually. The username
and password for logging in to the storage device are admin and ict2022@ICT##.
b. Set the location of estor1 to HongKong1 and estor2 to HongKong2.
c. Create a storage pool and import the license. Store the license in an OBS bucket on the
cloud. The path is obs-ict-resource >> storage >> License_V6 to 2022.10.1.rar.

Screenshot requirements:

a. After the license has been imported to both storage devices, take screenshots of license
lists and name them 1-1-1initial-lisence1 and 1-1-2initial-lisence2.
b. Take screenshots of the Device Manager home pages of both storage devices and name
them 1-1-3initial-finished1 and 1-1-4initial-finished2.

Subtask 2: Complete basic storage configurations.

2022-06-17 Huawei confidential. No spreading without permission. Page 20 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

a. On estor1, create a 1 GB LUN for the hosts WindowsStorage1 and LinuxStorage1.


Name WindowsStorage1's LUN Win1LUN, and LinuxStorage's LUN LinLUN.
b. Create logical hosts for WindowsStorage1 and LinuxStorage on the storage side and
name them WindowsStorage1 and LinuxStorage.
c. Map the LUNs to the logical hosts.

Screenshot requirements:

a. Take a screenshot of the mapping between WindowsStorage1 and Win1LUN and name
it 1-2-1map-win.
b. Take a screenshot of the mapping between LinuxStorage and LinLUN and name it 1-2-
2map-linux.

Task 2: Establishing host connectivity (60 points)


Subtask 1: Configure logical service ports.

a. Based on the topology, create a logical service port on estor1 and name it ServicePort1.
b. Based on the topology, create a logical service port on estor2 and name it ServicePort2.

Screenshot requirements:

a. Take a screenshot of the ServicePort1 details page and name it 2-1-1service-port1.


Ensure that the screenshot contains details such as the IP Address, Home Port, and IP
Address Failover.
b. Take a screenshot of the ServicePort2 details page and name it 2-1-2service-port2.
Ensure that the screenshot contains details such as the IP Address, Home Port, and IP
Address Failover.

Subtask 2: Configure the Windows host connectivity.

a. Log in to WindowsStorage1, user name and password are Administrator and


ict2022@ICT## .
b. Open iSCSI Initiator, and search for and connect to the estor1's storage target, the logical
service port.
c. Go to estor1 and add the corresponding initiator to the WindowsStorage1 logical host.
d. Go back to the host side. Open Server Manager, scan for the new disk, create a volume,
and name it Huawei1.
e. Create a .txt file in Huawei1 and name it Huawei.

Screenshot requirements:

a. After successfully discovering the target on the WindowsStorage1 host, take a


screenshot and name it 2-2-1win-discovery.
b. After successfully connecting to the target on the WindowsStorage1 host, take a
screenshot and name it 2-2-2win-target.
c. After successfully adding the initiator to the logical host on estor1, take a screenshot of
the initiator list and name it 2-2-3win-addini.

2022-06-17 Huawei confidential. No spreading without permission. Page 21 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

d. Take a screenshot of the Huawei.txt file on the WindowsStorage1 host and name it 2-
2-4win-txt1.

Subtask 3: Configure the LINUX host connectivity.

a. Log in to the LinuxStorage host as root. Password: ict2022@ICT##


b. Scan and log on to the storage target. Then complete the subsequent operations on the
storage side.
c. Go to the host side, format the storage space, create the /Huawei mount point, and
mount the disk.
d. Create a .txt file in the /Huawei directory and name it Huawei.

Screenshot requirements:

a. After successfully logging in to the target on the host, take a screenshot and name it 2-3-
1lin-load.
b. Take a screenshot of the Huawei.txt file and name it 2-3-2lin-txt2.

Task 3: Configuring file services (50 points)


Subtask 1: Configure file service ports.

a. Based on the topology, create a logical port of file services on estor1 and name it
FileService.

Screenshot requirements:

a. Take a screenshot of the FileService details and name it 3-1-1service-fileport. Ensure


that the screenshot contains details such as the IP Address, Home Port, and IP Address
Failover.

Subtask 2: Configure CIFS sharing.

a. On estor1, create a file system for Windows and name it in the format of ICT<Exam
group number> (for example, ICT01). Set the file system size to 3 GB and application
type to NAS_Default.
b. Create a local Windows authentication user with the username in the format of
ICT<Exam group number> (for example, ICT01) and password setting to ict2022@ICT##,
add the user to Users group.
c. Create a share and name it in the format of ICT<Exam group number> (for example,
ICT01). Add the created authentication user to this share and grant the user with the full
control permission.

Screenshot requirements:

a. Take a screenshot of the details of the created file system and name it 3-2-1cifs-
filesystem.
b. Take a screenshot of the details of the created authentication user and name it 3-2-2cifs-
authuser.
c. Take a screenshot of the details of the created share and name it 3-2-3cifs-share.

2022-06-17 Huawei confidential. No spreading without permission. Page 22 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Subtask 3: Access the CIFS share.

a. Log in to WindowsStorage1 and access the shared space using the authentication user
created in the previous step.
b. Create a .txt file in the filesystem and name it HuaweiFile.

Screenshot requirements:

a. After successfully logging in, take a screenshot of the shared space and name it 3-3-
1share-filesystem.
b. After successfully creating the HuaweiFile file, take a screenshot and name it 3-3-
2share-txt.

Task 4: Using the advanced remote replication feature (70 points)


Subtask 1: Configure logical replication ports.

Procedure:

a. Create logical replication ports on estor1 and estor2 and name them RepPort1 and
RepPort2.

Screenshot requirements:

a. Take screenshots of the RepPort1 and RepPort2 ports and name them 4-1-1rep-port1
and 4-1-2rep-port2. Ensure that the screenshots contain details such as IP Address, Home
Port, and IP Address Failover.

Subtask 2: Create an authentication user and add a remote device.

a. Create a remote device administrator on estor2. The username and password are
RemoteUser and ict2022@ICT##.
b. On estor1, add estor2 as the remote device.

Screenshot requirements:

a. View the details of the remote device administrator on estor2, take a screenshot, and
name it 4-2-1remote-user.
b. View the details of the remote device on estor1, take a screenshot, and name it 4-2-
2remote-device.

Subtask 3: Configure a remote replication pair.

a. Create a remote replication pair on estor1 based on Win1LUN. Major parameters are as
follows:
 Replication Mode: Asynchronous
 Pair Creation: Automatic
 Synchronization Type: Manual

Screenshot requirements:

2022-06-17 Huawei confidential. No spreading without permission. Page 23 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

a. Take a screenshot of the details of the remote replication pair on estor1 and name it 4-3-
1rep-pair.

Subtask 4: Verify the remote replication result.

a. Split the remote replication pair.


b. Map the secondary LUN generated on estor2 to the WindowsStorage 2 host.
c. On WindowsStorage 2, check whether data on the secondary LUN is consistent with that
on the primary LUN.

Screenshot requirements:

a. After successfully splitting the pair, take a screenshot of the details of the remote
replication pair on estor1 and name it 4-4-1rep-split.
b. Log in to WindowsStorage2, check the data on the disk mapped from the secondary
LUN, take a screenshot, and name it 4-4-2rep-verify. Ensure that the screenshot contains
the host IP address.
c. Go back to estor2, view details of the remote replication pair, take a screenshot, and
name it 4-4-3rep-pro. Ensure that the screenshot contains the synchronization start time,
synchronization end time, and secondary resource protection status.

3.3 Big Data


3.3.1 Scenarios
In the fight against the COVID-19 pandemic, big data technologies have seen widespread
application tracking confirmed cases, recoveries, and mortalities. Using a 526-day public
dataset released by Johns Hopkins University, covering the period from January 22, 2020 to
June 9, 2021, you need to follow the exam requirements to analyze and mine the global
pandemic data.

3.3.2 Exam Requirements


1. Take screenshots of all key steps and save them in the format 1-1-1xx.png and 1-1-
2xx.png.
2. Strictly follow the configuration and naming requirements described in the exam.
3. PuTTY and WinSCP are recommended for logging in to Linux servers and transferring
files.
4. Unless otherwise specified, use the resources in the AP-Hong Kong region.

3.3.3 Exam Resources

3.3.3.1 Lab Environment


The lab environment has been set up. This exam involves MapReduce Service (MRS), Object
Storage Service (OBS), Relational Database Service (RDS), and the AI development platform,
ModelArts. Confirm the lab environment before starting the exam. If the environment is

2022-06-17 Huawei confidential. No spreading without permission. Page 24 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

unavailable, ask one of the exam supervisors for help. Obtain the datasets required in exam
from the corresponding OBS bucket.

3.3.3.2 Cloud Resources


Resource Specifications Description
Name

VPC N/A vpc-web

Security group N/A sg-web

EIP Dynamic BGP | Pay-per-use billing | Dedicated bandwidth-web


bandwidth (5 Mbit/s)

MRS cluster Active: 2 x kc1.2xlarge.2 | 16 vCPUs | 64 GB Analysis cluster of


Standby: 3 x kc1.2xlarge.2 | 16 vCPUs | 64 GB x version 3.1.0
3

OBS bucket Standard, private

RDS DB 2 vCPUs | 4 GB | General computing-plus | MySQL 5.7


instance Single-node

ECS for 2 vCPUs | 8 GB Multi-engine 1.0


ModelArts (Python3)

3.3.3.3 Tools
Tool Remarks

PuTTY Remote login tool

WinSCP File transfer tool

3.3.4 Exam Tasks

3.3.4.1 Lab Tasks


Each step in a task is scored separately. Take screenshot of the code you execute or the
returned results of each step and save them to the specified directory.

Note: To ensure that your answer can be scored, take screenshot of your code or outputs as
required.

Task 1: Preprocessing MySQL data (60 points)


 Subtask 1: Create a MySQL database.
a. Log in to the Huawei Cloud official website and go to the RDS console. Locate the
row that contains the created DB instance, click More in the Operation column, and
select Log In (username: root, password: ict2022@ICT##).

2022-06-17 Huawei confidential. No spreading without permission. Page 25 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

b. Create a database named ict_bigdata and set the character set to UTF-8.
Screenshot requirements:
a. Take a screenshot after the login and save it as 1-1-1login.
b. Take a screenshot of the created database and save it as 1-1-2mysqldatabase.
 Subtask 2: Create a MySQL table.
a. Create a table named confirmed in the ict_bigdata database. Set the table engine to
InnoDB and the character set to UTF-8. Set the field names to: date, confirmed,
Province/State, and Country/Region. Set the field types, respectively, to:
varchar(50), int(11), varchar(50), and varchar(50).
None fields can be empty. No primary key is required. Create a multi-column index
for the date, Province/State and Country/Region columns. The relationships would
be as follows:
Field Type Null Key Default Extra
date varchar(50) NO MUL
confirmed int(11) NO
Province/State varchar(50) NO
Country/Region varchar(50) NO

b. Create a table named recovered in the ict_bigdata database. Set the table engine to
InnoDB and the character set to UTF-8. Set the field names to: date, recovered,
Province/State, and Country/Region. Set the field types, respectively, to:
varchar(50), int(11), varchar(50), and varchar(50).
None fields can be empty. No primary key is required. Create a multi-column index
for the date, Province/State and Country/Region columns. The relationships are as
follows:
Field Type Null Key Default Extra
date varchar(50) NO MUL
recovered int(11) NO
Province/State varchar(50) NO
Country/Region varchar(50) NO

c. Create a table named deaths in the ict_bigdata database. Set the table engine to
InnoDB and the character set to UTF-8. Set the field names to: date, deaths,
Province/State, and Country/Region. Set the field types, respectively, to:
varchar(50), int(11), varchar(50), and varchar(50).

2022-06-17 Huawei confidential. No spreading without permission. Page 26 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

None fields can be empty. No primary key is required. Create a multi-column index
for date, Province/State and Country/Region columns. The relationships are as
follows:
Field Type Null Key Default Extra
date varchar(50) NO MUL
deaths int(11) NO
Province/State varchar(50) NO
Country/Region varchar(50) NO

Screenshot requirements:
a. Take a screenshot of the SQL statement used to create the confirmed table and save
it as 1-2-1confirmed.
b. Take a screenshot of the SQL statement used to create the recovered table and save
it as 1-2-2recovered.
c. Take a screenshot of the SQL statement used to create the deaths table and save it
as 1-2-3deaths.
 Subtask 3: Import data.
Use the data import function (shown in the red box in the following figure) to import the
three .csv files in the obs_ictbigdata bucket to the tables you created in subtask 2.

Screenshot requirements:
a. Take a screenshot after importing data and save it as 1-3-1importdata.
 Subtask 4: Join multiple MySQL tables and query data.
a. Join the three tables you created through the date, Province/State, and
Country/Region fields, and save the results to table data, where the fields are date,
confirmed, recovered, deaths, Province/State, Country/Region in sequence. The
configuration of the table fields is as follows:
Field Type Null Key Default Extra
date varchar(50) NO
confirmed int(11) NO
recovered int(11) NO
deaths int(11) NO
Province/State varchar(50) NO
Country/Region varchar(50) NO

b. Query the data whose Country/Region is Australia, China, France, US, and United
Kingdom from the data table and save the returned data to the mysql_result table.
Ensure that the field sequence in the mysql_result table is the same as that in the
data table.
Screenshot requirements:

2022-06-17 Huawei confidential. No spreading without permission. Page 27 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

a. Take a screenshot of the first 50 rows of the data table and save it as 1-4-1joined.
b. Take a screenshot of the first 50 rows of the mysql_result table and save it as 1-4-
2filtered.

Task 2: Creating a Hive database and table and importing data from HDFS
(60 points)
 Subtask 1: Export the MySQL result and upload it to HDFS.
a. On the RDS for MySQL page, choose Import and Export and click Export. On the
displayed data export page, click Create Task to export the mysql_result table from
the ict_bigdata database to the obs_ictbigdata bucket in the CSV format. Retain all
data and set the encoding format to UTF-8. You do not need to retain field
attributes. Take a screenshot after exporting the data and download the exported
data to a local folder.

b. Use PuTTY to remotely log in to the MRS server as root (password: ict2022@ICT##).
In the /user directory of HDFS, create a subdirectory with the same name as the IAM
username of your group, for example: /user/ict11.
c. Decompress the .zip file downloaded in step a and use WinSCP to upload the .csv file
to the MRS cluster. Run the following shell command in PuTTY to remove the
quotation marks from the file.

sed -i 's/"//g' mysql_result.csv

d. Use PuTTY to upload the processed file to the HDFS directory you created in step b.
Screenshot requirements:
a. After exporting the data, take a screenshot and save it as 2-1-1exportdata.
b. Take a screenshot of the created HDFS directory and save it as 2-1-2hdfsmkdir.
c. No screenshot required
d. Take a screenshot of the shell commands you used for uploading the file to HDFS
and checking whether the file upload is successful and save it as 2-1-3hdfsupload.
 Subtask 2: Create a database and an external table in Hive and import data.
a. Run the beeline command to enter the Hive CLI; create a database named
ict_bigdata in Hive; display all databases in the current instance; and switch to the
ict_bigdata database.

2022-06-17 Huawei confidential. No spreading without permission. Page 28 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

b. Create an external table named ods_covid19 in the ict_bigdata database. Set the
field names and field types listed in the following table. Retain the default values for
other parameters.
Field Type
date string
confirmed int
recovered int
deaths int
Province/State string
Country/Region string
c. Run the Hive command to import the mysql_result.csv file in HDFS to the external
table ods_covid19. After the data is imported successfully, query the first 30 rows of
the ods_covid19 table.
Screenshot requirements:
a. Take a screenshot of the SQL statement you used and save it as 2-2-1hivedatabase.
b. Take a screenshot of the SQL statement you used for creating the table and the
creation results. Save the image as 2-2-2ods_covid19.
c. Take a screenshot of the first 30 rows of the ods_covid19 table and save it as 2-2-
3loaddata.

Task 3: Building a layered model and analyzing statistics in Hive (60 points)
 Subtask 1: Query Hive data.
a. Use PuTTY to log in to the MRS server and go to Hive. Switch to the ict_bigdata
database in Hive and create a table named dwd_covid19 in the database. Set the
field names and field types listed in the following table.
Field Type
year string
month string
day string
confirmed int
recovered int
deaths int
Province/State string
Country/Region string
b. Split data (Year/Month/Day) in the date column of ods_covid19 table to the first
three columns of the dwd_covid19 table in sequence. View the first 30 rows of the
dwd_covid19 table.
c. Create a table named dws_monthly_confirmed in the ict_bigdata database. Set the
field names and field types listed in the following table.

2022-06-17 Huawei confidential. No spreading without permission. Page 29 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Field Type
year string
month string
Country/Region string
monthly_confirmed int
d. Query the monthly confirmed cases of the specified five countries in the
dwd_covid19 table and save the returned data to the dws_monthly_confirmed
table.
Screenshot requirements:
a. Take a screenshot of the SQL statement you used for creating the dwd_covid19
table and save it as 3-1-1dwd_covid19.
b. Take a screenshot of the first 30 rows of the dwd_covid19 table and save it as 3-1-
2separated.
c. Take a screenshot of the SQL statement you used for creating the
dws_monthly_confirmed table and save it as 3-1-3dws_monthly_confirmed.
d. Take a screenshot of the dws_monthly_confirmed table after importing data and
save it as 3-1-4monthlyconfirmed.
 Subtask 2: Use the Hive window function to query data.
a. Create a table named dws_most_recovered in the ict_bigdata database. Set the
field names and field types listed in the following table.
Field Type
year string
month string
Country/Region string
monthly_recovered int
rank int
b. For each month, query the two countries with the largest number of monthly
recoveries in the dwd_covid19 table and save the returned data to the
dws_most_recovered table.
Screenshot requirements:
a. Take a screenshot of the SQL statement you used for creating the
dws_most_recovered table and save it as 3-2-1dws_most_recovered.
b. Take a screenshot of the dws_most_recovered after importing data and save it as 3-
2-2mostrecovered.

Task 4: Performing data mining using PySpark ML (20 points)


 Subtask 1: Make preparations for data mining on the ModelArts console.
Note: The PySpark 2.3.2 environment has been installed for ModelArts. The SparkContext
object and SparkSession object are saved as sc and spark, respectively. Both of the two
objects are available and you do not need to create and declare them again.

2022-06-17 Huawei confidential. No spreading without permission. Page 30 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

a. Use PuTTY to log in to the MRS server, and run the HDFS command to download the
000000_0 file in the
/user/hive/warehouse/ict_bigdata.db/dws_monthly_confirmed directory to the
local PC, and save the file to your desktop using WinSCP.
b. Go to the ModelArts console and choose DevEnviron > Notebook. Click Open
JupyterLab to enter the exam environment.

c. Set Kernel to PySpark-2.3.2 and open the notebook environment.

d. Drag the 000000_0 file on the desktop to the list on the left to upload the data.

e. Read the 000000_0 file and create a Spark DataFrame object to save the data. Just
copy and paste the following code to the CLI:

import pandas as pd
data_pd=pd.read_csv('000000_0',header=None)

data_pd.columns=['year','month','country/region','monthly_confirmed']
data_origin = spark.createDataFrame(data_pd)
data_origin.show()

2022-06-17 Huawei confidential. No spreading without permission. Page 31 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

f. Run the code shown here to construct features. This code is used to query data
whose Country/Region field in the data_origin table is US. Add a feature column
whose value increments from 1 (the month since 2020), and then extract the data in
the monthly_confirmed field. Export the data to a new field named label and export
the returned data to a new table named data.

from pyspark.sql.window import Window

import pyspark.sql.functions as F
data = data_origin.filter("`country/region`=='US'")
w = Window.orderBy('year','month')

data = data.withColumn('feature',F.row_number().over(w)).selectExpr('feature','monthly_confirmed as label')


data.show()

g. Import dependencies:

from pyspark.ml.regression import RandomForestRegressor

from pyspark.ml.feature import VectorAssembler


from pyspark.ml.evaluation import RegressionEvaluator

h. Use the VectorAssembler function to convert the feature column in the data table
into the vector format and output a new column named FeatureVec. Retain the new
table name as data. In the new data table, the FeatureVec column is added. You
only need to copy and paste the following code to the CLI:

data = VectorAssembler(inputCols=['feature'],outputCol='FeatureVec').transform(data)

Screenshot requirements:
Take a screenshot after uploading data (in step d) and save it as 4-1-1uploaded.
 Subtask 2: Analyze and visualize the regression using PySpark.
a. Use the data.randomSplit method to divide the data in the data table into the
training set trainingData and the test set testData (proportion: 20%) and set the
seed of random number to 0 (seed=0).
b. Use the RandomForestRegressor method to train a random forest regression model;
specify featuresCol='FeatureVec' retain the default values for other parameters; and
train trainingData.
Name the trained model model.
c. Use model to perform prediction on testData.
Name the output predictions and display the prediction output.
d. Use the RegressionEvaluator method and specify its parameters labelCol="label",
predictionCol="prediction", metricName="rmse" to compare the real value label
and the prediction value prediction.
Save the results to variable rmse and run the following command to output the
results:
print("Root Mean Squared Error (RMSE) on test data = %g" % rmse).
e. Use model to fit the full data in data.
Name the output full_predict and print it.

2022-06-17 Huawei confidential. No spreading without permission. Page 32 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

f. Use the toPandas method to convert full_predict to Pandas DataFrame. Use the
matplotlib.pyplot module to draw a line chart with the feature column in
full_predict as the X-axis and the label and prediction columns as the Y-axes. The
legends are true_case and predicted_case. The line will look something like this:

Screenshot requirements:
a. Take a screenshot of the code you used for splitting the dataset and save it as 4-2-
1randomsplit.
b. Take a screenshot of the code you used for training the model and save it as 4-2-
2model.
c. Take a screenshot of the code you used in this step and save it as 4-2-3testpredict.
d. Take a screenshot of the code you used in this step and save it as 4-2-4evaluate.
e. Take a screenshot of the code you used in this step and save it as 4-2-5fullpredict.
f. Take a screenshot of the code you used and the output line chart and save it as 4-2-
6visualization.

3.4 AI
3.4.1 Scenarios
AI applications require a lot of high quality data. To obtain enough high-quality and class-
balanced samples, neural networks can be used to generate new data based on existing data
and to expand datasets.

3.4.2 Exam Requirements


1. Take screenshots of all key steps and save them in the format 1-1-1xx.png and 1-1-
2xx.png.
2. Strictly follow the configuration and naming requirements described in the exam.
3. PuTTY and WinSCP are recommended for logging in to Linux servers and transferring
files.
4. Unless otherwise specified, use resources in the AP-Hong Kong region.

2022-06-17 Huawei confidential. No spreading without permission. Page 33 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

3.4.3 Exam Resources

3.4.3.1 Tools
Tool Description Available At

ModelArts ExeML for quick model https://console.huaweicloud.com/modelarts/?r


development egion=cn-north-4&locale=en-us#/dashboard

Jupyter Interactive notebook that http://codingpy.com/article/getting-started-


notebook supports the Python with-jupyter-notebook-part-1/
language

Matplotlib Python-based gallery Installation command: pip install matplotlib


Import command: import matplotlib

PIL Python-based image Installation command: pip install pillow


processing library Import command: import PIL

Note: If you have any other questions, see the appendix.

3.4.3.2 Dataset Description


The dataset used in the exam is an open-source flower classification dataset containing five
types of flowers: daisies, dandelions, roses, sunflowers, and tulips. There are 300 pictures each
of daisies, dandelions, roses, and tulips, but only 256 pictures of sunflowers. You need to use
Generative Adversarial Network (GAN) to generate new sunflower images based on the
existing sunflower images.

Data sample

3.4.3.3 Exam Requirements


a. Carefully read the Exam Guide, Appendix 4, and exam tasks.
b. If multiple solutions are available for a task, select the best one.

If you do not strictly follow the preceding instructions, you may fail to earn any points.

3.4.4 Exam Tasks

3.4.4.1 Lab Tasks


Each step in a task is scored separately. Please arrange your exam time appropriately.

2022-06-17 Huawei confidential. No spreading without permission. Page 34 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Appendix 4 is provided as a reference.

3.4.4.2 Task 1: Obtaining and preprocessing data (60 points)


 Subtask 1: Obtain the dataset image names.
a. Import the OS, NumPy, Matplotlib, Random, and PIL libraries.
b. Create a directory for the dataset folder, read the names of images in the dataset,
and print the names of the first five images.
Screenshot requirements:
a. Take a screenshot of the codes you used and the returned output and save it as 1-1-
1image-attribute.
 Subtask 2: Data Conversion.
a. Read 256 images in the dataset.
b. Convert the images to grayscale and resize them to a 64 x 64 NumPy array.
c. Print the array shape.
Screenshot requirements:
a. Take a screenshot of the code you used and the returned output and save it as 1-2-
1image-shape.
 Subtask 3: Visualize and preprocess the data.
a. Use matplot to visualize data and randomly print nine pictures in the form of 3x3
grid.
b. Flatten the 256 images into a one-dimensional vector.
c. Normalize the images.
Screenshot requirements:
a. Take a screenshot of the code you used and the returned output and save it as 1-3-
1image-flatten.

Task 2: Building a GAN (55 points)


 Subtask 1: Build a generator.
a. Import the TensorFlow and Keras libraries and set up the generator neural network
based on the summary result listed in the figure below.
b. Set hyperparameter alpha of LeakyReLU to 0.2, hyperparameter Momentum of
BatchNormalization to 0.8, and the activation function of the output layer to tanh.
Print the generator network information.

2022-06-17 Huawei confidential. No spreading without permission. Page 35 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Screenshot requirements:
a. Take a screenshot of the code you used and the summary result of the generator.
Save the image as 2-1-1generator.
 Subtask 2: Build a discriminator.
a. Set up a discriminator neural network based on the summary result listed in the
figure below. Ensure that the input of the discriminator is the same as the output of
the generator.
b. Use sigmoid activation for the last fully connected layer. For other layers, set
hyperparameter alpha of the LeakyReLU activation function to 0.2.
c. Compile the model with binary cross-entropy loss and Adam optimizer. Set
hyperparameter lr to 0.002, beta_1 to 0.5, and the model evaluation indicator to
accuracy. Print the discriminator network information.

2022-06-17 Huawei confidential. No spreading without permission. Page 36 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

Screenshot requirements:
a. Take a screenshot of the code you used and the returned output and save it as 2-2-
1descriminator
 Subtask 3: Combine the generator and discriminator to construct a GAN.
a. Connect the generator and discriminator based on the summary result listed in the
figure below; define the GAN input as the generator input; send the images
generated by the generator to the discriminator; and define the GAN output as the
discriminator output.
b. Compile the model with binary cross-entropy loss function and Adam optimizer. Set
hyperparameter lr to 0.005, beta_1 to 0.5, and the model evaluation indicator to
accuracy.

Screenshot requirements:
a. Take a screenshot of the code you used and the returned output and save it as 2-3-
1GAN.

Task 3: Training and visualizing the model (35 points)


 Subtask 1: Build functions to generate images and visualize losses

2022-06-17 Huawei confidential. No spreading without permission. Page 37 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

a. Generate the Gaussian noise and input the noise to the generator to generate
images.
b. Switch the pixel value of the images back to (0,255) and convert the vector to a 64 x
64 matrix. Randomly print ten grayscale images.
c. Obtain the generator and discriminator losses from the loss dictionary to construct a
loss visualization function.
d. Label the two types of losses. Set the X axis to the training epoch and the Y axis to
the loss. A diagram legend must be included.
Screenshot requirements:
a. Take a screenshot of the code you used and the returned output and save it as 3-2-
1loss
 Subtask 2: Model training.
a. Create a training loop, set the number of model training epochs to 10 and the
training batch size to 32. Randomly extract images from the dataset for training in
batches, and label the real images with a 1.
b. Fix the discriminator to create a generator and input Gaussian noise to generate fake
images. Then label the fake images with a 0 and obtain the loss of the generator.
c. Unfix discriminator parameters and use the discriminator to determine whether an
input image is true or fake. The discriminator loss is the average value of the true
images identification loss and fake images identification loss.
d. Build a loss dictionary for storing the generator and discriminator losses occurred in
each batch.
Screenshot requirements:
a. Take a screenshot of the code you used and the returned output and save it as 3-1-
1model-training-10.
 Subtask 3: Visualize the training results.
a. Call the images generation and losses visualization functions built in subtask 1.
b. Print the images generated by GAN every ten epochs. Print the loss curves chart of
the generator and discriminator every ten epochs.
Screenshot requirements:
a. Take a screenshot of the code you used and the returned output and save it as 3-3-
1visualization.

Appendix 4
Generate images of animated characters images through GAN.

This example uses Keras to build a generator and discriminator, and it uses an animation
dataset to train a model for generating animation character images. The generated images
can be used for subsequent model training.

1. Import third-party libraries.


import os
import numpy as np

2022-06-17 Huawei confidential. No spreading without permission. Page 38 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

import matplotlib.pyplot as plt


import random
from PIL import Image

2. Import and read the data.


# Define the dataset folder.
dataset_dir = "dataset"
# Read the names of the images in the folder.
imgname = os.listdir(dataset_dir)

image_size=64
input_images=[]
for file in filename:
# Read an image.
img=Image.open(dataset_dir+"/"+file)
# Resize all images to 64 x 64 pixel.
img=img.resize((image_size, image_size))
# Convert all images to grayscale.
img=img.convert("L")
# Convert all images into a NumPy array.
img=np.asarray(img)
# Put all images in the list.
input_images.append(img)
# Convert the image list into a NumPy array.
input_images = np.asarray(input_images)
print(input_images.shape)

# Output results
(256, 64, 64)
#Create a canvas and print four images.
plt.figure()
for i in range(4):
plt.subplot(2,2,i+1)
plt.imshow(input_images[i])
plt.show()

# Output results

# Convert the images to a one-dimensional vector with 4096 stretch length.


input_images = input_images.reshape(256, image_size*image_size)
# Normalize the images.
input_images = (input_images.astype('float32')-127.5)/127.5

3. Define a generator.

2022-06-17 Huawei confidential. No spreading without permission. Page 39 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

# Import the TensorFlow and Keras libraries required for modeling.


from tensorflow import keras
from tensorflow.keras.models import Sequential, Model
from tensorflow.keras.layers import Conv2D,Input, Dense, Dropout, Activation, Flatten, BatchNormalization
from tensorflow.keras.layers import LeakyReLU
from tensorflow.keras.optimizers import Adam

# Define the length of the noise vector.


noise_length = 100

# Define a generator g.
g = Sequential()

# Create a fully connected layer with 1024 neurons. Set the input layer size same as the noise vector length.
g.add(Dense(1024, input_dim=noise_length))
# Use LeakyReLU as the activation function. When x < 0, y = 0.2x.
g.add(LeakyReLU(alpha=0.2))
# Add the BN layer to reduce the center offset.
g.add(BatchNormalization(momentum=0.8))

# Add the second fully connected layer with 4096 neurons. Use tanh as the activation function.
g.add(Dense(4096))
# Select LeakyReLU as the activation function. When x < 0, y = 0.2x.
g.add(LeakyReLU(alpha=0.2))
# Add the BN layer to reduce the center offset.
g.add(BatchNormalization(momentum=0.8))

# Add the second fully connected layer with 512 neurons.


g.add(Dense(512))
# Use LeakyReLU as the activation function. When x < 0, y = 0.2x.
g.add(LeakyReLU(alpha=0.2))
# Add the BN layer to reduce the center offset.
g.add(BatchNormalization(momentum=0.8))

# Add the third fully connected layer with 1024 neurons.


g.add(Dense(2048))
# Use LeakyReLU as the activation function. When x < 0, y = 0.2x.
g.add(LeakyReLU(alpha=0.2))
# Add the BN layer to reduce the center offset.
g.add(BatchNormalization(momentum=0.8))

# Add an output layer. Each output image contains 4096 pixels. Use the tanh activation function to map the output to
(-1, 1).
g.add(Dense(4096))

# Print the summary of generator.


g.summary(0)

# Output result

2022-06-17 Huawei confidential. No spreading without permission. Page 40 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

4. Define a discriminator.
# Set the optimizer of the discriminator to Adam. Set a relatively small learning rate.
d_adam = Adam (lr = 0.0002, beta_1 = 0.5)
# Construct a discriminator.
d = Sequential()
# Set the number of neurons at the discriminator input layer as same as that of the generator output layer.
d.add(Dense(1024, input_dim = 4096))
# Select LeakyReLU as the activation function.
d.add(LeakyReLU())
# Create the next fully connected layer with 256 neurons.
d.add(Dense(256))
# The discriminator output layer has only one neuron to identify whether an image is true or fake. Use sigmoid to map
the output of the discriminator to (0,1). 0 indicates fake and 1 indicates true.
d.add (Dense (1, activation = 'sigmoid'))
# The discriminator uses the cross entropy loss function and sets accuracy as an indicator.
d.compile (loss = 'binary_crossentropy', optimizer = d_adam, metrics = ['accuracy'])
# Print the discriminator information.
d.summary ()

# Output results

2022-06-17 Huawei confidential. No spreading without permission. Page 41 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

5. Combine the generator and discriminator to build a GAN.


# Set the GAN optimizer to Adam.
gan_adam = Adam ()
# Fix the discriminator parameters.
d.trainable = False
# Define the GAN input.
gan_input = Input (shape = (noise_length,))
# Define the generated images.
generated_image = g (gan_input)
# Define the GAN output.
gan_output = d (generated_image)
# Define the GAN model and combine the generator and discriminator.
gan = Model (gan_input, gan_output)
# GAN uses the cross entropy cost function and sets accuracy as an indicator.
gan.compile (loss = 'binary_crossentropy', optimizer = gan_adam, metrics = ['accuracy'])
# Print the GAN information.
gan.summary ()

#Output results

6. Define the input noise of the generator


# Define a function to print the generated images.
def plot_generated (n_ex = 10, dim =(1, 10), figsize = (12,2)):
# Generate Gaussian noise.
noise = np.random.normal(0,1,size = (n_ex, noise_length))
# Input the noise to the generator to obtain the generated images.
generated_images = g.predict(noise)
# Convert the size of the images back to (0,255).

2022-06-17 Huawei confidential. No spreading without permission. Page 42 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

generated_images = generated_images * 127.5+127.5


# Convert the generated image vector into a matrix.
generated_images = generated_images.reshape(n_ex, 64, 64)
plt.figure(figsize = figsize)
for i in range(generated_images.shape[0]):
plt.subplot(dim[0], dim[1],i+1)
#Display the grayscale images.
plt.imshow(generated_images[i],)
plt.axis('off')
plt.tight_layout()
plt.show()

7. Draw the loss curve.


# Define a function to draw the losses.
def plot_loss(losses):
d_loss = [v[0] for v in losses["D"]]
g_loss = [v[0] for v in losses["G"]]
plt.figure(figsize=(5,4))
plt.plot(d_loss, label = "Discriminator loss")
plt.plot(g_loss, label = "Generator loss")
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.show()

8. Train the model.


# Set the number of model training rounds.
num_epochs = 500
# Set the batch size to a relatively big number (since the Batch Normalization is used).
batch_size = 16
# Define a loss dictionary. Use D to store the discriminator loss and G to store the generator loss.
losses = {"D":[],"G":[]}
# Calculate how many batches are required in each training epoch.
batchCount = int(input_images.shape[0] / batch_size)
# Train the loop.
for epochs in range(num_epochs+1):
for _ in range(batchCount):
# Generate Gaussian noise.
noise = np.random.normal(0, 1, size = (batch_size, noise_length))
# Define the label of true images.
y_true = np.ones(batch_size)
# Fix the discriminator parameters.
d.trainable = False
# Train the generator.
g_loss = gan.train_on_batch(noise, y_true)
# Generate images.
fake_img = g.predict(noise)
# Randomly extract data from the dataset to train the model.
true_img = input_images[np.random.randint(0, input_images.shape[0], size=batch_size)]
# Define the label of fake images.
y_fake = np.zeros(batch_size)
# Unfix the discriminator parameters.
d.trainable = True

d_loss_true = d.train_on_batch(true_img, y_true)


# Record the loss of fake image prediction when the input is a fake image:
d_loss_fake = d.train_on_batch(fake_img, y_fake)

2022-06-17 Huawei confidential. No spreading without permission. Page 43 of 44


2021-2022 Huawei ICT Competition Global Finals
Cloud Track Exam Hands-on Practice

# Set the discriminator loss to the average value of the true images identification loss and fake images
identification loss.
d_loss = 0.5*np.add(d_loss_true, d_loss_fake)
# Add the discriminator loss of the current training batch to the loss dictionary.
losses["D"].append(d_loss)
# Add the generator loss of the current training batch to the loss dictionary.
losses["G"].append(g_loss)
# Print the generated images for each five training batches.
if epochs%10==0:
plot_generated()
# Print the loss and accuracy value.
print('-'*5, 'Epoch %d' % epochs, '-'*5)
print("Generator Loss:",g_loss[0])
print("Discriminator Loss:",d_loss[0])
if epochs%10==0:
plot_loss(losses)

#Output results

2022-06-17 Huawei confidential. No spreading without permission. Page 44 of 44

You might also like