A模块题目OpenStack平台部署与运维

任务 1 私有云平台环境初始化(6 分)

IP 主机名
192.168.157.30 controller
192.168.157.31 compute

1.配置主机名

把 controller 节点主机名设置为 controller, compute 节点主机名设置为 compute。

分别在 controller 节点和 compute 节点将 hostname 命令的返回结果提交到答题框。【0.5 分】

[root@controller ~]# hostname
controller

[root@compute ~]# hostname
compute

解法:

hostnamectl set-hostname controller

hostnamectl set-hostname compute

2.配置 hosts 文件

分别在 controller 节点和 compute 节点修改 hosts 文件将 IP 地址映射为主机名。

请在 controller 节点将 cat /etc/hosts 命令的返回结果提交到答题框。 【0.5 分】

[root@controller ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.157.30 controller
192.168.157.31 compute


[root@compute ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.157.30 controller
192.168.157.31 compute

3.挂载光盘镜像

将提供的 CentOS-7-x86_64-DVD-1804.iso 和 bricsskills_cloud_iaas.iso 光盘镜像移动到

controller 节点 /root 目录下,然后在 /opt 目录下使用命令创建 centos 目录和 iaas 目录,

并将镜像文件 centOS-7-x86_64-DVD-1804.iso 挂载到 /opt/centos 目录下,将镜像文件

bricsskills_cloud_iaas.iso 挂载到 /iaas 目录下。

请在 controller 节点将 ls /opt/iaas/命令的返回结果提交到答题框。【0.5 分】

iaas-repo  images

解法:

#将指定的镜像上传至/root目录下
 #挂载
 
[root@controller ~]# cat >> /etc/fstab << EOF
/root/CentOS-7-x86_64-DVD-1804.iso /opt/centos iso9660 defaults 0 0
/root/chinaskills_cloud_iaas.iso /opt/iaas iso9660 defaults 0 0
EOF

4.配置 controller 节点 yum 源

将 controller 节点原有的 yum 源移动到/home 目录,

为 controller 节点创建本地 yum 源,

yum 源文件名为 local.repo。

请将 yum list | grep vsftpd 的返回结果提交到答题框。【0.5 分】

[root@controller ~]# yum list | grep vsftpd
vsftpd.x86_64                              3.0.2-22.el7                centos

解法:

[root@controller ~]# mkdir /home/yum
[root@controller ~]# mv /etc/yum.repos.d/* /home/yum
[root@controller ~]# cat /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=file:///opt/iaas/iaas-repo
gpgcheck=0
enabled=1

[root@controller ~]# yum repolist

5.搭建 ftp 服务器

在 controller 节点上安装 vsftp 服务, 将/opt 目录设为共享,并设置为开机自启动,然后

重启服务生效。

请将 cat /etc/vsftpd/vsftpd.conf |grep /opt 命令的返回结果提交到答题框。【1 分】

[root@controller ~]#  cat /etc/vsftpd/vsftpd.conf |grep /opt
anon_root=/opt

解法:

[root@controller ~]# yum install -y vsftpd
[root@controller ~]# cat /etc/vsftpd/vsftpd.conf
#添加
anon_root=/opt
[root@controller ~]# systemctl enable vsftpd --now
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.

#关闭防火墙及安全策略
[root@controller ~]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@controller ~]# setenforce 0
[root@controller ~]# cat /etc/selinux/config
SELINUX=permissive

[root@compute ~]# systemctl stop firewalld && systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@compute ~]# setenforce 0
[root@compute ~]# cat /etc/selinux/config
SELINUX=permissive


6.配置 compute 节点 yum 源

将 compute 节点原有的 yum 源移动到/home 目录,为 compute 节点创建 ftp 源,yum 源文件

名为 ftp.repo,其中 ftp 服务器为 controller 节点,配置 ftp 源时不要写 IP 地址。

请将 yum list | grep xiandian 命令的返回结果提交到答题框【1 分】

[root@compute ~]# yum list | grep xiandian
iaas-xiandian.x86_64                       2.4-2                       iaas-0

解法:

[root@compute ~]# mkdir /home/yum
[root@compute ~]# mv /etc/yum.repos.d/* /home/yum
[root@compute ~]# cat /etc/yum.repos.d/ftp.repo
[centos]
name=centos
baseurl=ftp://controller/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=ftp://controller/iaas/iaas-repo
gpgcheck=0
enabled=1
[root@compute ~]# yum repolist

7.分区

在 compute 节点将 vdb 分为两个区分别为 vdb1 和 vdb2,大小自定义。要求分区格式为 gpt,

使用 mkfs.xfs 命令对文件系统格式化。

请将 lsblk -f 命令的返回结果提交到答题框【1 分】

虚拟机没有vdb区,使用sdb分区进行代替

[root@compute ~]# lsblk -f
NAME            FSTYPE      LABEL           UUID                                   MOUNTPOINT
sda
├─sda1          xfs                         c2b0cad1-cdef-48c6-adb7-5e4eafaf7458   /boot
└─sda2          LVM2_member                 oiioJ7-K5mu-sPhw-R4Rb-S3yH-fWo9-23G9aY
  ├─centos-root xfs                         e78104be-5c62-4102-b730-f03cde9fa24a   /
  └─centos-swap swap                        74991746-7fc7-4936-a835-4f603f2468c8   [SWAP]
sdb
├─sdb1          xfs                         25a1594a-769d-48ac-966c-d59607cd0bb4
└─sdb2          xfs                         c49808f0-0ac0-4848-957d-e0525f1117b3
sdc
sr0             iso9660     CentOS 7 x86_64 2018-05-03-20-55-23-00

解法:

[root@compute ~]# yum install -y gdisk
[root@compute ~]# gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-41943006, default = 2048) or {
   +-}size{
   KMGTP}:
