0%

云计算-2022样题-私有云

云计算赛项赛卷1

OpenStack云平台运维

1.使用提供的云安全框架组件,将提供的OpenStack云平台的安全策略从http优化至https。

使用提供的云安全框架组件,将自行搭建的OpenStack云平台的安全策略从http优化至https。
yum -y install mod_ssl

1
2
3
4
5
6
vi /etc/openstack-dashboard/local_settings
##在DEBUG = False下增加4行
USE_SSL = True
CSRF_COOKIE_SECURE = True ##原文中有,去掉注释即可
SESSION_COOKIE_SECURE = True ##原文中有,去掉注释即可
SESSION_COOKIE_HTTPONLY = True
1
2
3
vi /etc/httpd/conf.d/ssl.conf
##将SSLProtocol all -SSLv2 -SSLv3改成:
SSLProtocol all -SSLv2

systemctl restart httpd

systemctl restart memcached

2.在提供的OpenStack平台上,通过修改相关参数对openstack平台进行调优操作,相应的调优操作有:

(1)设置内存超售比例为1.5倍;

(2)设置为120秒。

1
2
3
vi /etc/nova/nova.conf
ram_allocation_ratio=1.5 ##设置内存超售比例为1.5倍
service_down_time = 120 ##设置nova服务心跳检查时间为120秒

systemctl restart *nova*

3.在提供的OpenStack平台上,使用Swift对象存储服务,修改相应的配置文件,使对象存储Swift作为glance镜像服务的后端存储

vi /etc/glance/glance-api.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[glance_store]
#stores = file,http
#default_store = file
#filesystem_store_datadir = /var/lib/glance/images/
default_store=swift
stores=glance.store.swift.Store
swift_store_auth_address=http://controller:5000/v3.0
swift_store_endpoint_type=internalURL
swift_store_multi_tenant=True
swift_store_admin_tenants=service
swift_store_user=glance
swift_store_key=000000
swift_store_container=glance
swift_store_create_container_on_put=True

4.在提供的OpenStack平台上,编写heat模板createvm.yml文件,模板作用为按照要求创建一个云主机。

1
2
3
4
5
6
7
8
9
10
11
[root@controller ~]# cat createvm.yml 
heat_template_version: 2018-03-02
resources:
server:
type: OS::Nova::Server
properties:
name: "testvm1"
image: cirros
flavor: m1.flavor
networks:
- network: extnet

5.在提供的OpenStack平台上,对cinder存储空间进行扩容操作,要求将cinder存储空间扩容10G。

创建一块新分区(vdb3)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@compute ~]# fdisk /dev/vdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
分区号 (3,4,默认 3):
起始 扇区 (83888128-104857599,默认为 83888128):
将使用默认值 83888128
Last 扇区, +扇区 or +size{K,M,G} (83888128-104857599,默认为 104857599):
将使用默认值 104857599
分区 3 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):w!
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盘。

重启一下

reboot

vgextend cinder-volumes /dev/vdb3 添加

1
2
3
[root@compute ~]# vgextend cinder-volumes /dev/vdb3
Physical volume "/dev/vdb3" successfully created.
Volume group "cinder-volumes" successfully extended

vgdisplay 查看

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@compute ~]# vgdisplay
--- Volume group ---
VG Name cinder-volumes
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 29.99 GiB
PE Size 4.00 MiB
Total PE 7678
Alloc PE / Size 4874 / <19.04 GiB
Free PE / Size 2804 / 10.95 GiB
VG UUID LOomGq-bcsf-Lqpe-sgmi-hJU3-H7rk-8DHfz2

6.在OpenStack私有云平台,创建一台云主机,使用提供的软件包,编写一键部署脚本,要求可以一键部署gpmall商城应用系统。

7.使用manila共享文件系统服务,使manila为多租户云环境中的共享文件系统提供统一的管理服务。

8.使用Blazar服务,使得管理员可以在OpenStack中为虚拟(实例,卷等)和物理(主机,存储等)的不同资源类型提供资源预留的能力。

9.使用cloudkitty计费服务,处理来自不同监控指标后端的数据并进行计费规则创建。以达到费用核算目的。

10.使用提供的iaas-error1镜像创建云主机,创建后的云主机内有错误的OpenStack平台,错误现象为cinder服务无法正常使用,请结合报错信息排查错误,使cinder服务可以正常使用。

云计算赛项赛卷2

1.使用自动搭建的OpenStack平台,登录数据库,创建库test,并在库test中创建表company(表结构如(id int not null primary key,name varchar(50),addr varchar(255))所示),在表company中插入一条数据(1,”alibaba”,”china”)

1
2
3
4
5
6
7
8
9
10
11
MariaDB [(none)]> create database test;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use test;
Database changed
MariaDB [test]> create table company(
-> id int not null primary key,
-> name varchar(50),
-> addr varchar(255));
Query OK, 0 rows affected (0.15 sec)
MariaDB [test]> insert into company values(1,"alibaba","chinas");
Query OK, 1 row affected (0.02 sec)

2.OpenStack各服务内部通信都是通过RPC来交互,各agent都需要去连接RabbitMQ;随着各服务agent增多,MQ的连接数会随之增多,最终可能会到达上限,成为瓶颈。使用提供的Ope nStack私有云平台,通过修改limits.conf配置文件来修改RabbitMQ服务的最大连接数为10240

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@controller /]# cat /etc/security/limits.conf 
...........................................
#<domain> <type> <item> <value>
#
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
user soft nofile 10240
user hard nofile 10240
# End of file

3.在提供的OpenStack私有云平台上,在/root目录下编写Heat模板create_user.yaml,创建名为heat-user的用户,属于admin项目,并赋予heat-user用户admin的权限,配置用户密码为123456。

1
2
3
4
5
6
7
8
9
10
11
[root@controller ~]# cat create_user.yml 
heat_template_version: 2018-03-02
resources:
user:
type: OS::Keystone::User
properties:
name: heat-user
password: "000000"
domain: demo
default_project: admin
roles: [{"role":"admin","project":"admin"}]

4.在提供的OpenStack私有云平台上,使用cirros-0.3.4-x86_64-disk.img镜像,创建一个名为Gmirror1的镜像,要求启动该镜像的最小硬盘是30G、最小内存是2048M。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@controller ~]# openstack image create Gmirror1 --disk-format qcow2 --container-format bare --min-disk 30 --min-ram 2048 < cirros-0.3.4-x86_64-disk.img 
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2022-05-03T00:34:26Z |
| disk_format | qcow2 |
| file | /v2/images/1a1ef251-a1d6-4f53-87aa-beef8fae8e64/file |
| id | 1a1ef251-a1d6-4f53-87aa-beef8fae8e64 |
| min_disk | 30 |
| min_ram | 2048 |
| name | Gmirror1 |
| owner | f9ef9bd849374360807c1fa567b44862 |
| protected | False |
| schema | /v2/schemas/image |
| size | 13287936 |
| status | active |
| tags | |
| updated_at | 2022-05-03T00:34:27Z |
| virtual_size | None |
| visibility | shared |
+------------------+------------------------------------------------------+

5.在提供的OpenStack私有云平台上,自行安装Swift服务,新建名为chinaskill的容器,将cirros-0.3.4-x86_64-disk.img镜像上传到chinaskill容器中,并设置分段存放,每一段大小为10M。

