实践笔记 基于鲲鹏服务器的打砖块小游戏部署

举报
千江有水千江月 发表于 2024/12/20 23:39:21 2024/12/20
【摘要】 活动链接【开发者日·创享峰会专场】体验官:体验六大实践项目,领开发者定制好礼【开发者空间实践指导】基于鲲鹏服务器的打砖块小游戏部署 操作步骤在开发者空间中配置云主机显示开机中,点击进入桌面loading…成功进入桌面,可以把保持展开的勾给取消掉,它就自动隐藏了。 跟随实验手册,开始输入命令terminal窗口别关,这里有后续需要的密码和IPdeveloper@developer:~/Des...

活动链接

【开发者日·创享峰会专场】体验官:体验六大实践项目,领开发者定制好礼

【开发者空间实践指导】基于鲲鹏服务器的打砖块小游戏部署

操作步骤

在开发者空间中配置云主机

显示开机中,点击进入桌面

loading…

成功进入桌面,可以把保持展开的勾给取消掉,它就自动隐藏了。

跟随实验手册,开始输入命令

  • terminal窗口别关,这里有后续需要的密码和IP
developer@developer:~/Desktop$ hcd deploy --password abcd1234! --time 1800
(2024-12-20 21:53:38) [hcd-info ]: start to execute the deployment task
(2024-12-20 21:53:38) [hcd-info ]: prepare to check whether previous resource is deploying
(2024-12-20 21:53:38) [hcd-info ]: check there is no previously deploying resource PASSED
(2024-12-20 21:53:38) [hcd-info ]: prepare to check whether exist previously deployed resources
(2024-12-20 21:53:38) [hcd-info ]: check there is no previously deployed resources PASSED
(2024-12-20 21:53:38) [hcd-info ]: prepare to check whether remaining available deployment time is enough
(2024-12-20 21:53:38) [hcd-info ]: expect 1800 seconds, available time is 129090 seconds
(2024-12-20 21:53:38) [hcd-info ]: the actual deployment time of current project is 1800 seconds
(2024-12-20 21:53:38) [hcd-info ]: check remaining available deployment time PASSED
(2024-12-20 21:53:38) [hcd-info ]: prepare to create resource stack
(2024-12-20 21:53:38) [hcd-info ]: stack name is stack-e834242a-7a6e-446e-968e-eb34d82a8285
(2024-12-20 21:53:38) [hcd-info ]: project name is project-9f98b783-79b5-4af3-8af6-5aa5df62d249
(2024-12-20 21:53:39) [hcd-info ]: SUCCEED to create resource stack
(2024-12-20 21:53:39) [hcd-info ]: prepare to get deploy progress
(2024-12-20 21:53:36) [hcd-info ]: Creating required resource now
(2024-12-20 21:53:36) [hcd-info ]: Creating required resource now
(2024-12-20 21:53:38) [hcd-info ]: Plan: 3 to add, 0 to change, 0 to destroy.
(2024-12-20 21:53:38) [hcd-info ]: huaweicloud_compute_instance.ecs: Creating...
(2024-12-20 21:53:36) [hcd-info ]: Creating required resource now
(2024-12-20 21:53:36) [hcd-info ]: Creating required resource now
(2024-12-20 21:53:36) [hcd-info ]: Creating required resource now
(2024-12-20 21:53:36) [hcd-info ]: Creating required resource now
(2024-12-20 21:53:36) [hcd-info ]: Creating required resource now
(2024-12-20 21:53:36) [hcd-info ]: Creating required resource now
(2024-12-20 21:53:38) [hcd-info ]: Plan: 3 to add, 0 to change, 0 to destroy.
(2024-12-20 21:53:36) [hcd-info ]: Creating required resource now
(2024-12-20 21:53:38) [hcd-info ]: Plan: 3 to add, 0 to change, 0 to destroy.
(2024-12-20 21:53:38) [hcd-info ]: huaweicloud_compute_instance.ecs: Creating...
(2024-12-20 21:53:48) [hcd-info ]: huaweicloud_compute_instance.ecs: Still creating... [10s elapsed]
(2024-12-20 21:53:58) [hcd-info ]: huaweicloud_compute_instance.ecs: Still creating... [20s elapsed]
(2024-12-20 21:54:08) [hcd-info ]: huaweicloud_compute_instance.ecs: Still creating... [30s elapsed]
(2024-12-20 21:54:18) [hcd-info ]: huaweicloud_compute_instance.ecs: Still creating... [40s elapsed]
(2024-12-20 21:54:28) [hcd-info ]: huaweicloud_compute_instance.ecs: Still creating... [50s elapsed]
(2024-12-20 21:54:35) [hcd-info ]: huaweicloud_compute_instance.ecs: Creation complete after 56s [id=6c549431-2173-418a-a3ae-33c2e9d23ea3]
(2024-12-20 21:54:35) [hcd-info ]: huaweicloud_coc_script.coc_script: Creating...
(2024-12-20 21:54:36) [hcd-info ]: huaweicloud_coc_script.coc_script: Creation complete after 1s [id=SC20241220215439012eb5f42]
(2024-12-20 21:54:36) [hcd-info ]: huaweicloud_coc_script_execute.coc_script_execute: Creating...
(2024-12-20 21:54:46) [hcd-info ]: huaweicloud_coc_script_execute.coc_script_execute: Still creating... [10s elapsed]
(2024-12-20 21:54:56) [hcd-info ]: huaweicloud_coc_script_execute.coc_script_execute: Still creating... [20s elapsed]
(2024-12-20 21:55:06) [hcd-info ]: huaweicloud_coc_script_execute.coc_script_execute: Still creating... [30s elapsed]
(2024-12-20 21:55:16) [hcd-info ]: huaweicloud_coc_script_execute.coc_script_execute: Still creating... [40s elapsed]
(2024-12-20 21:55:26) [hcd-info ]: huaweicloud_coc_script_execute.coc_script_execute: Still creating... [50s elapsed]
(2024-12-20 21:55:36) [hcd-info ]: huaweicloud_coc_script_execute.coc_script_execute: Still creating... [1m0s elapsed]
(2024-12-20 21:55:41) [hcd-info ]: huaweicloud_coc_script_execute.coc_script_execute: Creation complete after 1m6s [id=SCT2024122021553001dfd6d5f]
(2024-12-20 21:55:41) [hcd-info ]: Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
(2024-12-20 21:55:46) [hcd-info ]: Apply required resource success. 
(2024-12-20 21:56:07) [hcd-info ]: SUCCEED to create resources according to current resource stack
(2024-12-20 21:56:07) [hcd-info ]: prepare to get address of deployed project
(2024-12-20 21:56:07) [hcd-info ]: SUCCEED to get address of deployed project
(2024-12-20 21:56:07) [hcd-warn ]: prepare to running your application on https://113.44.14.40:8084 to provide service
(2024-12-20 21:56:07) [hcd-warn ]: wait until the application running, press ctrl-c to force to exit wait
(2024-12-20 21:56:07) [hcd-info ]: deployed project is RUNNING and start to provide services
(2024-12-20 21:56:07) [hcd-info ]: application is running, service addr: https://113.44.14.40:8084