Last sector (2048-41943006, default = 41943006) or {
   +-}size{
   KMGTP}: +10G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

Command (? for help): n
Partition number (2-128, default 2):
First sector (34-41943006, default = 20973568) or {
   +-}size{
   KMGTP}:
Last sector (20973568-41943006, default = 41943006) or {
   +-}size{
   KMGTP}: +10G
Last sector (20973568-41943006, default = 41943006) or {
   +-}size{
   KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.


[root@compute ~]# mkfs.xfs /dev/sdb1
[root@compute ~]# mkfs.xfs /dev/sdb2


8.系统调优-脏数据回写

Linux 系统内存中会存在脏数据,一般系统默认脏数据占用内存 30%时会回写磁盘,修

改系统配置文件,要求将回写磁盘的大小调整为 60%。

在 controller 节点请将 sysctl -p 命令的返回结果提交到答题框。【1 分】

[root@controller ~]# sysctl -p
vm.dirty_ratio = 60

解法:

[root@controller ~]# cat /etc/sysctl.conf
vm.dirty_ratio = 60

任务 2 OpenStack 搭建任务(8 分)

1.修改脚本文件

在 controller 节点和 compute 节点分别安装 iaas-xiandian 软件包,修改脚本文件基本变

量(脚本文件为/etc/xiandian/openrc.sh),修改完成后使用命令生效该脚本文件。

在 controller 节点请将 echo $INTERFACE_NAME 命令的返回结果提交到答题框。【0.5 分】

[root@controller ~]# echo $INTERFACE_NAME
eth36

解法:

#controller节点与compute节点做法相同
#只修改interface_ip和INTERFACE_NAME  即可

[root@controller ~]# yum install -y iaas-xiandian
[root@controller ~]# cat /etc/xiandian/openrc.sh
#--------------------system Config--------------------##
#Controller Server Manager IP. example:x.x.x.x
HOST_IP=192.168.157.30

#Controller HOST Password. example:000000
HOST_PASS=000000

#Controller Server hostname. example:controller
HOST_NAME=controller

#Compute Node Manager IP. example:x.x.x.x
HOST_IP_NODE=192.168.157.31

#Compute HOST Password. example:000000
HOST_PASS_NODE=000000

#Compute Node hostname. example:compute
HOST_NAME_NODE=compute

#--------------------Chrony Config-------------------##
#Controller network segment IP.  example:x.x.0.0/16(x.x.x.0/24)
network_segment_IP=192.168.157,0/24

#--------------------Rabbit Config ------------------##
#user for rabbit. example:openstack
RABBIT_USER=openstack

#Password for rabbit user .example:000000
RABBIT_PASS=000000

#--------------------MySQL Config---------------------##
#Password for MySQL root user . exmaple:000000
DB_PASS=000000

#--------------------Keystone Config------------------##
#Password for Keystore admin user. exmaple:000000
DOMAIN_NAME=demo
ADMIN_PASS=000000
DEMO_PASS=000000

#Password for Mysql keystore user. exmaple:000000
KEYSTONE_DBPASS=000000

#--------------------Glance Config--------------------##
#Password for Mysql glance user. exmaple:000000
GLANCE_DBPASS=000000

#Password for Keystore glance user. exmaple:000000
GLANCE_PASS=000000

#--------------------Nova Config----------------------##
#Password for Mysql nova user. exmaple:000000
NOVA_DBPASS=000000

#Password for Keystore nova user. exmaple:000000
NOVA_PASS=000000

#--------------------Neturon Config-------------------##
#Password for Mysql neutron user. exmaple:000000
NEUTRON_DBPASS=000000

#Password for Keystore neutron user. exmaple:000000
NEUTRON_PASS=000000

#metadata secret for neutron. exmaple:000000
METADATA_SECRET=000000

#Tunnel Network Interface. example:x.x.x.x
INTERFACE_IP=192.168.157.30

#External Network Interface. example:eth1
INTERFACE_NAME=eth36

#External Network The Physical Adapter. example:provider
Physical_NAME=provider

#First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101
minvlan=101

#Last Vlan ID in VLAN RANGE for VLAN Network. example:200
maxvlan=200

#--------------------Cinder Config--------------------##
#Password for Mysql cinder user. exmaple:000000
CINDER_DBPASS=000000

#Password for Keystore cinder user. exmaple:000000
CINDER_PASS=000000

#Cinder Block Disk. example:md126p3
BLOCK_DISK=sdb1

#--------------------Swift Config---------------------##
#Password for Keystore swift user. exmaple:000000
SWIFT_PASS=000000

#The NODE Object Disk for Swift. example:md126p4.
OBJECT_DISK=sdb2

#The NODE IP for Swift Storage Network. example:x.x.x.x.
STORAGE_LOCAL_NET_IP=192.168.157.31

#--------------------Heat Config----------------------##
#Password for Mysql heat user. exmaple:000000
HEAT_DBPASS=000000

#Password for Keystore heat user. exmaple:000000
HEAT_PASS=000000

#--------------------Zun Config-----------------------##
#Password for Mysql Zun user. exmaple:000000
ZUN_DBPASS=000000

#Password for Keystore Zun user. exmaple:000000
ZUN_PASS=000000

#Password for Mysql Kuryr user. exmaple:000000
KURYR_DBPASS=000000

#Password for Keystore Kuryr user. exmaple:000000
KURYR_PASS=000000

#--------------------Ceilometer Config----------------##
#Password for Gnocchi ceilometer user. exmaple:000000
CEILOMETER_DBPASS=000000

#Password for Keystore ceilometer user. exmaple:000000
CEILOMETER_PASS=000000

#--------------------AODH Config----------------##
#Password for Mysql AODH user. exmaple:000000
AODH_DBPASS=000000

#Password for Keystore AODH user. exmaple:000000
AODH_PASS=000000

#--------------------Barbican Config----------------##
#Password for Mysql Barbican user. exmaple:000000
BARBICAN_DBPASS=000000

#Password for Keystore Barbican user. exmaple:000000
BARBICAN_PASS=000000

root@controller ~]# source /etc/xiandian/openrc.sh