1
2
3
4
5
6
7
[root@controller ~]# swift post chinaskill
[root@controller ~]# swift list
chinaskill
[root@controller ~]# swift upload chinaskill -S 10000000 cirros-0.3.4-x86_64-disk.img
cirros-0.3.4-x86_64-disk.img segment 0
cirros-0.3.4-x86_64-disk.img segment 1
cirros-0.3.4-x86_64-disk.img

6.使用OpenStack私有云平台,创建两台云主机vm1和vm2,在这两台云主机上分别安装数据库服务,并配置成主从数据库,vm1节点为主库,vm2节点为从库(数据库密码设置为000000)。

(1)修改主机名

mysql1

hostnamectl set-hostname mysql1

bash

exit

mysql2

hostnamectl set-hostname mysql2

bash

exit

(2)配置hosts文件

两个节点配置/etc/hosts文件,修改为如下

vi /etc/hosts

1
2
3
4
5
6
7
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6


192.168.20.107 mysql1
192.168.20.109 mysql2
192.168.20.137 mycat

(3)配置YUM源

两个节点均使用提供的mariadb–10.3.23-repo.tar.gz的压缩包,解压并放在/opt目录下,进入/etc/yum.repos.d目录下,将原来的repo文件移除,新建local.repo文件并编辑内容,具体操作命令如下:

curl -O http://172.19.25.11/mariadb-10.3.23-repo.tar.gz

tar -zxvf mariadb-10.3.23-repo.tar.gz -C /opt