ssh登录

这里有三步,ssh+yes+password。

感觉输入法切换有些不太好,有机会提个建议。

developer@developer:~/Desktop$ ssh root@113.44.14.40
The authenticity of host '113.44.14.40 (113.44.14.40)' can't be established.
ED25519 key fingerprint is SHA256:Mf5RossljJiSX7oVUy2+rBBeI8+XeqinKGGf5jntgRU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '113.44.14.40' (ED25519) to the list of known hosts.
root@113.44.14.40's password: 
Last login: Fri Dec 20 21:55:35 2024
	
	Welcome to Huawei Cloud Service

[root@hcd-ecs-1353 ~]# 

新建html文件

[root@hcd-ecs-1353 ~]# mkdir game
[root@hcd-ecs-1353 ~]# cd game
[root@hcd-ecs-1353 game]# vi game.html
[root@hcd-ecs-1353 game]# 

案例中心

案例中心点开后是一个网页,感兴趣的同学可以自行探索。

安装python

安装python的过程中,会看到很多依赖包。生产环境中,切记谨慎对待系统升级操作。

一个升级,把底层依赖包的版本改了,极有可能导致整个工程的崩溃。

[root@hcd-ecs-1353 game]# sudo yum install -y python3 
已加载插件:fastestmirror
Determining fastest mirrors
base                                                     | 3.6 kB     00:00     
epel                                                     | 5.4 kB     00:00     
extras                                                   | 2.9 kB     00:00     
updates                                                  | 2.9 kB     00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 python3.aarch64.0.3.6.8-21.el7_9 将被 安装
--> 正在处理依赖关系 python3-libs(aarch-64) = 3.6.8-21.el7_9,它被软件包 python3-3.6.8-21.el7_9.aarch64 需要
--> 正在处理依赖关系 python3-setuptools,它被软件包 python3-3.6.8-21.el7_9.aarch64 需要
--> 正在处理依赖关系 python3-pip,它被软件包 python3-3.6.8-21.el7_9.aarch64 需要
--> 正在处理依赖关系 libpython3.6m.so.1.0()(64bit),它被软件包 python3-3.6.8-21.el7_9.aarch64 需要
--> 正在检查事务
---> 软件包 python3-libs.aarch64.0.3.6.8-21.el7_9 将被 安装
--> 正在处理依赖关系 libtirpc.so.1()(64bit),它被软件包 python3-libs-3.6.8-21.el7_9.aarch64 需要
---> 软件包 python3-pip.noarch.0.9.0.3-8.el7 将被 安装
---> 软件包 python3-setuptools.noarch.0.39.2.0-10.el7 将被 安装
--> 正在检查事务
---> 软件包 libtirpc.aarch64.0.0.2.4-0.16.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================
 Package                 架构         版本                   源            大小