2.修改脚本文件

在 compute 节点配置/etc/xiandian/openrc.sh 文件,根据环境情况修改参数,块存储服务

的后端使用第二块硬盘的第一个分区,生效该参数文件。

请将 echo $INTERFACE_IP&& echo $BLOCK_DISK 命令的返回结果提交到答题框。【0.5 分】

[root@compute ~]#  echo $INTERFACE_IP&& echo $BLOCK_DISK
192.168.157.31
sdb1

解法:

[root@compute ~]# cat /etc/xiandian/openrc.sh
#--------------------system Config--------------------##
#Controller Server Manager IP. example:x.x.x.x
HOST_IP=192.168.157.30

#Controller HOST Password. example:000000
HOST_PASS=000000

#Controller Server hostname. example:controller
HOST_NAME=controller

#Compute Node Manager IP. example:x.x.x.x
HOST_IP_NODE=192.168.157.31

#Compute HOST Password. example:000000
HOST_PASS_NODE=000000

#Compute Node hostname. example:compute
HOST_NAME_NODE=compute

#--------------------Chrony Config-------------------##
#Controller network segment IP.  example:x.x.0.0/16(x.x.x.0/24)
network_segment_IP=192.168.157,0/24

#--------------------Rabbit Config ------------------##
#user for rabbit. example:openstack
RABBIT_USER=openstack