rm -rf /etc/yum.repos.d/*

vi /etc/yum.repos.d/local.repo

1
2
3
4
5
[mariadb]
name=mariadb
baseurl=file:///opt/
gpgcheck=0
enabled=1

(4)安装数据库服务并启动

配置完毕后,两个节点安装数据库服务,命令如下:

yum install -y mariadb mariadb-server

systemctl start mariadb

systemctl enable mariadb

(5)初始化数据库

两个节点初始化数据库,配置数据库root密码为000000,命令如下:

mysql_secure_installation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.



Enter current password for root (enter for none): #默认按Enter键
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y

New password: #输入数据库root密码000000
Re-enter new password: #再次输入密码000000
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
\- Dropping test database...
... Success!
\- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

(6)配置mysql1主节点

修改mysql1节点的数据库配置文件,在配置文件/etc/my.cnf.d/server.cnf中的[mysqld]增添如下内容。

1
2
3
4
5
6
[root@mysql1 ~]# cat /etc/my.cnf.d/server.cnf
... ...
[mysqld]
log_bin = mysql-bin #记录操作日志
binlog_ignore_db = mysql #不同步MySQL系统数据库
server_id = 12 #数据库集群中的每个节点id都要不同,一般使用IP地址的最后段的数字,例如172.30.11.12,server_id就写12

重启数据库服务,并进入数据库,命令如下:

1
2
3
4
5
6
7
8
9
10
11
[root@mysql1 ~]# systemctl restart mariadb
[root@mysql1 ~]# mysql -uroot -p000000
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.3.23-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

在mysql1节点,授权在任何客户端机器上可以以root用户登录到数据库,然后在主节点上创建一个user用户连接节点mysql2,并赋予从节点同步主节点数据库的权限。命令如下:

1
2
3
4
5
6
7
MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by "000000";

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant replication slave on *.* to 'user'@'mysql2' identified by '000000';

Query OK, 0 rows affected (0.00 sec)

(7)配置mysql2从节点

修改mysql2节点的数据库配置文件,在配置文件/etc/my.cnf.d/server.cnf中的[mysqld]增添如下内容。

[root@mysql2 ~]# cat /etc/my.cnf.d/server.cnf

1
2
3
4
5
6
7
8
... ...

[mysqld]
log_bin = mysql-bin #记录操作日志
binlog_ignore_db = mysql #不同步MySQL系统数据库
server_id = 13 #数据库集群中的每个节点id都要不同,一般使用IP地址的最后段的数字,例如172.30.11.13,server_id就写13

... ...

修改完配置文件后,重启数据库服务,并在从节点mysql2上登录MariaDB数据库,配置从节点连接主节点的连接信息。master_host为主节点主机名mysql1,master_user为上一步中创建的用户user,命令如下:

1
2
3
4
5
6
7
8
9
10
11
[root@mysql2 ~]# systemctl restart mariadb
[root@mysql2 ~]# mysql -uroot -p000000
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.3.23-MariaDB-log MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement

MariaDB [(none)]> change master to master_host='mysql1',master_user='user',master_password='000000';

Query OK, 0 rows affected (0.01 sec)

配置完毕主从数据库之间的连接信息之后,开启从节点服务。使用show slave status\G命令,并查看从节点服务状态,如果Slave_IO_Running和Slave_SQL_Running的状态都为YES,则从节点服务开启成功。命令如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
MariaDB [(none)]> start slave;

MariaDB [(none)]> show slave status\G

*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: mysql1
Master_User: user
Master_Port: 3306
Connect_Retry: 60
........
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
.........

可以看到Slave_IO_Running和Slave_SQL_Running的状态都是Yes,配置数据库主从集群成功。

(8)主节点创建数据库

先在主节点mysql1中创建库test,并在库test中创建表company,插入表数据,创建完成后,查看表company数据,命令如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@mysql1 ~]# mysql -uroot -p000000

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 11

Server version: 10.3.23-MariaDB-log MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database test;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use test;
Database changed
MariaDB [test]> create table company(id int not null primary key,name varchar(50),addr varchar(255));
Query OK, 0 rows affected (0.01 sec)

MariaDB [test]> insert into company values(1,"alibaba","china");

Query OK, 1 row affected (0.01 sec)



MariaDB [test]> select * from company;

+----+---------+-------+
| id | name | addr |
+----+---------+-------+
| 1 | alibaba | china |
+----+---------+-------+

1 row in set (0.00 sec)

(9)从节点验证复制功能

登录mysql2节点的数据库,查看数据库列表。找到test数据库,查询表,并查询内容验证从数据库的复制功能,命令如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[root@mysql2 ~]# mysql -uroot -p000000
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.3.23-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+

| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> use test;
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
MariaDB [test]> show tables;
+----------------+
| Tables_in_test |
+----------------+
| company |
+----------------+
1 row in set (0.00 sec)
MariaDB [test]> select * from company;
+----+---------+-------+
| id | name | addr |
+----+---------+-------+
| 1 | alibaba | china |
+----+---------+-------+
1 row in set (0.00 sec)

可以查看到主数据库中刚刚创建的库、表、信息,验证从数据库的复制功能成功。

7.在OpenStack私有云平台,创建一台云主机,使用提供的软件包,编写一键部署脚本,要求可以一键部署owncloud云网盘应用系统。

8.使用Blazar服务,使得管理员可以在OpenStack中为虚拟(实例,卷等)和物理(主机,存储等)的不同资源类型提供资源预留的能力。

9.使用cloudkitty计费服务,处理虚拟机实例(compute)、云硬盘(volume)、镜像(image)、网络进出流量(network.bw.in, network.bw.out)、浮动IP(network.floating)的计费数据并进行计费规则创建,以达到费用核算目的。

10.使用提供的iaas-error2镜像创建云主机,创建后的云主机内有错误的OpenStack平台,错误现象为glance服务无法正常使用,请结合报错信息排查错误,使glance服务可以正常使用。

云计算赛项赛卷3

1.使用提供的OpenStack私有云平台,修改相关配置文件,启用-device virtio-net-pci in kvm。

2.在提供的OpenStack平台上,通过修改相关参数对openstack平台进行调优操作,相应的调优操作有:

(1)预留前2个物理CPU,把后面的所有CPU分配给虚拟机使用(假设vcpu为16个);

1
2
vi /etc/nova/nova.conf
vcpu_pin_set= 3-16

(2)设置cpu超售比例为4倍;

1
2
vi /etc/nova/nova.conf
cpu_allocation_ratio=4.0

3.在提供的OpenStack平台上,对mencached服务进行操作使memcached的缓存由64MB变为256MB。

1
2
3
4
5
6
[root@controller ~]# cat /etc/sysconfig/memcached 
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="256" #缓存
OPTIONS="-l 127.0.0.1,::1,controller"

4.在提供的OpenStack平台上,编写heat模板createnet.yml文件,模板作用为按照要求创建一个网络和子网。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@controller ~]# cat createnet.yml 
heat_template_version: 2018-03-02
resources:
network:
type: OS::Neutron::Net
properties:
name: "extnet"
shared: false
admin_state_up: true
subnet:
type: OS::Neutron::Subnet
properties:
cidr: 10.10.2.0/24
enable_dhcp: true
gateway_ip: 10.10.2.1
allocation_pools:
- start: 10.10.2.20
end: 10.10.2.100
name: "subextnet"
network_id: {get_resource: "network"}

5.使用提供的OpenStack私有云平台,修改普通用户权限,使普通用户不能对镜像进行创建和删除操作

6.在OpenStack私有云平台,创建一台云主机,并创建一个40G大小的cinder块存储,将块存储连接到云主机,然后在云主机上对云硬盘进行操作。要求分出2个大小为10G的分区,使用这2个分区,创建名为/dev/md0、raid级别为0的磁盘阵列,最后将md0格式化为ext4格式并挂载至/mnt目录。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
[root@mysql1 ~]# fdisk /dev/vdc
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-83886079,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-83886079,默认为 83886079):+10G
分区 1 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
分区号 (2-4,默认 2):
起始 扇区 (20973568-83886079,默认为 20973568):
将使用默认值 20973568
Last 扇区, +扇区 or +size{K,M,G} (20973568-83886079,默认为 83886079):+10G
分区 2 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):t
分区号 (1,2,默认 2):1
Hex 代码(输入 L 列出所有代码):fd
已将分区“Linux”的类型更改为“Linux raid autodetect”
命令(输入 m 获取帮助):t
分区号 (1,2,默认 2):
Hex 代码(输入 L 列出所有代码):fd
已将分区“Linux”的类型更改为“Linux raid autodetect”
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@mysql1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 50G 0 disk
└─vda1 253:1 0 50G 0 part /
vdb 253:16 0 50G 0 disk /mnt
vdc 253:32 0 40G 0 disk
├─vdc1 253:33 0 10G 0 part
└─vdc2 253:34 0 10G 0 part

创建磁盘阵列

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@mysql1 ~]# mdadm -C /dev/md0 -l 0 -n 2 /dev/vdc1 /dev/vdc2
mdadm: Fail create md0 when using /sys/module/md_mod/parameters/new_array
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@mysql1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 50G 0 disk
└─vda1 253:1 0 50G 0 part /
vdb 253:16 0 50G 0 disk /mnt
vdc 253:32 0 40G 0 disk
├─vdc1 253:33 0 10G 0 part
│ └─md0 9:0 0 20G 0 raid0
└─vdc2 253:34 0 10G 0 part
└─md0 9:0 0 20G 0 raid0

格式化为ext4格式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@mysql1 ~]# mkfs.ext4 /dev/md0
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=128 blocks, Stripe width=256 blocks
1310720 inodes, 5238272 blocks
261913 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2153775104
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

挂载到mnt

mount /dev/md0 /mnt/

7.使用manila共享文件系统服务,使manila为多租户云环境中的共享文件系统提供统一的管理服务。

8.使用cyborg硬件加速服务,实现硬件资源的发现、上报、挂载\卸载等资源管理。

9.在OpenStack私有云平台,创建一台云主机,编写脚本,要求可以完成数据库的定期备份,并把数据库备份文件存放在/opt目录下。

10.使用提供的iaas-error3镜像创建云主机,创建后的云主机内有错误的OpenStack平台,错误现象为nova服务无法正常使用,创建云主机报错,请结合报错信息排查错误,使nova服务可以正常使用,可以正常创建云主机。

云计算赛项赛卷4

1.在提供的OpenStack私有云平台上,在/root目录下编写Heat模板create_net.yaml,创建名为Heat-Network网络,选择不共享;创建子网名为Heat-Subnet,子网网段设置为10.20.2.0/24,开启DHCP服务,地址池为10.20.2.20-10.20.2.100。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@controller ~]# cat createnet.yml 
heat_template_version: 2018-03-02
resources:
network:
type: OS::Neutron::Net
properties:
name: "extnet"
shared: false
admin_state_up: true
subnet:
type: OS::Neutron::Subnet
properties:
cidr: 10.10.2.0/24
enable_dhcp: true
gateway_ip: 10.10.2.1
allocation_pools:
- start: 10.10.2.20
end: 10.10.2.100
name: "subextnet"
network_id: {get_resource: "network"}

2.在提供的OpenStack私有云平台,创建一台云主机(镜像使用CentOS7.9,flavor使用带临时磁盘50G的),配置该主机为nfs的server端,将该云主机中的/mnt/test目录进行共享(目录不存在可自行创建)。然后配置controller节点为nfs的client端,要求将/mnt/test目录作为glance后端存储的挂载目录。

nfs服务端:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[root@nfs ~]# umount /mnt
[root@nfs ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 100G 0 disk
└─vda1 253:1 0 100G 0 part /
vdb 253:16 0 50G 0 disk
[root@nfs ~]#
[root@nfs ~]# mkfs.ext4 /dev/vdb
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13107200 blocks
655360 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2162163712
400 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[root@nfs ~]# mount /dev/vdb /mnt
[root@nfs ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 100G 0 disk
└─vda1 253:1 0 100G 0 part /
vdb 253:16 0 50G 0 disk /mnt

yum install -y nfs-utils rpcbind

mkdir /mnt/test

echo /mnt/test *(rw,async,no_root_squash) > /etc/exports

1
2
3
4
[root@nfs ~]# systemctl restart rpcbind
[root@nfs ~]# systemctl restart nfs
[root@nfs ~]# systemctl enable rpcbind
[root@nfs ~]# systemctl enable nfs

nfs客户端:

echo 192.168.20.106:/mnt/test /var/lib/glance/images nfs default netdev 0 0 > /etc/fstab

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@controller ~]# systemctl restart rpcbind
[root@controller ~]# systemctl restart nfs
[root@controller ~]# systemctl enable rpcbind
[root@controller ~]# systemctl enable nfs
[root@controller ~]# showmount -e 192.168.20.106
Export list for 192.168.20.106:
/mnt/test *
[root@controller ~]# mount -t nfs 192.168.20.106:/mnt/test /var/lib/glance/images/
[root@controller ~]# chown -R glance:glance /var/lib/glance/images/
[root@controller ~]# ll /var/lib/glance/
总用量 4
drwxr-xr-x 2 glance glance 4096 4月 25 06:18 images
[root@controller ~]# mount
...............................................................
192.168.20.106:/mnt/test on /var/lib/glance/images type nfs4 (rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.20.105,local_lock=none,addr=192.168.20.106)

3.使用OpenStack私有云平台,找到virsh中ID为10的云主机(若不存在请自行创建)。在云主机所在的物理节点,进入virsh交互式界面,使用virsh命令,将memory虚拟机的内存调整为5242880KB大小。

4.使用OpenStack私有云平台,创建一台云主机,创建完之后对该云主机进行打快照处理,并将该快照保存至/root/cloudsave目录,保存名字为csccvm.qcow2。

1
2
3
[root@controller ~]# openstack server image create vm1 --name csccvm
[root@controller ~]# mkdir /root/cloudsave
[root@controller ~]# openstack image save --file /root/cloudsave/csccvm.qcow2 csccvm

5.使用OpenStack私有云平台,使用centos7.9镜像,flavor使用1vcpu/2G内存/40G硬盘,创建云主机cscc_vm,假设在使用过程中,发现该云主机配置太低,需要调整,请修改相应配置,将dashboard界面上的云主机调整实例大小可以使用,将该云主机实例大小调整为2vcpu/4G内存/40G硬盘。

sed -i 's/#allow_resize_to_same_host=false/allow_resize_to_same_host=True/g' /etc/nova/nova.conf

systemctl restart *nova*

然后图形化操作

6.使用OpenStack私有云平台,创建三个云主机,使用提供的软件包安装RabbitMQ服务,安装完毕后,搭建RabbitMQ集群,并打开RabbitMQ服务的图形化监控页面插件。集群使用普通集群模式,其中第一台做磁盘节点,另外两台做内存节点。

(1)修改主机名

对这3台虚拟机进行修改主机名的操作,主机名修改为rabbitmq1,rabbitmq2,rabbitmq3。命令如下

rabbitmaq1

hostnamectl set-hostname rabbitmq1

bash

exit

rabbitmaq2

hostnamectl set-hostname rabbitmq2

bash

exit

rabbitmaq3

hostnamectl set-hostname rabbitmq3

bash

exit

(2)修改hosts

三个节点都配置hosts

vi /etc/hosts

1
2
3
4
5
6
7
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6


192.168.20.121 rabbitmq1
192.168.20.128 rabbitmq2
192.168.20.116 rabbitmq3

(4)配置yum源

三个节点均使用提供的rabbitmq-repo.tar.gz的压缩包,上传至虚拟机的/root目录下,解压并放在/opt目录下,进入/etc/yum.repos.d目录下,将原来的repo文件移除,新建local.repo文件并编辑内容,具体操作命令如下:

curl -O http://172.19.25.11/rabbitmq-repo.tar.gz

tar -zxvf rabbitmq-repo.tar.gz -C /opt/

mv /etc/yum.repos.d/* /tmp/

vi local.repo

1
2
3
4
5
[rabbitmq]
name=rabbitmq
baseurl=file:///opt/rabbitmq-repo
gpgcheck=0
enabled=1

(5)安装RabbitMQ服务并启动

配置完毕后,三个节点安装RabbitMQ服务,命令如下:

yum install -y rabbitmq-server

rabbitmq1节点启动RabbitMQ服务并查看服务状态,命令如下:

systemctl start rabbitmq-server

systemctl status rabbitmq-server

(6)配置界面访问

RabbitMQ提供了一个非常友好的图形化监控页面插件(rabbitmq_management),让我们可以一目了然看见Rabbit的状态或集群状态。启用图形化页面插件的具体命令如下:

rabbitmq-plugins enable rabbitmq_management

service rabbitmq-server restart

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[root@rabbitmq1 ~]# netstat -ntpl

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 13685/beam

tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 500/rpcbind

tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 11320/epmd

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1162/sshd

tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 13685/beam

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 932/master

tcp6 0 0 :::5672 :::* LISTEN 13685/beam

tcp6 0 0 :::111 :::* LISTEN 500/rpcbind

tcp6 0 0 :::4369 :::* LISTEN 11320/epmd

tcp6 0 0 :::22 :::* LISTEN 1162/sshd

tcp6 0 0 ::1:25 :::* LISTEN 932/master

可以看到15672端口已开放,打开浏览器,输入rabbitmq1节点的IP+端口15672(http://172.30.11.12:15672)访问RabbitMQ监控界面,使用默认的用户名和密码登录(用户名和密码都为guest)

(7)配置节点间的通信

RabbitMQ的集群是依附于erlang集群来工作的,所以必须先构建起一个erlang集群。erlang集群中各节点是由magic cookie来实现的,每个节点上要保持相同的.erlang.cookie文件,这个cookie存放在/var/lib/rabbitmq/.erlang.cookie中,文件是400的权限。必须保证各节点cookie一致,不然节点之间就无法通信。

查看rabbitmq1节点的.erlang.cookie文件,并将该文件复制到rabbitmq2和rabbitmq3节点的/var/lib/rabbitmq/目录下,命令如下

1
2
3
4
5
6
7
[root@rabbitmq1 ~]# cat /var/lib/rabbitmq/.erlang.cookie 

EZYGPUJOTSESXPAUFMWO

[root@rabbitmq1 ~]# scp /var/lib/rabbitmq/.erlang.cookie root@rabbitmq2:/var/lib/rabbitmq/

[root@rabbitmq1 ~]# scp /var/lib/rabbitmq/.erlang.cookie root@rabbitmq3:/var/lib/rabbitmq/

将.erlang.cookie文件传至rabbitmq2和rabbitmq3节点后,需要修改该文件的用户与用户组,命令如下:

1
2
3
4
5
6
[root@rabbitmq1 ~]#cd /var/lib/rabbitmq/
[root@rabbitmq1 rabbitmq]# chown rabbitmq:rabbitmq .erlang.cookie
[root@rabbitmq2 ~]#cd /var/lib/rabbitmq/
[root@rabbitmq2 rabbitmq]# chown rabbitmq:rabbitmq .erlang.cookie
[root@rabbitmq3 ~]#cd /var/lib/rabbitmq/
[root@rabbitmq3 rabbitmq]# chown rabbitmq:rabbitmq .erlang.cookie

(8)配置节点加入集群

在rabbitmq2、rabbitmq3节点执行如下命令,将这两个节点作为RAM节点加入到RabbitMQ集群中,具体命令如下:

rabbitmq2节点:

systemctl start rabbitmq-server

service rabbitmq-server restart

rabbitmq3节点:

systemctl start rabbitmq-server

service rabbitmq-server restart

上面这俩步千万不要忘记打

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
rabbitmq2节点:

[root@rabbitmq2 rabbitmq]# rabbitmqctl stop_app

Stopping node rabbit@rabbitmq2 ...

...done.

[root@rabbitmq2 rabbitmq]# rabbitmqctl join_cluster --ram rabbit@rabbitmq1

Clustering node rabbit@rabbitmq2 with rabbit@rabbitmq1 ...

...done.

[root@rabbitmq2 rabbitmq]# rabbitmqctl start_app

Starting node rabbit@rabbitmq2 ...

...done.

rabbitmq3节点:

[root@rabbitmq3 rabbitmq]# rabbitmqctl stop_app

Stopping node rabbit@rabbitmq3 ...

...done.

[root@rabbitmq3 rabbitmq]# rabbitmqctl join_cluster --ram rabbit@rabbitmq1

Clustering node rabbit@rabbitmq3 with rabbit@rabbitmq1 ...

...done.

[root@rabbitmq3 rabbitmq]# rabbitmqctl start_app

Starting node rabbit@rabbitmq3 ...

...done.

默认rabbitmq启动后是磁盘节点,在这个cluster命令下,rabbitmq2和rabbitmq3是内存节点,rabbitmq1是磁盘节点。

如果要使rabbitmq2、rabbitmq3都是磁盘节点,去掉–ram参数即可。

如果想要更改节点类型,可以使用命令rabbitmqctl change_cluster_node_type disc(ram),前提是必须停掉Rabbit应用。

(9)配置RAM节点启用界面

在rabbitmq2和rabbitmq3节点上启用rabbitmq_management,命令如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
rabbitmq2节点:

[root@rabbitmq2 rabbitmq]# rabbitmq-plugins enable rabbitmq_management

The following plugins have been enabled:

mochiweb

webmachine

rabbitmq_web_dispatch

amqp_client

rabbitmq_management_agent

rabbitmq_management

Plugin configuration has changed. Restart RabbitMQ for changes to take effect.

[root@rabbitmq2 rabbitmq]# systemctl restart rabbitmq-server

rabbitmq3节点:

[root@rabbitmq3 rabbitmq]# rabbitmq-plugins enable rabbitmq_management

The following plugins have been enabled:

mochiweb

webmachine

rabbitmq_web_dispatch

amqp_client

rabbitmq_management_agent

rabbitmq_management

Plugin configuration has changed. Restart RabbitMQ for changes to take effect.

[root@rabbitmq3 rabbitmq]# systemctl restart rabbitmq-server

启用rabbitmq2节点和rabbitmq3节点的监控界面后,登录

(10)查看集群状态

在RabbitMQ集群的任一节点上,可以查看RabbitMQ集群的状态,命令如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@rabbitmq1 ~]# rabbitmqctl cluster_status

Cluster status of node rabbit@rabbitmq1 ...

[{nodes,[{disc,[rabbit@rabbitmq1]},{ram,[rabbit@rabbitmq3,rabbit@rabbitmq2]}]},

{running_nodes,[rabbit@rabbitmq3,rabbit@rabbitmq2,rabbit@rabbitmq1]},

{cluster_name,<<"rabbit@rabbitmq1">>},

{partitions,[]}]

...done.

可以查看到rabbitmq1节点为disc磁盘节点,rabbitmq2节点和rabbitmq3节点为RAM内存节点。

7.使用karbor服务,保护云平台上的卷(一般就是映射到VMs上的可进行读写的数据存储载体或设备)

8.使用Blazar服务,使得管理员可以在OpenStack中为虚拟(实例,卷等)和物理(主机,存储等)的不同资源类型提供资源预留的能力。

9.使用octavia负载均衡服务,实现云平台上的负载均衡。

10.使用提供的iaas-error4镜像创建云主机,创建后的云主机内有错误的OpenStack平台,错误现象为dashboard界面服务无法正常使用,请结合报错信息排查错误,使dashboard界面服务可以正常使用。

云计算赛项赛卷5

1.使用OpenStack私有云平台,创建三个云主机,使用提供的软件包安装RabbitMQ服务,安装完毕后,搭建RabbitMQ集群,并打开RabbitMQ服务的图形化监控页面插件。集群使用普通集群模式,其中第一台做磁盘节点,另外两台做内存节点。

2.在openstack私有云平台上,创建云主机VM1,镜像使用cirros。创建成功后,将云主机打快照并保存到controller节点/root/cloudsave目录下,保存名字为csccvm.qcow2。最后使用qemu-img相关命令,将镜像的campat版本修改为0.10(该操作是为了适配某些低版本的云平台)。

1
2
3
4
5
6
7
8
9
10
[root@controller ~]# openstack server image create vm1 --name csccvm
[root@controller ~]# mkdir /root/cloudsave
[root@controller ~]# openstack image save --file /root/cloudsave/csccvm.qcow2 csccvm
[root@controller ~]# cd /var/lib/glance/images/
[root@controller images]# ll
总用量 47464
-rw-r----- 1 glance glance 22020096 5月 9 03:25 10b86659-1951-452b-9dbf-1ba3d5ad2f9d
-rw-r----- 1 glance glance 13287936 5月 8 02:08 bd74df22-1558-4fff-b4f3-f78aee4275d6
-rw-r----- 1 glance glance 13287936 5月 9 02:39 ccf243c9-8cb7-453e-902b-de66867c7e5f
[root@controller images]# qemu-img amend -f qcow2 -o compat=0.10 10b86659-1951-452b-9dbf-1ba3d5ad2f9d

3.在提供OpenStack私有云平台,创建一台云主机,云主机名为cscc_vm,镜像使用cirros、flavor自行创建(配置自定义)。然后创建一块大小为1G的云硬盘,命名为block,并挂载到该云主机。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[root@controller ~]# cinder create --name block 1
+--------------------------------+--------------------------------------+
| Property | Value |
+--------------------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2022-05-09T03:28:56.000000 |
| description | None |
| encrypted | False |
| id | 1dd10e41-f0c6-4feb-a7e8-ddb1d99b067f |
| metadata | {} |
| migration_status | None |
| multiattach | False |
| name | block |
| os-vol-host-attr:host | None |
| os-vol-mig-status-attr:migstat | None |
| os-vol-mig-status-attr:name_id | None |
| os-vol-tenant-attr:tenant_id | 0047a899f1b34aaba102c89bf5dbeab4 |
| replication_status | None |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| updated_at | None |
| user_id | 73ba03dfca0f4de6953a79e478cd035f |
| volume_type | None |
+--------------------------------+--------------------------------------+
[root@controller ~]# openstack server add volume vm1 block

4.在提供的OpenStack平台上,编写heat模板createcinder.yml文件,模板作用为按照要求创建一个云硬盘。

1
2
3
4
5
6
7
8
[root@controller ~]# cat createcinder.yml 
heat_template_version: 2018-03-02
resources:
cinder:
type: OS::Cinder::Volume
properties:
name: dsb
size: 10

5.在OpenStack私有云平台,创建一台云主机,并创建一个40G大小的cinder块存储,将块存储连接到云主机,然后在云主机上对云硬盘进行操作。要求分出4个大小为5G的分区,使用这4个分区,创建名为/dev/md5、raid级别为5的磁盘阵列加一个热备盘(/dev/vdb4为热备盘)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
[root@mysql1 ~]# fdisk /dev/vdd
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x206f71f2 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-83886079,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-83886079,默认为 83886079):+5G
分区 1 已设置为 Linux 类型,大小设为 5 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
分区号 (2-4,默认 2):
起始 扇区 (10487808-83886079,默认为 10487808):
将使用默认值 10487808
Last 扇区, +扇区 or +size{K,M,G} (10487808-83886079,默认为 83886079):+5G
分区 2 已设置为 Linux 类型,大小设为 5 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
分区号 (3,4,默认 3):
起始 扇区 (20973568-83886079,默认为 20973568):
将使用默认值 20973568
Last 扇区, +扇区 or +size{K,M,G} (20973568-83886079,默认为 83886079):+5G
分区 3 已设置为 Linux 类型,大小设为 5 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default e): p
已选择分区 4
起始 扇区 (31459328-83886079,默认为 31459328):
将使用默认值 31459328
Last 扇区, +扇区 or +size{K,M,G} (31459328-83886079,默认为 83886079):+5G
分区 4 已设置为 Linux 类型,大小设为 5 GiB
命令(输入 m 获取帮助):t
分区号 (1-4,默认 4):1
Hex 代码(输入 L 列出所有代码):fd
已将分区“Linux”的类型更改为“Linux raid autodetect”
命令(输入 m 获取帮助):t
分区号 (1-4,默认 4):2
Hex 代码(输入 L 列出所有代码):fd
已将分区“Linux”的类型更改为“Linux raid autodetect”
命令(输入 m 获取帮助):t
分区号 (1-4,默认 4):3
Hex 代码(输入 L 列出所有代码):fd
已将分区“Linux”的类型更改为“Linux raid autodetect”
命令(输入 m 获取帮助):t
分区号 (1-4,默认 4):
Hex 代码(输入 L 列出所有代码):fd
已将分区“Linux”的类型更改为“Linux raid autodetect”
命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@mysql1 ~]# mdadm -C /dev/md5 -l 5 -n 3 -x 1 /dev/vdd1 /dev/vdd2 /dev/vdd3 /dev/vdd4
mdadm: Fail create md5 when using /sys/module/md_mod/parameters/new_array
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.
[root@mysql1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 50G 0 disk
└─vda1 253:1 0 50G 0 part /
vdb 253:16 0 50G 0 disk /mnt
vdd 253:48 0 40G 0 disk
├─vdd1 253:49 0 5G 0 part
│ └─md5 9:5 0 10G 0 raid5
├─vdd2 253:50 0 5G 0 part
│ └─md5 9:5 0 10G 0 raid5
├─vdd3 253:51 0 5G 0 part
│ └─md5 9:5 0 10G 0 raid5
└─vdd4 253:52 0 5G 0 part
└─md5 9:5 0 10G 0 raid5
[root@mysql1 ~]# mdadm -D /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Mon May 9 03:40:45 2022
Raid Level : raid5
Array Size : 10475520 (9.99 GiB 10.73 GB)
Used Dev Size : 5237760 (5.00 GiB 5.36 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Mon May 9 03:41:31 2022
State : clean
Active Devices : 3
Working Devices : 4
Failed Devices : 0
Spare Devices : 1
Layout : left-symmetric
Chunk Size : 512K

Consistency Policy : resync

Name : mysql1:5 (local to host mysql1)
UUID : d90bb669:5411f2f1:d6f25855:d80efe7e
Events : 18
Number Major Minor RaidDevice State
0 253 49 0 active sync /dev/vdd1
1 253 50 1 active sync /dev/vdd2
4 253 51 2 active sync /dev/vdd3
3 253 52 - spare /dev/vdd4

6.使用提供的OpenStack平台,创建一台云主机,根据提供的软件包,编写一键部署LNMP+WordPress的部署脚本。

7.使用manila共享文件系统服务,使manila为多租户云环境中的共享文件系统提供统一的管理服务。

8.使用Blazar服务,使得管理员可以在OpenStack中为虚拟(实例,卷等)和物理(主机,存储等)的不同资源类型提供资源预留的能力。

9.使用cloudkitty计费服务,使用noop计费模型处理来自不同监控指标后端的数据并进行计费规则创建。以达到费用核算目的。

10.使用提供的iaas-error5镜像创建云主机,创建后的云主机内有错误的OpenStack平台,错误现象为无法创建用户和项目,请结合报错信息排查错误,使keystone服务可以正常使用,可以正常创建用户与项目。

云计算赛项赛卷6

1.使用提供的OpenStack私有云平台,修改相关参数对openstack平台进行调优操作,相应的调优操作有:

(1)预留前2个物理CPU,把后面的所有CPU分配给虚拟机使用(假设vcpu为16个);

1
2
vi /etc/nova/nova.conf 
vcpu_pin_set= 3-16

(2)设置cpu超售比例为4倍;

1
2
vi /etc/nova/nova.conf 
cpu_allocation_ratio=4.0

(3)设置内存超售比例为1.5倍;

1
2
vi /etc/nova/nova.conf 
ram_allocation_ratio=1.5

(4)预留2048mb内存,这部分内存不能被虚拟机使用;

1
2
vi /etc/nova/nova.conf 
reserved_host_memory_mb=2048

(5)预留10240mb磁盘,这部分磁盘不能被虚拟机使用;

1
2
vi /etc/nova/nova.conf 
reserved_host_disk_mb=10240

(6)设置nova服务心跳检查时间为120秒。

1
2
vi /etc/nova/nova.conf 
service_down_time = 120

systemctl restart *nova*

2.使用OpenStack私有云平台,创建一台云主机,创建完之后对该云主机进行打快照处理,并将该快照保存至/root/cloudsave目录,保存名字为csccvm.qcow2。

1
2
3
[root@controller ~]# openstack server image create vm1 --name csccvm
[root@controller ~]# mkdir /root/cloudsave
[root@controller ~]# openstack image save --file /root/cloudsave/csccvm.qcow2 csccvm

3.在提供的OpenStack平台上,使用Swift对象存储服务,修改相应的配置文件,使对象存储Swift作为glance镜像服务的后端存储。

vi /etc/glance/glance-api.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[glance_store]
#stores = file,http
#default_store = file
#filesystem_store_datadir = /var/lib/glance/images/
default_store=swift
stores=glance.store.swift.Store
swift_store_auth_address=http://controller:5000/v3.0
swift_store_endpoint_type=internalURL
swift_store_multi_tenant=True
swift_store_admin_tenants=service
swift_store_user=glance
swift_store_key=000000
swift_store_container=glance
swift_store_create_container_on_put=True

systemctl restart *glance*

4.在提供的OpenStack平台上,编写heat模板createswift.yml文件,模板作用为按照要求创建容器。

1
2
3
4
5
6
7
[root@controller ~]# cat swift.yml 
heat_template_version: 2018-03-02
resources:
swift:
type: OS::Swift::Container
properties:
name: skill

5.使用Blazar服务,使得管理员可以在OpenStack中为虚拟(实例,卷等)和物理(主机,存储等)的不同资源类型提供资源预留的能力。

6.使用cloudkitty计费服务,处理来自不同监控指标后端的数据并进行计费规则创建。以达到费用核算目的。

7.使用OpenStack私有云平台,创建两台云主机vm1和vm2,在这两台云主机上分别安装数据库服务,并配置成主从数据库,vm1节点为主库,vm2节点为从库(数据库密码设置为000000)。

8.使用OpenStack私有云平台,创建三台云主机vm1、vm2和vm3,首先使用两台云主机完成MariaDB数据库的主从配置,接着根据提供的数据库中间件Mycat。完成Mycat读写分离数据库的配置安装(逻辑库名称使用“USERDB”,数据库密码使用000000)。

9.在OpenStack私有云平台,创建一台云主机,使用提供的软件包,编写脚本,要求可以一键部署nfs服务。

1
2
3
4
5
6
7
8
9
10
11
12
[root@mycat ~]# cat nfs.sh 
#!/bin/bash
yum install -y nfs-utils rpcbind
umount /mnt
mkfs.ext4 /dev/vdb
mount /dev/vdb /mnt
mkdir /mnt/test
echo '/mnt/test *(rw,async,no_root_squash)' > /etc/exports
systemctl restart rpcbind
systemctl restart nfs
systemctl enable rpcbind
systemctl enable nfs

10.使用提供的iaas-error6镜像创建云主机,创建后的云主机内有错误的OpenStack平台,错误现象为所有的命令均无法正常使用,请结合报错信息排查错误,使OpenStack平台服务可以正常使用。

云计算赛项赛卷7

1.在提供的OpenStack平台上,使用Cinder块存储服务,创建块存储卷,并使用该卷连接到云主机。

2.在提供的OpenStack平台上,编写heat模板createuser.yml文件,模板作用为按照要求创建项目与用户,并赋予用户admin权限。

1
2
3
4
5
6
7
8
9
10
11
[root@controller ~]# cat user.yml 
heat_template_version: 2018-03-02
resources:
user:
type: OS::Keystone::User
properties:
name: heat-user
password: 000000
domain: demo
default_project: admin
roles: [{"role":"admin","project":"admin"}]

3.在提供的OpenStack平台上,上传cirros镜像,要求启动该镜像起码需要1G内存和10G硬盘。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@controller ~]# openstack image create cirros1 --min-disk 10 --min-ram 1024 --disk-format qcow2 --container-format bare < cirros-0.3.4-x86_64-disk.img 
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2022-05-09T05:16:23Z |
| disk_format | qcow2 |
| file | /v2/images/0621890a-626c-485e-b6e6-db8bbee96898/file |
| id | 0621890a-626c-485e-b6e6-db8bbee96898 |
| min_disk | 10 |
| min_ram | 1024 |
| name | cirros1 |
| owner | 0047a899f1b34aaba102c89bf5dbeab4 |
| protected | False |
| schema | /v2/schemas/image |
| size | 13287936 |
| status | active |
| tags | |
| updated_at | 2022-05-09T05:16:24Z |
| virtual_size | None |
| visibility | shared |
+------------------+------------------------------------------------------+

4.使用manila共享文件系统服务,使manila为多租户云环境中的共享文件系统提供统一的管理服务。

5.使用Blazar服务,使得管理员可以在OpenStack中为虚拟(实例,卷等)和物理(主机,存储等)的不同资源类型提供资源预留的能力。

6.使用cloudkitty计费服务,处理来自不同监控指标后端的数据并进行计费规则创建。以达到费用核算目的。

7.在OpenStack私有云平台,创建一台云主机,编写定时任务脚本,要求可以在每个星期的周三晚上11点,定时自动备份数据库。

8.在OpenStack私有云平台,创建一台云主机,并创建一个40G大小的cinder块存储,将块存储连接到云主机,然后在云主机上对云硬盘进行操作。要求分出三个大小为5G的分区,使用这三个分区,创建名chinaskill-vg的卷组。然后创建名chinaskill-lv的逻辑卷,大小为12G。

yum install openstack-cinder -y

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
[root@controller ~]# fdisk /dev/vdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x1ef41573 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-83886079,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-83886079,默认为 83886079):+5G
分区 1 已设置为 Linux 类型,大小设为 5 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
分区号 (2-4,默认 2):
起始 扇区 (10487808-83886079,默认为 10487808):
将使用默认值 10487808
Last 扇区, +扇区 or +size{K,M,G} (10487808-83886079,默认为 83886079):+5G
分区 2 已设置为 Linux 类型,大小设为 5 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
分区号 (3,4,默认 3):
起始 扇区 (20973568-83886079,默认为 20973568):
将使用默认值 20973568
Last 扇区, +扇区 or +size{K,M,G} (20973568-83886079,默认为 83886079):+5G
分区 3 已设置为 Linux 类型,大小设为 5 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
1
2
3
4
5
[root@controller ~]# vgcreate chinaskill-vg /dev/vdb1 /dev/vdb2 /dev/vdb3
Physical volume "/dev/vdb1" successfully created.
Physical volume "/dev/vdb2" successfully created.
Physical volume "/dev/vdb3" successfully created.
Volume group "chinaskill-vg" successfully created

9.使用OpenStack私有云平台,创建三个云主机,使用提供的软件包安装RabbitMQ服务,安装完毕后,搭建RabbitMQ集群,并打开RabbitMQ服务的图形化监控页面插件。集群使用普通集群模式,其中第一台做磁盘节点,另外两台做内存节点。

10.使用提供的iaas-error7镜像创建云主机,创建后的云主机内有错误的OpenStack平台,错误现象为neutron网络命令无法正常使用,请结合报错信息排查错误,使neutron服务可以正常使用。

云计算赛项赛卷8

1.使用提供的OpenStack私有云平台,修改普通用户权限,使普通用户不能对镜像进行创建和删除操作。

2.在提供的OpenStack私有云平台上,在/root目录下编写Heat模板create_user.yaml,创建名为heat-user的用户,属于admin项目,并赋予heat-user用户admin的权限,配置用户密码为123456。

1
2
3
4
5
6
7
8
9
10
11
[root@controller ~]# cat user.yml 
heat_template_version: 2018-03-02
resources:
user:
type: OS::Keystone::User
properties:
name: heat-user
password: 000000
domain: demo
default_project: admin
roles: [{"role":"admin","project":"admin"}]

3.使用提供的OpenStack私有云平台,优化KVM的I/O调度算法,将默认的deadline修改为none模式。

1
2
3
[root@controller ~]# echo none > /sys/block/vda/queue/scheduler 
[root@controller ~]# cat /sys/block/vda/queue/scheduler
[none] mq-deadline kyber

4.在提供的OpenStack私有云平台,创建一台云主机,配置该主机为nfs的server端,将该云主机中的/mnt/test目录进行共享(目录不存在可自行创建)。然后配置controller节点为nfs的client端,要求将/mnt/test目录作为glance后端存储的挂载目录。

5.使用提供的OpenStack私有云平台,申请三台云主机,使用提供的http源,在两个节点自行安装redis服务并启动,配置redis的访问需要密码,密码设置为123456。然后将这三个redis节点配置为redis的一主二从三哨兵架构

主节点:

yum install -y redis

1
2
3
4
5
6
vi /etc/redis.conf 
bind 0.0.0.0
protected-mode no
daemonize yes
masterauth 123456
requirepass 123456

systemctl restart redis

systemctl enable redis

从节点1:

yum install -y redis

1
2
3
4
5
6
7
vi /etc/redis.conf
bind 0.0.0.0
protected-mode no
daemonize yes
slaveof 192.168.20.104 6379
masterauth 123456
requirepass 123456

systemctl restart redis

systemctl enable redis

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@redis-2 ~]# redis-cli 
127.0.0.1:6379> info
.................
# Replication
role:slave
master_host:192.168.20.104
master_port:6379
master_link_status:up
master_last_io_seconds_ago:7
master_sync_in_progress:0
slave_repl_offset:589
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
....................

从节点2:

yum install -y redis

1
2
3
4
5
6
7
vi /etc/redis.conf
bind 0.0.0.0
protected-mode no
daemonize yes
slaveof 192.168.20.104 6379
masterauth 123456
requirepass 123456

systemctl restart redis

systemctl enable redis

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@redis-3 ~]# redis-cli 
127.0.0.1:6379> info
.................
# Replication
role:slave
master_host:192.168.20.104
master_port:6379
master_link_status:up
master_last_io_seconds_ago:7
master_sync_in_progress:0
slave_repl_offset:589
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
....................

1、哨兵模式搭建:
哨兵模式需要修改sentinel.conf文件,三台服务器均为此配置

vi /etc/redis-sentinel.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
端口默认为26379。
port 26379
关闭保护模式,可以外部访问。
protected-mode no
设置为后台启动。
daemonize yes
指定主机IP地址和端口(三台配置均为指定主机ip),并且指定当有2台哨兵认为主机宕机,则对主机进行容灾切换。mymaster:设置master名字,必须在其它有用到该名字的命令之前设置
sentinel monitor mymaster 192.168.20.104 6379 2
当在Redis实例中开启了requirepass,这里就需要提供密码。
sentinel auth-pass mymaster 123456
这里设置了主机多少秒无响应,则认为挂了。此处3秒
sentinel down-after-milliseconds mymaster 3000
主备切换时,最多有多少个slave同时对新的master进行同步,这里设置为默认的1。
snetinel parallel-syncs mymaster 1
故障转移的超时时间,这里设置为三分钟。
sentinel failover-timeout mymaster 180000

启动哨兵模式

redis-sentinel /etc/redis-sentinel.conf

6.使用提供的OpenStack私有云平台,申请三台云主机,分别命令为node1、node2、node3,使用提供的软件包,在这三个节点上安装数据库服务,数据库密码设置为123456。将这三个节点配置为数据库高可用集群即MariaDB_Galera_Cluster。

7.使用manila共享文件系统服务,使manila为多租户云环境中的共享文件系统提供统一的管理服务。

8.使用Blazar服务,使得管理员可以在OpenStack中为虚拟(实例,卷等)和物理(主机,存储等)的不同资源类型提供资源预留的能力。

9.使用cloudkitty计费服务,使用hashmap计费模型处理来自不同监控指标后端的数据并进行计费规则创建。以达到费用核算目的。

10.使用提供的iaas-error8镜像创建云主机,创建后的云主机内有错误的OpenStack平台,错误现象为上传镜像一直处于pending状态,请结合报错信息排查错误,使glance服务可以正常使用。

云计算赛项赛卷9

1.OpenStack各服务内部通信都是通过RPC来交互,各agent都需要去连接RabbitMQ;随着各服务agent增多,MQ的连接数会随之增多,最终可能会到达上限,成为瓶颈。使用提供的OpenStack私有云平台,通过修改limits.conf配置文件来修改RabbitMQ服务的最大连接数为10240。

2.在提供的OpenStack私有云平台上,在/root目录下编写Heat模板create_net.yaml,创建名为Heat-Network网络,选择不共享;创建子网名为Heat-Subnet,子网网段设置为10.20.2.0/24,开启DHCP服务,地址池为10.20.2.20-10.20.2.100。

3.使用提供的OpenStack私有云平台,申请三台云主机,分别命令为node1、node2、node3,使用提供的软件包,在这三个节点上安装数据库服务,数据库密码设置为123456。将这三个节点配置为数据库高可用集群即MariaDB_Galera_Cluster。

4.使用上一题配置完成的数据库集群,使用提供的mariadb-repo.tar.gz软件包,安装haproxy负载均衡服务。配置node1节点为负载均衡的窗口,配置负载均衡为轮询算法;HA服务监听的端口为node1节点的3307端口;配置访问三个节点的权重依次为1,2,4。

5.在OpenStack私有云平台,创建一台云主机,编写脚本,使得可以一键部署ELK系统。

6.在提供的OpenStack平台上,上传cirros镜像,并对该镜像打上一个test的标签。

openstack image set cirros --tag test

7.使用manila共享文件系统服务,使manila为多租户云环境中的共享文件系统提供统一的管理服务。

8.使用Blazar服务,使得管理员可以在OpenStack中为虚拟(实例,卷等)和物理(主机,存储等)的不同资源类型提供资源预留的能力。

9.使用cloudkitty计费服务,处理来自不同监控指标后端的数据并进行计费规则创建。以达到费用核算目的。

10.使用提供的iaas-error9镜像创建云主机,创建后的云主机内有错误的OpenStack平台,错误现象为cinder服务因创建的卷太多,无法满足使用,请结合报错信息排查错误,扩容cinder存储池,使cinder服务可以正常使用。

云计算赛项赛卷10

1.在提供的OpenStack平台上,通过nova的相关命令创建云主机类型,名字exam,ID为1234,内存为1024,硬盘为20G,虚拟内核数量为2。并修改云平台中默认每个tenant的实例配额为20个。

1
2
3
4
5
6
[root@controller ~]# nova flavor-create --is-public true exam 1234 1024 20 2
+------+------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | Description |
+------+------+-----------+------+-----------+------+-------+-------------+-----------+-------------+
| 1234 | exam | 1024 | 20 | 0 | | 2 | 1.0 | True | - |
+------+------+-----------+------+-----------+------+-------+-------------+-----------+-------------+

2.在提供的OpenStack平台上,使用Zun组件创建容器。

3.在日常运维管理中,安装包的依赖关系冲突是经常存在的。在控制节点,安装libguestfs-tools工具的时候,会发生依赖包的冲突,请解决依赖关系的报错,完成libguestfs-tools工具的安装。

4.使用提供的OpenStack私有云平台,假设在使用过程中,发现该创建的云主机配置太低,需要调整,请修改相应配置,将dashboard界面上的云主机调整实例大小可以使用。

5.在提供的OpenStack平台上,使用ceilometer相关命令,修改名称为cpu_hi的告警状态为不生效。

6.使用manila共享文件系统服务,使manila为多租户云环境中的共享文件系统提供统一的管理服务。

7.使用Blazar服务,使得管理员可以在OpenStack中为虚拟(实例,卷等)和物理(主机,存储等)的不同资源类型提供资源预留的能力。

8.使用cloudkitty计费服务,处理来自不同监控指标后端的数据并进行计费规则创建。以达到费用核算目的。

9.在OpenStack私有云平台,创建一台云主机,编写脚本,要求可以完成数据库的定期备份,把数据库备份文件存放在/opt目录下,要求每个备份文件都已时间命名,并只保留一个月的备份文件,超过一个月的自动删除。

10.使用提供的iaas-error10镜像创建云主机,创建后的云主机内有错误的OpenStack平台,错误现象为安全组策略无法正常使用,请结合报错信息排查错误,使安全组可以正常使用。