================================================================================
正在安装:
 python3                 aarch64      3.6.8-21.el7_9         updates       70 k
为依赖而安装:
 libtirpc                aarch64      0.2.4-0.16.el7         base          84 k
 python3-libs            aarch64      3.6.8-21.el7_9         updates      6.5 M
 python3-pip             noarch       9.0.3-8.el7            base         1.6 M
 python3-setuptools      noarch       39.2.0-10.el7          base         629 k

事务概要
================================================================================
安装  1 软件包 (+4 依赖软件包)

总下载量:8.9 M
安装大小:50 M
Downloading packages:
(1/5): python3-3.6.8-21.el7_9.aarch64.rpm                  |  70 kB   00:00     
(2/5): libtirpc-0.2.4-0.16.el7.aarch64.rpm                 |  84 kB   00:00     
(3/5): python3-pip-9.0.3-8.el7.noarch.rpm                  | 1.6 MB   00:00     
(4/5): python3-setuptools-39.2.0-10.el7.noarch.rpm         | 629 kB   00:00     
(5/5): python3-libs-3.6.8-21.el7_9.aarch64.rpm             | 6.5 MB   00:00     
--------------------------------------------------------------------------------
总计                                                15 MB/s | 8.9 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : libtirpc-0.2.4-0.16.el7.aarch64                             1/5 
  正在安装    : python3-libs-3.6.8-21.el7_9.aarch64                         2/5 
  正在安装    : python3-setuptools-39.2.0-10.el7.noarch                     3/5 
  正在安装    : python3-3.6.8-21.el7_9.aarch64                              4/5 
  正在安装    : python3-pip-9.0.3-8.el7.noarch                              5/5 
  验证中      : python3-pip-9.0.3-8.el7.noarch                              1/5 
  验证中      : python3-libs-3.6.8-21.el7_9.aarch64                         2/5 
  验证中      : libtirpc-0.2.4-0.16.el7.aarch64                             3/5 
  验证中      : python3-setuptools-39.2.0-10.el7.noarch                     4/5 
  验证中      : python3-3.6.8-21.el7_9.aarch64                              5/5 

已安装:
  python3.aarch64 0:3.6.8-21.el7_9                                              

作为依赖被安装:
  libtirpc.aarch64 0:0.2.4-0.16.el7  python3-libs.aarch64 0:3.6.8-21.el7_9     
  python3-pip.noarch 0:9.0.3-8.el7   python3-setuptools.noarch 0:39.2.0-10.el7 

完毕!
[root@hcd-ecs-1353 game]# python3 --version
Python 3.6.8

启动web server与玩游戏

[root@hcd-ecs-1353 game]# python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

查找错误点

我见到网页上显示着残缺的html代码,估计是编辑game.html时,复制粘贴出了点问题。

右键查看源代码

终止webserver,更正game.html,重新运行websever,恢复正常!

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。