#Password for rabbit user .example:000000
RABBIT_PASS=000000

#--------------------MySQL Config---------------------##
#Password for MySQL root user . exmaple:000000
DB_PASS=000000

#--------------------Keystone Config------------------##
#Password for Keystore admin user. exmaple:000000
DOMAIN_NAME=demo
ADMIN_PASS=000000
DEMO_PASS=000000

#Password for Mysql keystore user. exmaple:000000
KEYSTONE_DBPASS=000000

#--------------------Glance Config--------------------##
#Password for Mysql glance user. exmaple:000000
GLANCE_DBPASS=000000

#Password for Keystore glance user. exmaple:000000
GLANCE_PASS=000000

#--------------------Nova Config----------------------##
#Password for Mysql nova user. exmaple:000000
NOVA_DBPASS=000000

#Password for Keystore nova user. exmaple:000000
NOVA_PASS=000000

#--------------------Neturon Config-------------------##
#Password for Mysql neutron user. exmaple:000000
NEUTRON_DBPASS=000000

#Password for Keystore neutron user. exmaple:000000
NEUTRON_PASS=000000

#metadata secret for neutron. exmaple:000000
METADATA_SECRET=000000

#Tunnel Network Interface. example:x.x.x.x
INTERFACE_IP=192.168.157.31

#External Network Interface. example:eth1
INTERFACE_NAME=eth37

#External Network The Physical Adapter. example:provider
Physical_NAME=provider

#First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101
minvlan=101

#Last Vlan ID in VLAN RANGE for VLAN Network. example:200
maxvlan=200

#--------------------Cinder Config--------------------##
#Password for Mysql cinder user. exmaple:000000
CINDER_DBPASS=000000

#Password for Keystore cinder user. exmaple:000000
CINDER_PASS=000000

#Cinder Block Disk. example:md126p3
BLOCK_DISK=sdb1

#--------------------Swift Config---------------------##
#Password for Keystore swift user. exmaple:000000
SWIFT_PASS=000000

#The NODE Object Disk for Swift. example:md126p4.
OBJECT_DISK=sdb2

#The NODE IP for Swift Storage Network. example:x.x.x.x.
STORAGE_LOCAL_NET_IP=192.168.157.31

#--------------------Heat Config----------------------##
#Password for Mysql heat user. exmaple:000000
HEAT_DBPASS=000000

#Password for Keystore heat user. exmaple:000000
HEAT_PASS=000000

#--------------------Zun Config-----------------------##
#Password for Mysql Zun user. exmaple:000000
ZUN_DBPASS=000000

#Password for Keystore Zun user. exmaple:000000
ZUN_PASS=000000

#Password for Mysql Kuryr user. exmaple:000000
KURYR_DBPASS=000000

#Password for Keystore Kuryr user. exmaple:000000
KURYR_PASS=000000

#--------------------Ceilometer Config----------------##
#Password for Gnocchi ceilometer user. exmaple:000000
CEILOMETER_DBPASS=000000

#Password for Keystore ceilometer user. exmaple:000000
CEILOMETER_PASS=000000

#--------------------AODH Config----------------##
#Password for Mysql AODH user. exmaple:000000
AODH_DBPASS=000000

