wps栏目上的运服务怎么没有了
579
2022-05-28
1、如果是在弹性云服务器上部署就不用更换yum源,虚拟机上面模拟首先更换yum。
https://developer.aliyun.com/mirror/ ##阿里镜像源
2、开始安装LAMP服务
[root@localhost ~]# yum -y install httpd php php-fpm php-server php-mysql ##分别安装httpd php php-server php-fpm php-mysql等服务
3、重启httpd和php
[root@node-0002 ~]# nohup python -m SimpleHTTPServer 80 > /dev/null 2>&1 & 开放80端口 [1] 8110 [root@node-0002 ~]# curl 127.0.0.1:80
4、web界面验证http是否启动
如果不能访问:
(1)弹性云主机去安全组添加:http 80端口
(2)虚拟机里面的话:
[root@localhost ~]# systemctl start firewalld ##重启防火墙 [root@localhost ~]# firewall-cmd --list-ports ##查看端口 ##这里显示没有端口开启 [root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent ##开启tcp/80这个端口 success [root@localhost ~]# firewall-cmd --reload ##启动端口 success [root@localhost ~]# firewall-cmd --list-ports 80/tcp ##再次查看就会发现80端口已经开启
5、卸载Mariadb数据库(卸载mariadb数据库是为了防止密码冲突)
[root@localhost ~]# yum -y remove mariadb-server 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com ##我这里用的是虚拟机源也是阿里的镜像源
6、重启Mariadb并重置密码:
[root@localhost ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm [root@localhost ~]# yum -y install mysql57-community-release-el7-8.noarch.rpm Loaded plugins: fastestmirror [root@localhost ~]# yum -y install mysql-community-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile [root@localhost ~]# systemctl restart mysqld [root@localhost ~]# systemctl enable mysqld [root@localhost ~]# grep -Eo "for root@localhost:.*" /var/log/mysqld.log |sed -r "s/(for.*localhost:)(.*)//" gc 7、登入数据库设置权限 [root@localhost ~]# mysql -uroot -pHuawei@123 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.35 MySQL Community Server (GPL) Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> 参考:https://www.cnblogs.com/sanduzxcvbnm/p/9789236.html [root@localhost ~]# mysql -uroot -pHuawei@123 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.35 MySQL Community Server (GPL) Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set host='%' where user='root' limit 1; ##配置MySQL远程连接 Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges; ##刷新权限 Query OK, 0 rows affected (0.00 sec) mysql> exit Bye 验证: [root@localhost ~]# mysql -h 172.16.175.85 -u root -pHuawei@123 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.7.35 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> [root@localhost ~]# mysql -uroot -pHuawei@123 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql> create database Discuz; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | Discuz | | mysql | | performance_schema | | sys | +--------------------+ 5 rows in set (0.00 sec) mysql> 8、部署网站服务: [root@localhost ~]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip -bash: wget: 未找到命令 ##没有安装wget这个命令 [root@localhost ~]# yum -y install wget ##yum安装 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 正在解决依赖关系 --> 正在检查事务 [root@localhost ~]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip ##拖取资料包 --2021-10-07 16:10:21-- http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip 正在解析主机 download.comsenz.com (download.comsenz.com)... 223.111.194.252, 223.111.112.109, 36.156.85.208, ... 正在连接 download.comsenz.com (download.comsenz.com)|223.111.194.252|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 301 Moved Permanently 位置:https://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip [跟随至新的 URL] --2021-10-07 16:10:21-- https://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip 正在连接 download.comsenz.com (download.comsenz.com)|223.111.194.252|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:12486773 (12M) [application/zip] 正在保存至: “Discuz_X3.2_SC_UTF8.zip” 100%[==================================================>] 12,486,773 3.10MB/s 用时 4.0s 2021-10-07 16:10:26 (2.96 MB/s) - 已保存 “Discuz_X3.2_SC_UTF8.zip” [12486773/12486773]) [root@localhost ~]# ll ##查看 总用量 12200 -rw-------. 1 root root 1318 10月 3 23:46 anaconda-ks.cfg -rw-r--r--. 1 root root 12486773 4月 8 2020 Discuz_X3.2_SC_UTF8.zip [root@localhost ~]# [root@localhost ~]# yum -y install unzip ##下载unzip软件 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com [root@localhost ~]# unzip Discuz_X3.2_SC_UTF8.zip ##解压 [root@localhost ~]# ll ##查看解压包 总用量 12204 -rw-------. 1 root root 1318 10月 3 23:46 anaconda-ks.cfg -rw-r--r--. 1 root root 12486773 4月 8 2020 Discuz_X3.2_SC_UTF8.zip drwxr-xr-x. 2 root root 102 5月 31 2016 readme drwxr-xr-x. 12 root root 4096 5月 31 2016 upload drwxr-xr-x. 4 root root 72 5月 31 2016 utility [root@localhost ~]# cp -rf upload/* /var/www/html/ ##把解压的包cp到另一个目录去 [root@localhost ~]# [root@localhost ~]# chmod -R 777 /var/www/html/ ##赋予777的权限 [root@localhost ~]# [root@localhost ~]# systemctl restart httpd ##重启httpd服务 [root@localhost ~]# systemctl enable httpd [root@localhost ~]# 安装包 python-packages-centos]# python3 -m pip install --upgrade pip-21.1.1-py3-none-any.whl [root@openstack python-packages-centos]# pip3 show huaweicloud-sdk-python Name: huaweicloud-sdk-python Version: 1.0.28 Summary: An SDK for building applications to work with OpenStack Home-page: https://github.com/huaweicloud/huaweicloud-sdk-python Author: huawei Author-email: UNKNOWN License: UNKNOWN Location: /usr/local/lib/python3.6/site-packages Requires: six, pbr, deprecation, keystoneauth1, stevedore Required-by: python-packages-centos]# python3 -m pip install --upgrade pip python-packages-centos]# python3 -m pip install --upgrade huaweicloud-sdk-python HUAWEICloud-Python]# pip3 install huaweicloudsdkcore HUAWEICloud-Python]# pip3 install huaweicloudsdkecs 获取token: [root@openstack HUAWEICloud-Python]# cat huaweicloudapi.py from openstack import connection """ 两种获取华为云Python API认证连接方式: 1.通过账号密码方式 (1) 输入账号密码和domain (2) 其他参数禁止修改 2.通过AKSK方式 (1) 输入AKSK和项目ID (2) 其他参数禁止修改 以上两种方式任选一种 """ # create connection #def get_conn_user(): # conn = connection.Connection( # auth_url="https://iam.myhuaweicloud.com/v3", # 认证地址 # username="CSCCxxxx", # 帐号名 # password="xxxxxx", # 帐号密码 # user_domain_name="CSCCxxxx", # 帐号名(主账号名) # project_name="cn-north-4" # 项目名, cn-north-4 华北-北京四 # ) # return conn # create connection def get_conn_aksk(): conn = connection.Connection( cloud="myhuaweicloud.com", # 认证地址 ak="Z7BHZROSUFSYRRHSO55Q", # Access Key Id sk="USlhjw9Jazz8zWEoyU1HG0ROCwQvgoqYcxgw8phe", # Secret Access Key project_id="0ddb21707c0091b52f43c001b7c60148", # 项目id, cn-north-4 华北-北京四 region="cn-southwest-2" # 项目名, cn-north-4 华北-北京四 ) return conn 创建VPC 在云服务器的 /root/huawei 目录下编写 create_vpc.py 文件,并导入赛项提供的 huaweicloudapi.py 文件获取连接。编写 Python 代码,调用 vpcv1 类,创建华为云的虚拟私有云,具体要求为 (1) 虚拟私有云名称:chinaskills_vpc; (2) 如果虚拟私有云已经存在,代码中需要先删除; (3) 使用其源码的 get 方法输出此虚拟私有云的详细信息(状态要求为 OK) import huaweicloudapi as api import time def create_vpc(): vpc={ "name":sub_name, #这个名字定义为变量 "description":"test", "cidr":"172.16.0.0/16" } return conn.vpcv1.create_vpc(**vpc) #创建vpc对象 def find_vpc(): return conn.vpcv1.find_vpc(sub_name) #发现vpc def create_and_get(): sub_id=create_vpc().id time.sleep(5) #停顿5秒get到vpc状态 print(conn.vpcv1.get_vpc(sub_id)) #打印出vpc_id if __name__ == "__main__": conn = api.get_conn_aksk() #赋权,,调取huaweiclod的ak、sk sub_name="chinaskill_vpc" #给上面的 名字变量赋名 if not find_vpc(): #如果发现不了vpc 这里是删除重名 create_and_get() #就创建他 else: conn.vpcv1.delete_vpc(find_vpc().id) #就删除他 time.sleep(5) create_and_get() VPC_subnet 在云服务器的/root/huawei 目录下编写 create_subnet.py 文件,并导入赛项提供的 huaweicloudapi.py 文件获取连接。编写 Python 代码,调用 vpcv1 类,创建华为云的虚拟私有云子网,具体要求为 (1) 使用虚拟私有云名称获取其 ID(不允许直接填写虚拟私有云 ID); (2) 虚拟私有云子网名称:chinaskills_subnet; (3) 虚拟私有云子网网段:192.168.100.0/24; (4) 虚拟私有云子网网关:192.168.100.1; (5) 虚拟私有云子网可用区域:cn-north-4a; (6) 如果虚拟私有云子网已经存在,代码中需要先删除; (7) 使用其源码的 get 方法输出此虚拟私有云子网的详细信息(状态要求为 ACTIVE) import huaweicloudapi as api import time def create_subnet(): subnet={ "name": sub_name, "cidr": "172.16.0.0/16", "vpc_id": vpc_id, "gateway_ip": "172.16.0.1", # "availability_zone":"cn-southwest-2", #可用区域在创建子网的时候就应该选择 "extra_dhcp_opts": [{"opt_name": "ntp"}] } return conn.vpcv1.create_subnet(**subnet) def find_subnet(): return conn.vpcv1.find_subnet(sub_name) def create_and_get(): sub_id=create_subnet().id time.sleep(5) print(conn.vpcv1.get_subnet(sub_id)) if __name__ == "__main__": conn = api.get_conn_aksk() sub_name="chinaskill_vpc_subnet" vpc_id=conn.vpcv1.find_vpc("chinaskill_vpc").id if not find_subnet(): create_and_get() else: conn.vpcv1.delete_subnet(find_subnet().id,vpc_id) time.sleep(5) create_and_get() server_group 在云服务器的/root/huawei 目录下编写 create_server_group.py 文件,并导入赛项提供的 huaweicloudapi.py 文件获取连接。编写 Python 代码,调用 compute 类,创建华为云的云服 务器组,具体要求为 (1) 云服务器组名称:chinaskills_server_group; (2) 云服务器组策略:反亲和性; (3)如果安全组已经存在,代码中需要先删除; (4)使用其源码的 get 方法输出此云服务器组的详细信息。 import huaweicloudapi as api import time def create_server_group(): server_groups={ "name": sub_name, "policies":["anti-affinity"] } return conn.compute.create_server_group(**server_groups) def find_server_group(): return conn.compute.find_server_group(sub_name) def create_and_get(): sub_id = create_server_group().id time.sleep(3) print(conn.compute.get_server_group(sub_id)) if __name__ == "__main__": conn = api.get_conn_aksk() sub_name="chinaskills_server_group" if not find_server_group(): create_server_group() else: conn.compute.delete_server_group(find_server_group().id) time.sleep(5) create_and_get() sec_group and 规则 在云服务器的/root/huawei 目录下编写 create_security_group.py 文件,并导入赛项提供的 huaweicloudapi.py 文件获取连接。编写 Python 代码,调用 vpcv1 类,创建华为云的安全组,具体要求为 (1) 安全组名称:chinaskills_security_group; (2) 如果安全组已经存在,代码中需要先删除; (3) 使用其源码的 get 方法输出此安全组的详细信息。 import huaweicloudapi as api import time def create_security_group(): security_group={ "name": sub_name } return conn.vpcv1.create_security_group(**security_group) def find_security_group(): return conn.vpcv1.find_security_group(sub_name) def create_and_get(): sub_id = create_security_group().id time.sleep(3) print(conn.vpcv1.get_security_group(sub_id)) if __name__ == "__main__": conn=api.get_conn_aksk() sub_name="chinaskills_security_group" if not find_security_group(): create_and_get() else: conn.vpcv1.delete_security_group(find_security_group().id) time.sleep(5) create_and_get() Python 代码,调用 vpcv1 类,创建华为云的安全组规则,具体要求为 (1) 使用安全组名称获取其 ID(不允许直接填写安全组 ID); (2) 删除此安全组里所有规则(保证代码可以重复执行); (3) 放通出方向规则:所有协议端口; (4) 放通入方向规则:TCP 协议 22 端口; (5) 放通入方向规则:ICMP 协议所有端口; (6) 使用其源码的 get 方法输出此安全组的详细信息。 import huaweicloudapi as api # get security group id 查找安全组id def get_security_group_id(name): return conn.vpcv1.find_security_group(name) security_groups = conn.vpcv1.security_groups() for security_group in security_groups: if name == security_group.name: return security_group.id # delete exist security group rule 删除安全组内所以id def if_exist(security_group_id): data = { "security_group_id": security_group_id, } sgrs = conn.vpcv1.security_group_rules(**data) for sgr in sgrs: conn.vpcv1.delete_security_group_rule(sgr.id) # create security group rule 创建安全组规则 def create_security_group_rule(security_group_id): if_exist(security_group_id) egress = { "security_group_id": security_group_id, "direction": "egress" } ssh = { "security_group_id": security_group_id, "direction": "ingress", "protocol": "tcp", "port_range_min": 22, "port_range_max": 22 } icmp = { "security_group_id": security_group_id, "direction": "ingress", "protocol": "icmp" } #输出安全组规则 print(conn.vpcv1.create_security_group_rule(**egress)) print(conn.vpcv1.create_security_group_rule(**ssh)) print(conn.vpcv1.create_security_group_rule(**icmp)) if __name__ == '__main__': conn = api.get_conn_aksk() security_group_id = get_security_group_id("chinaskills_security_group").id create_security_group_rule(security_group_id) server_keypair (1) 秘钥对名称:chinaskills_keypair; (2) 如果秘钥对已经存在,代码中需要先删除; (3) 使用其源码的 get 方法输出此秘钥对详细信息。 import huaweicloudapi as api import time def create_keypair(): keypair=conn.compute.create_keypair(name=name) print(keypair) def find_keypair(): return conn.compute.find_keypair(name) def create_and_get(): create_keypair() print("密钥对信息:",conn.compute.get_keypair(name)) if __name__ == "__main__": conn=api.get_conn_aksk() name="chinaskills_keypair" if not find_keypair(): create_and_get() else: conn.compute.delete_keypair(find_keypair().id) time.sleep(5) create_and_get() create_server (1) 云服务器名称:chinaskills_server; (2) 云服务器可用区域:cn-north-4a; (3) 云服务器镜像:CentOS 7.5 64bit; (4) 云服务系统盘:磁盘规格 SSD、大小 100G; (5) 云服务数据盘:SSD、大小 50G; (6) 云服务器规格:c6.large.2; (7) 云服务器网络: chinaskills_subnet; (8) 云服务器安全组:chinaskills_security_group; (9) 云服务器组:chinaskills_server_group; (10) 云服务器秘钥对:chinaskills_keypair; (11) 云服务器弹性公网 IP:类型为全动态 BGP、带宽为 5 Mbit/s; (12) 云服务器标签:chinaskills=true; (13) 如果云服务器已经存在,代码中需要先删除; (14) 以上需求可用直接使用其 ID,例如:镜像 ID、网络 ID 等等; (15) 使用其源码的 get 方法输出此云服务器的详细信息。 from openstack import connection import time con = connection.Connection( cloud="myhuaweicloud.com", ak="********************", sk="********************", project_id="aaa5152ee9bd453084d139da9f927268", region="cn-southwest-2" ) server = con.compute.find_server("chinaskills_server") if server is not None: con.compute.delete_server(server) time.sleep(5) server_data = { "name": "chinaskills_server", "availability_zone": "cn-southwest-2a", "imageRef": "5f7c4607-779c-48a5-87d5-5f67a660c42f", "root_volume": { "volumetype": "SSD", "size": 100 }, "data_volumes": { "volumetype": "SSD", "size": 50 }, "flavorRef": "c6.large.2", "vpcid": "29adb01c-a0e8-422d-9ea5-eadd86034dc6", "nics": [ { "subnet_id": "91df789e-0d99-430d-9e9b-762203bbf446" } ], "security_groups": [ { "id": "fcbff996-4a55-48f3-9e10-3390445b16c3" } ], "key_name": "chinaskills_keypair", "publicip": { "eip": { "iptype": "5_sbgp", "bandwidth": { "size": 5, } } }, "server_tags": [ { "key": "chinaskills", "value": "true" } ] } server = con.compute.create_server(**server_data) time.sleep(15) print(con.compute.get_server(server)) 创建的弹性伸缩配置,具体要求为 (1) 伸缩配置名称:chinaskills_as_config; (2) 镜像配置:CentOS 7.5 64bit; (3) 磁盘配置:系统盘规格 SSD、大小 100G;数据盘规格 SSD、大小 50G; (4) 规格配置:c6.large.2; (5) 安全组配置:chinaskills_security_group; (6) 秘钥对配置:chinaskills_keypair; (7) 弹性公网配置:类型为全动态 BGP、带宽为 5 Mbit/s; (8) 如果弹性伸缩配置已经存在,代码中需要先删除; (9)使用其源码的 get 方法输出此弹性伸缩配置的详细信息。 from openstack import connection import time con = connection.Connection( cloud="myhuaweicloud.com", ak="********************", sk="********************", project_id="aaa5152ee9bd453084d139da9f927268", region="cn-southwest-2" ) config = con.auto_scaling.find_config("chinaskills_as_config") if config is not None: con.auto_scaling.delete_config(config) config_data = { "image_id": "5f7c4607-779c-48a5-87d5-5f67a660c42f", "disk":[ { "disk_type": "SYS", "volume_type": "SSD", "size": 100 }, { "disk_type": "DATA", "volume_type": "SSD", "size": 50 } ], "flavor_id" : "c6.large.2", "security_groups": [ { "id": "fcbff996-4a55-48f3-9e10-3390445b16c3" } ], "key_name": "chinaskills_keypair", "eip": { "ip_type": "5_bgp", "bandwidth": { "size": 5, "share_type": "PER" } } } config = con.auto_scaling.create_config("chinaskills_as_config",**config_data) print(con.auto_scaling.get_config(config)) 创建的弹性伸缩组,具体要求为 (1) 伸缩组名称:chinaskills_as_group; (2) 区域配置:cn-north-4a; (3) 弹性伸缩配置:chinaskills_as_config; (4) vpc 配置:chinaskills_vpc; (5) 子网配置:chinaskills_subnet; (6) 安全组配置:chinaskills_security_group; (7) 云服务器数配置:最大实例 3 台、最小实例 1 台、期望实例 2 台; (8) 配置弹性公网 IP 随实例释放; (9) 以上需求可用直接使用其 ID,例如:网络 ID、安全组 ID 等等; (10) 如果弹性伸缩组已经存在,代码中需要先删除; (11) 使用其源码的 get 方法输出此弹性伸缩组的详细信息。 from openstack import connection import time con = connection.Connection( cloud="myhuaweicloud.com", ak="********************", sk="********************", project_id="aaa5152ee9bd453084d139da9f927268", region="cn-southwest-2" ) group = con.auto_scaling.find_group("chinaskills_as_group") if group is not None: con.auto_scaling.delete_group(group) group_data = { "name": "chinaskills_as_group", "availability_zones": [ "cn-southwest-2a" ], "scaling_configuration_id": "dacd4047-c0c7-4440-9d93-e6e4c35cc494", "vpc_id": "29adb01c-a0e8-422d-9ea5-eadd86034dc6", "networks": [ { "id": "91df789e-0d99-430d-9e9b-762203bbf446" } ], "security_groups": [ { "id": "fcbff996-4a55-48f3-9e10-3390445b16c3" } ], "max_instance_number": 3, "min_instance_number": 1, "desire_instance_number": 2, "delete_publicip": "true" } group = con.auto_scaling.create_group(**group_data) print(con.auto_scaling.get_group(group)) 创建的弹性伸缩组策略,具体要求如下: (1) 基于伸缩组:chinaskills_as_group(不允许直接使用其 ID) (2) 伸缩策略名称:chinaskills_as_policy_daily (3) 策略类型:周期策略 (4) 重复周期:按天 (5) 触发时间:00:00 (6) 生效时间: 2021-06-10T00:00Z 到 2021-12-31T00:00Z (7) 执行动作:增加 1 实例 (8) 冷却时间:900 (秒) (9) 如果伸缩策略已经存在,代码中需要先删除 (10) 使用其源码的 get 方法输出此伸策略的详细信息 from openstack import connection import time con = connection.Connection( cloud="myhuaweicloud.com", ak="********************", sk="********************", project_id="aaa5152ee9bd453084d139da9f927268", region="cn-southwest-2" ) policy = con.auto_scaling.policies("chinaskills_as_group") if policy is not None: con.auto_scaling.delete_policy(policy) policy_data = { "name": "chinaskills_as_policy_daily", "type": "RECURRENCE", "scaling_group_id": "d419624d-5e7d-4f32-a615-3ff815e2f690", "scheduled_policy": { "recurrence_type": "Daily", "launch_time": "00:00", "start_time": "2022-03-26T00:00Z", "end_time": "2022-06-26T00:00Z" }, "scaling_policy_action": { "operation": "ADD", "instance_number": 1 }, "cool_down_time": "900" } policy = con.auto_scaling.create_policy(**policy_data) print(con.auto_scaling.get_policy(policy)) 创建的云硬盘,具体要求如下: (1) 云硬盘可用区域:cn-north-4a (2) 云硬盘名称:chinaskills_volume (3) 云硬盘规格和大小:超高 IO,100G (4) 设置云硬盘共享 (5) 设置云硬盘加密,加密秘钥为默认的 KMS 密钥 (6) 如果云硬盘已经存在,代码中需要先删除 (7) 使用其源码的 get 方法输出此云硬盘的详细信息(状态要求为 available) import huaweicloudapi as api import time def create_volume(): data = { "name": name, "availability_zone": "cn-southwest-2a", # 根据题目要求修改可用域 "volume_type": "SSD", # SSD为超高IO云硬盘 "size": 100, "multiattach": "true", # true表示共享云硬盘 "metadata": { "__system__cmkid": "c26fc6ab-ddb2-4f1a-8644-b894615c4d1f", # 默认秘钥id "__system__encrypted": "1" # 1代表加密 } } return conn.block_store.create_volume(**data) def create_and_get(): v_id = create_volume().id time.sleep(5) # 等待5秒刷新状态为available print("云硬盘的详细信息:", conn.block_store.get_volume(v_id)) if __name__ == '__main__': conn = api.get_conn_aksk() name = "chinaskills_volume" v_list = conn.block_store.volumes() for v in v_list: # 因为没有find函数,只能遍历云硬盘列表是否存在,目的:删除同名的云硬盘 if v.name == name: conn.block_store.delete_volume(v.id) create_and_get() 9、web界面查看网站部署 参考:https://www.cnblogs.com/sanduzxcvbnm/p/9789236.html 参考:https://www.icode9.com/ HTTP LAMP
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。