#Password for Keystore AODH user. exmaple:000000
AODH_PASS=000000

#--------------------Barbican Config----------------##
#Password for Mysql Barbican user. exmaple:000000
BARBICAN_DBPASS=000000

#Password for Keystore Barbican user. exmaple:000000
BARBICAN_PASS=000000

[root@compute ~]# source /etc/xiandian/openrc.sh

3.安装 openstack 包

分别在 controller 节点和 compute 节点执行 iaas-pre-host.sh 文件(不需要重启云主机)。

在 controller 节点请将 openstack --version 命令的返回结果提交到答题框。【1 分】

[root@controller ~]# openstack --version
openstack 3.14.3

解法:

[root@controller ~]# iaas-pre-host.sh
[root@compute ~]# iaas-pre-host.sh

4. 搭建数据库组件

在 controller 节点执行 iaas-install-mysql.sh 脚本,会自行安装 mariadb、memcached、

rabbitmq 等服务和完成相关配置。执行完成后修改配置文件将缓存 CACHESIZE 修改为 128,

并重启相应服务。

请将 ps aux|grep memcached 命令的返回结果提交到答题框。【1 分】

[root@controller ~]# ps aux|grep memcached
memcach+  15901  0.1  0.0 443040  2164 ?        Ssl  09:15   0:00 /usr/bin/memcached -p 11211 -u memcached -m 128 -c 1024 -l 127.0.0.1,::1,controller
root      15919  0.0  0.0 112704   960 pts/0    S+   09:15   0:00 grep --color=auto memcached

解法:

[root@controller ~]# iaas-install-mysql.sh
[root@controller ~]# rpm -qc memcached
/etc/sysconfig/memcached
[root@controller ~]# cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="128"
OPTIONS="-l 127.0.0.1,::1,controller"
[root@controller ~]# systemctl restart memcached

5.搭建认证服务组件

在 controller 节点执行 iaas-install-keystone.sh 脚本,会自行安装 keystone 服务和完成相

关配置。使用 openstack 命令,创建一个名为 tom 的账户,密码为 tompassword123,邮箱为

tom@example.com。

请将 openstack user list 命令的返回结果提交到答题框。【1 分】

[root@controller ~]# openstack user list
+----------------------------------+-------+
| ID                               | Name  |
+----------------------------------+-------+
| 0a22a2d4f3964cfbbbd6474dc92cca01 | admin |
| 196d426492be403b8fbaa4b0c0f8e2a9 | tom   |
| 314971684b4d4345b5aa43b2dd55339f | demo  |
+----------------------------------+-------+

解法:

[root@controller ~]# iaas-install-keystone.sh
[root@controller ~]# source /etc/keystone/admin-openrc.sh
[root@controller ~]# openstack user create tom --password tompassword123 --email tom@example.com --domain demo
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | ed6f7dc2006d4010bd9194ebc576d9e9 |
| email               | tom@example.com                  |
| enabled             | True                             |
| id                  | 196d426492be403b8fbaa4b0c0f8e2a9 |
| name                | tom                              |
| options             | {
   }                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

6.搭建镜像服务组件

在 controller 节点执行 iaas-install-glance.sh 脚本,会自行安装 glance 服务和完成相关

配 置 。 完 成 后 使 用 openstack 命 令 , 创 建 一 个 名 为 cirros 的 镜 像 , 镜 像 文 件 使 用

cirros-0.3.4-x86_64-disk.img。

请将 openstack image show cirros 命令的返回结果提交到答题框。【1 分】

[root@controller ~]#  openstack image show cirros
+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | 443b7623e27ecf03dc9e01ee93f67afe                     |
| container_format | bare                                                 |
| created_at       | 2023-03-13T13:29:50Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/4219d1cb-5238-4720-a7be-167f9b158a9b/file |
| id               | 4219d1cb-5238-4720-a7be-167f9b158a9b                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | cirros                                               |
| owner            | 1a99aaa6a1024d84a00a779c4d186b44                     |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 12716032                                             |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2023-03-13T13:29:50Z                                 |
| virtual_size     | None                                                 |

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部