基础运维任务 设置各服务器节点的IP地址,确保网络正常通信,设置云服务器1主机名为Controller,云服务器2主机名为Compute,并在各服务器节点中设置主机名与IP地址的映射、关闭防火墙并设置为开机不启动、SELinux 为 Permissive 模式。(1分)
1 2 3 hostnamectl set-hostname controller bash vi /etc/hosts
hosts内容
1 2 3 4 5 192.168.10.10 controller 192.168.10.20 compute 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
配置免密登录
2.将提供的CentOS-7-x86_64-DVD-1804.iso和OpenStackQueens.iso光盘镜像上传到Controller服务器的/root目录下,然后在/opt目录下分别创建centos目录和openstack目录,并将镜像文件CentOS-7-x86_64-DVD-1804.iso挂载到centos目录下,将镜像文件OpenStackQueens.iso挂载到openstack目录下。(1分)
1 2 3 4 mkdir /opt/centosmkdir /opt/iaasmount -o loop chinaskills_cloud_iaas.iso /opt/iaas/ mount -o loop CentOS-7.5-x86_64-DVD-1804.iso /opt/centos/
3.在Controller服务器上利用centos目录中的软件包安装vsftp服务器并设置开机自启动,提供yum仓库服务,并分别设置controller和compute服务器的yum源文件ftp.repo,其中节点的地址使用主机名形式。(1分)
1 2 3 4 5 6 7 8 9 rm -rf /etc/yum.repos.d/*vi /etc/yum.repos.d/http.repo yum repolist yum install -y vsftpd vi /etc/vsftpd/vsftpd.conf systemctl restart vsftpd setenforce 0 systemctl stop firewalld systemctl disable firewalld
controller节点repo
1 2 3 4 5 6 7 8 9 10 [centos] name=centos baseurl=file:///opt/centos gpgcheck=0 enabled=1 [iaas] name=iaas baseurl=file:///opt/iaas/iaas-repo gpgcheck=0 enabled=1
compute节点
1 2 3 4 5 6 7 8 9 10 [centos] name=centos baseurl=ftp://controller/centos gpgcheck=0 enabled=1 [iaas] name=iaas baseurl=ftp://controller/iaas/iaas-repo gpgcheck=0 enabled=1
5.在compute节点上创建2个20G的磁盘分区。(1分)
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@compute ~] NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 199G 0 part ├─centos-root 253:0 0 50G 0 lvm / ├─centos-swap 253:1 0 7.9G 0 lvm [SWAP] └─centos-home 253:2 0 141.1G 0 lvm /home sdb 8:16 0 50G 0 disk sr0 11:0 1 4.2G 0 rom [root@compute ~] 欢迎使用 fdisk (util-linux 2.23.2)。 更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。 Device does not contain a recognized partition table 使用磁盘标识符 0x95832372 创建新的 DOS 磁盘标签。 命令(输入 m 获取帮助):n Partition type : p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p 分区号 (1-4,默认 1): 起始 扇区 (2048-104857599,默认为 2048): 将使用默认值 2048 Last 扇区, +扇区 or +size{K,M,G} (2048-104857599,默认为 104857599):+20G 分区 1 已设置为 Linux 类型,大小设为 20 GiB 命令(输入 m 获取帮助):n Partition type : p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p 分区号 (2-4,默认 2): 起始 扇区 (41945088-104857599,默认为 41945088): 将使用默认值 41945088 Last 扇区, +扇区 or +size{K,M,G} (41945088-104857599,默认为 104857599):+20G 分区 2 已设置为 Linux 类型,大小设为 20 GiB 命令(输入 m 获取帮助):w The partition table has been altered! Calling ioctl() to re-read partition table. 正在同步磁盘。
OpenStack搭建任务 环境变量配置(1分) 在控制节点和计算节点分别安装iaas-xiandian软件包,根据表2完成脚本文件openrc.sh的配置
1 2 3 yum install iaas-xiandian -y vi /etc/xiandian/openrc.sh scp /etc/xiandian/openrc.sh compute:/etc/xiandian/openrc.sh
openrc.sh内容 (:%s/PASS=/PASS=000000/g)替换
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 # --------------------system Config-------------------- # Controller Server Manager IP. example:x.x.x.x HOST_IP=192.168.10.10 //controller节点nat网卡的ip # 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.10.20 //compute节点nat网卡IP # 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.10.0/24 //两个节点nat网卡的网段 用于时间同步服务 # --------------------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=172.17.1.10 //当前节点的内网IP 也就是controller节点的nat网卡IP 在compute节点就是172.17.1.20 两个节点的配置文件就这里不一样 其他直接复制即可 # External Network Interface. example:eth1 INTERFACE_NAME=ens33 //内网网卡=nat网卡 # External Network The Physical Adapter. example:provider Physical_NAME=provider //供应商名称 默认 # First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101 minvlan=101 //VLAN id 默认 # Last Vlan ID in VLAN RANGE for VLAN Network. example:200 maxvlan=200 //VLAN id 默认 # --------------------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 //compute节点分好的区 用于cinder块存储 具体区你们的compute节点上查看 查看分区命令:lsblk # --------------------Swift Config--------------------- # Password for Keystore swift user. exmaple:000000 SWIFT_PASS=000000 # The NODE Object Disk for Swift. example:md126p4. OBJECT_DISK=sdb2 //compute节点分好的区 用于swift对象存储 具体区你们的compute节点上查看 查看分区命令:lsblk # The NODE IP for Swift Storage Network. example:x.x.x.x. STORAGE_LOCAL_NET_IP=192.168.10.20 //swift服务运行的节点 compute节点的ip # --------------------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
执行安装脚本 controller节点
1 2 3 4 5 6 7 iaas-pre-host.sh iaas-install-mysql.sh iaas-install-keystone.sh iaas-install-glance.sh iaas-install-nova-controller.sh iaas-install-neutron-controller.sh iaas-install-dashboard.sh
compute节点
1 2 3 iaas-pre-host.sh iaas-install-nova-compute.sh iaas-install-neutron-compute.sh
省比赛只到这里,我不确定后面还要不
1 2 3 4 5 6 iaas-install-cinder-controller.sh iaas-install-swift-controller.sh iaas-install-heat.sh iaas-install-zun-controller.sh iaas-install-ceilometer-controller.sh iaas-install-aodh.sh
compute
1 2 3 4 iaas-install-cinder-compute.sh iaas-install-swift-compute.sh iaas-install-zun-compute.sh iaas-install-ceilometer-compute.sh
数据库安装(2分) 使用脚本安装数据库服务,进入数据库。
(1)创建本地用户examuser,密码为000000;
(2)查询mysql数据库中的user表的host,user,password字段;
(3)赋予这个用户对所有数据库拥有“查询”“删除”“更新”“创建”的本地权限。 依次将操作命令和返回结果以文本形式提交到答题框。
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@controller ~] [MariaDB [(none)]> insert into mysql.user(host,user,Password) values("localhost" ,"examuser" ,Password("000000" )); Query OK, 1 row affected, 4 warnings (0.00 sec) MariaDB [(none)]> 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 MariaDB [mysql]> select host,user,password from user; +-----------+----------+-------------------------------------------+ | host | user | password | +-----------+----------+-------------------------------------------+ | localhost | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | xiandian | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | 127.0.0.1 | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | ::1 | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | localhost | keystone | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | % | keystone | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | localhost | glance | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | % | glance | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | localhost | nova | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | % | nova | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | localhost | neutron | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | % | neutron | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | localhost | cinder | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | % | cinder | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | localhost | heat | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | % | heat | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | localhost | aodh | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | % | aodh | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | localhost | examuser | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | +-----------+----------+-------------------------------------------+ 19 rows in set (0.00 sec) MariaDB [mysql]> grant select,delete,update,create on *.* to examuser@"localhost" identified by "000000" ; Query OK, 0 rows affected (0.01 sec) MariaDB [mysql]> flush privileges; //刷新权限 MariaDB [mysql]> exit
1 2 3 4 5 6 insert into mysql.user(host,user,Password) values("localhost","examuser",Password("000000")); use mysql select host,user,password from user; grant select,delete,update,create on *.* to examuser@"localhost" identified by "000000"; flush privileges; exit
版本2 数据库安装与调优[0.5 分] 在 controller 节点上使用 iaas-install-mysql.sh 脚本安装 Mariadb、Memcached、RabbitMQ 等服务。安装服务完毕后,修改/etc/my.cnf 文件,完成下列要求:
1.设置数据库支持大小写; 2.设置数据库缓存 innodb 表的索引,数据,插入数据时的缓冲为 4G;
3.设置数据库的 log buffer 为 64MB; 4.设置数据库的 redo log 大小为 256MB; 5.设置数据库的 redo log 文件组为 2。 完成后提交控制节点的用户名、密码和 IP 地址到答题框。
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 [root@controller ~]# iaas-pre-host.sh [root@compute ~]# iaas-pre-host.sh #执行完这一步,一定要重新连接,刷新一下,不然rabbitmq服务会报错 [root@compute ~]# iaas-install-mysql.sh [root@controller ~]# cat /etc/my.cnf # # This group is read both both by the client and the server # use it for options that affect everything # [client-server] # # This group is read by the server # [mysqld] # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 default-storage-engine = innodb innodb_file_per_table collation-server = utf8_general_ci init-connect = 'SET NAMES utf8' character-set-server = utf8 max_connections=10000 innodb_log_buffer_size = 4M #此参数确定些日志文件所用的内存大小,以M为单位。缓冲区更大能提高性能,但意外的故障将会丢失数据。MySQL开发人员建议设置为1-8M之间 innodb_log_file_size = 32M #此参数确定数据日志文件的大小,更大的设置可以提高性能,但也会增加恢复故障数据库所需的时间 innodb_log_files_in_group = 3 #为提高性能,MySQL可以以循环方式将日志文件写到多个文件。推荐设置为3 #1,数据库不区分大小写,其中 0:区分大小写,1:不区分大小写 lower_case_table_names =1 #2,设置innodb的数据缓冲为4G innodb_buffer_pool_size = 4G #3,传输数据包的大小值 max_allowed_packet = 30M # # include all files from the config directory # !includedir /etc/my.cnf.d [root@controller ~]#
修改OpenStack平台
修改Nova服务配置文件,设置参数“virt_type=qemu”。命令参数如下:
1 2 [root@controller ~]# crudini --set /etc/nova/nova.conf libvirt virt_type qemu [root@controller ~]# systemctl restart openstack-nova-compute
上传镜像,使用“openstack image list”命令查看当前可用镜像列表。命令如下:
1 2 3 4 5 6 7 8 9 [root@controller ~]# curl -O http://mirrors.douxuedu.com/newcloud/cirros-0.3.4-x86_64-disk.img [root@controller ~]# glance image-create --name cirros-0.3.4 --disk-format qcow2 --container-format bare --progress < cirros-0.3.4-x86_64-disk.img … [root@controller ~]# openstack image list +--------------------------------------+--------------+---------+ | ID | Name | Status | +--------------------------------------+--------------+---------+ | 32a2513c-e5ba-438b-a5ee-63c35c03b284 | cirros-0.3.4 | active | +--------------------------------------+--------------+---------+
创建镜像和网络:
1 2 3 4 5 6 7 [root@controller ~]# curl -O http://mirrors.douxuedu.com/newcloud/cirros-0.3.4-x86_64-disk.img [root@controller ~]# source /etc/keystone/admin-openrc.sh [root@controller ~]# glance image-create --name cirros-0.3.4 --disk-format qcow2 --container-format bare --progress < cirros-0.3.4-x86_64-disk.img … [root@controller ~]# openstack network create --provider-network-type vlan --provider-physical-network provider network-vlan --provider-segment 200 … [root@controller ~]# openstack subnet create --network network-vlan --allocation-pool start=192.168.200.100,end=192.168.200.200 --gateway 192.168.200.1 --subnet-range 192.168.200.0/24 subnet-vlan
NFS服务配置
1 2 3 vi /etc/exports /mnt/test 10.24.200.0/24(rw,no_root_squash,no_all_squash,sync,anonuid=501,anongid=501)
云主机调整类型大小 (1)修改配置文件
修改controller节点nova.conf配置文件,添加调整类型大小的参数,controller节点设置参数如下所示:
1 2 [root@controller ~]# crudini --set /etc/nova/nova.conf DEFAULT allow_resize_to_same_host True [root@controller ~]# crudini --set /etc/nova/nova.conf DEFAULT scheduler_default_filters RetryFilter,AvailabilityZoneFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter
keystone安装(2分) 使用脚本安装keystone服务,创建用户testuser,密码为xiandian,将testuser用户分配给admin项目,赋予用户admin的权限。依次将操作命令和查询结果以文本形式提交到答题框。
1 2 3 4 5 6 7 8 9 10 11 12 13 [root@controller ~]# iaas-install-keystone.sh [root@controller ~]# source /etc/keystone/admin-openrc.sh //加载keystone的环境变量 [root@controller ~]# openstack user create --domain demo --password xiandian testuser +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | 5a486c51bc8e4dffa4a181f6c54e0938 | | enabled | True | | id | ec6d67cdb3ac4b3ca827587c14be0a3e | | name | testuser | +-----------+----------------------------------+ [root@controller ~]# openstack role add --project admin --user testuser admin
版本2 Keystone 服务安装与使用[0.5 分] 在 controller 节点上使用 iaas-install-keystone.sh 脚本安装 Keystone 服务。安装完成后, 使用相关命令,创建用户 chinaskill,密码为 000000。完成后提交控制节点的用户名、密码和 IP 地址到答题框。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [root@controller ~]# iaas-install-keystone.sh [root@controller ~]# source /etc/keystone/admin-openrc.sh [root@controller ~]# openstack user create --domain demo --password 000000 chinaskill +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | b11e543ed5104ef79cd7a65c24ea156a | | enabled | True | | id | 8bd1afe33af44e24aeb9f3d9a234aa75 | | name | chinaskill | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+ [root@controller ~]# #注意我的域名是自定义的,正常应该是demo
glance安装(2分) 使用脚本安装glance服务。使用CentOS_6.5_x86_64_XD.qcow2文件创建名为examimage的镜像;使用openstack命令查看镜像列表;设置该镜像的标签为lastone,查询镜像详细信息。依次将操作命令和查询结果以文本形式提交到答题框。
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 [root@controller ~]# iaas-install-glance.sh [root@controller ~]# glance image-create --name "testone" --disk-format "qcow2" --container-format bare --progress < /root/CentOS_6.5_x86_64_XD.qcow2 [=============================>] 100% +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 3e565ace16066679ea363dde5411ed25 | | container_format | bare | | created_at | 2018-01-17T09:01:36Z | | disk_format | qcow2 | | id | 3bb63ae0-3129-442b-b19f-9f66298132aa | | min_disk | 0 | | min_ram | 0 | | name | examimage | | owner | 0ab2dbde4f754b699e22461426cd0774 | | protected | False | | size | 283181056 | | status | active | | tags | [] | | updated_at | 2018-01-17T09:01:38Z | | virtual_size | None | | visibility | private | +------------------+--------------------------------------+ [root@controller ~]# openstack image list +--------------------------------------+-----------+--------+ | ID | Name | Status | +--------------------------------------+-----------+--------+ | 3bb63ae0-3129-442b-b19f-9f66298132aa | examimage | active | +--------------------------------------+-----------+--------+ [root@controller ~]# openstack image set examimage --tag lastone [root@controller ~]# openstack image show examimage +------------------+------------------------------------------------------+ | Field | Value | +------------------+------------------------------------------------------+ | checksum | 3e565ace16066679ea363dde5411ed25 | | container_format | bare | | created_at | 2018-01-17T09:01:36Z | | disk_format | qcow2 | | file | /v2/images/3bb63ae0-3129-442b-b19f-9f66298132aa/file | | id | 3bb63ae0-3129-442b-b19f-9f66298132aa | | min_disk | 0 | | min_ram | 0 | | name | examimage | | owner | 0ab2dbde4f754b699e22461426cd0774 | | protected | False | | schema | /v2/schemas/image | | size | 283181056 | | status | active | | tags | lastone | | updated_at | 2018-01-18T01:15:18Z | | virtual_size | None | | visibility | private | +------------------+------------------------------------------------------+
命令详解 –name NAME 上传完镜像在openstack中显示的名称;
–disk-format DISK_FORMAT 镜像格式;openstack支持的格式详情请看官方介绍;
–container-format CONTAINER_FORMAT 图片的容器格式,可以是ami,ari,aki,ovf,bare默认是bare
–owner TENANT_ID 那个租户可以使用此镜像
–size SIZE 这个镜像的大小
–min-disk DISK_GB 这个镜像启动最小需要的大小;
–min-ram DISK_RAM 启动这个镜像需要的最小内存;
–location IMAGE_URL 在web界面中可以使用url地址上传镜像,目前支持http协议的;
–file FILE 镜像所在本地目录;
–checksum CHECKSUM 镜像数据验证;
–is-public [True|False] 是否共享此镜像;共享后其他用户也可以使用此镜像启动instance; 版本2
###nova管理(2分) 使用脚本安装nova服务,通过nova的相关命令创建名为exam,ID为1234,内存为1024M,硬盘为20G,虚拟内核数量为2的云主机类型,查看exam的详细信息。依次将操作命令及返回结果以文本形式提交到答题框。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 [root@controller ~]# iaas-install-nova-controller.sh /iaas-install-nova-compute.sh nova服务是两个节点都要安装 [root@xiandian ~]# nova flavor-create exam 1234 1024 20 2 +------+------+-----------+------+-----------+------+-------+-------------+-----------+ | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | +------+------+-----------+------+-----------+------+-------+-------------+-----------+ | 1234 | exam | 1024 | 20 | 0 | | 2 | 1.0 | True | +------+------+-----------+------+-----------+------+-------+-------------+-----------+ [root@xiandian ~]# nova flavor-show 1234 +----------------------------+-------+ | Property | Value | +----------------------------+-------+ | OS-FLV-DISABLED:disabled | False | | OS-FLV-EXT-DATA:ephemeral | 0 | | disk | 20 | | extra_specs | {} | | id | 1234 | | name | exam | | os-flavor-access:is_public | True | | ram | 1024 | | rxtx_factor | 1.0 | | swap | | | vcpus | 2 | +----------------------------+-------+
网络创建(2分) 使用脚本安装neutron服务,并配置为GRE网络:
(1)创建云主机外部网络为ext-net,子网为ext-subnet,虚拟机浮动IP网段为192.168.200.0/24,网关为192.168.200.1;
(2)创建云主机隧道网络int-net1,子网为int-subnet1,虚拟机子网IP网段为10.0.0.0/24,网关为10.0.0.1;
(3)创建云主机隧道网络int-net2,子网为int-subnet2,虚拟机子网IP网段为10.0.1.0/24,网关为10.0.1.1;
(4)添加名为ext-router的路由器,配置路由接口地址,完成隧道网络int-net1和外部网络ext-net的连通。
使用neutron相关命令查询子网的列表信息,并查看int-subnet1的详细信息。依次将操作命令和查询结果以文本形式提交到答题框。
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 [root@controller ~]# iaas-install-neutron-controller.sh/iaas-install-neutron-compute.sh neutron服务也是双节点 [root@controller ~]# openstack network create --share --external \ --provider-physical-network provider \ --provider-network-type vlan \ --provider-segment 1120 extnet //vlanid 根据自己的情况来设置 [root@controller ~]# openstack subnet create --network extnet \ --allocation-pool start=192.168.200.2,end=192.168.200.254 \ --dns-nameserver 1.2.4.8 --gateway 192.168.200.1 \ --subnet-range 192.168.200.0/24 extsubnet ---------------------------------------------------------------------------------------------- [root@controller ~]# openstack network create --share \ intnet1 [root@controller ~]# openstack subnet create --network intnet1 \ --allocation-pool start=10.10.0.2,end=10.10.0.254 \ --dns-nameserver 1.2.4.8 --gateway 10.10.1.1 \ --subnet-range 10.10.0.0/24 intsubnet1 ---------------------------------------------------------------------------------------- [root@controller ~]# openstack network create --share \ intnet2 [root@controller ~]# openstack subnet create --network intnet2 \ --allocation-pool start=10.10.1.2,end=10.10.1.254 \ --dns-nameserver 1.2.4.8 --gateway 10.10.1.1 \ --subnet-range 10.10.1.0/24 intsubnet2 路由配置----------------------------------------------------------------- [root@controller ~]# openstack router create ext-router [root@controller ~]# openstack router set \ --enable-snat --external-gateway extnet \ --fixed-ip subnet=extsubnet ext-router [root@controller ~]# openstack router add subnet ext-router intsubnet1 查看------------------------------------------------------------------------------ [root@controller ~]# neutron subnet-list [root@controller ~]# neutron subnet-show 6386b9ad-c446-45ae-a947-8a44b580feaf
dashboard配置(1分) 使用脚本安装dashboard服务,使用curl命令查询http://192.168.100.10/dashboard。依次将操作命令和查询结果以文本形式提交到答题框。
1 curl http://192.168.10.10/dashboard/auth/login/
nfs配置文件说明:
● /mnt/test:为共享目录(若没有这个目录,请新建一个)。
● 10.24.200.0/24:可以为一个网段,一个IP,也可以是域名。域名支持通配符,例如,*.qq.com。
● rw:read-write,可读写。
● ro:read-only,只读。
● sync:文件同时写入硬盘和内存。
● async:文件暂存于内存,而不是直接写入内存。
● wdelay:延迟写操作。
● no_root_squash:NFS客户端连接服务端时,如果使用的是root,那么对服务端共享的目录来说,也拥有root权限。显然开启这项是不安全的。
● root_squash:NFS客户端连接服务端时,如果使用的是root,那么对服务端共享的目录来说,拥有匿名用户权限,通常它将使用nobody或nfsnobody身份。
● all_squash:不论NFS客户端连接服务端时使用什么用户,对服务端共享的目录来说,都拥有匿名用户权限。
● anonuid:匿名用户的UID(User Identification,用户身份证明)值,可以在此处自行设定。
OpenStack云平台运维 镜像管理 使用自己搭建的openstack云平台,使用http:///cirros-0.3.4-x86_64-disk.img镜像,使用命令创建一个名为cirros的镜像。
1 2 source /etc/keystone/admin-openrc.sh glance image-create --name "cirros" --disk-format "qcow2" --container-format bare --progress < /root/cirros-0.3.4-x86_64-disk.img
网络管理 使用自己搭建的openstack云平台,创建云主机网络extnet,子网extsubnet,虚拟机网段为192.168.100.0/24, 网关为192.168.100.1,段ID默认写100。
1 2 3 4 5 6 7 8 9 10 11 [root@controller ~]# iaas-install-neutron-controller.sh/iaas-install-neutron-compute.sh neutron服务也是双节点 [root@controller ~]# openstack network create --share --external \ --provider-physical-network provider \ --provider-network-type vlan \ --provider-segment 100 extnet //vlanid 根据自己的情况来设置 [root@controller ~]# openstack subnet create --network extnet \ --allocation-pool start=192.168.100.2,end=192.168.100.254 \ --gateway 192.168.100.1 \ --subnet-range 192.168.100.0/24 extsubnet ------------------------------------------------------------------------------
heat模板管理 使用自己搭建的openstack云平台,在/root目录下编写模板server.yaml,创建名为“m1.flavor”、 ID 为 1234、内存为1024MB、硬盘为20GB、vcpu数量为 1的云主机类型。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 heat resource-type-list #查看资源类型 openstack orchestration template version list #查看可用于编排的模板版本 vi server.yaml heat_template_version: 2015-04-30 # 使用的heat模板版本 description: Create Flavor # 描述信息 resources: # 定义资源 flavor: # 在模板的资源部分中必须是唯一的资源ID type: OS::Nova::Flavor # 资源类型,这里表示一个 Flavor 类型 properties: # 资源特定属性的列表。 name: "m1.flavor" # Flavor类型的名称属性 flavorid: "1234" # id属性,如果没有指定则会自动生成UUID disk: 20 # 磁盘大小默认是GB ram: 1024 # 内存大小必须是MB vcpus: 1 outputs: # 定义输出信息 flavor_info: # 输出信息的名称 description: Get the information of virtual machine type # 输出描述 value: { get_attr: [ flavor, show ] } # get_attr 从相应资源定义创建的实例在运行时解析其属性值进行输出 heat stack-create m1.flavor -f server.yaml openstack stack list openstack stack show m1.flavor
云主机管理 使用自己搭建的openstack云平台,基于“cirros”镜像、flavor使用“m1.flavor”、extnet的网络,创建一台虚拟机VM1,并启动VM1。
1 2 openstack server create --flavor m1.flavor --image cirros --network extnet VM1 openstack server show VM1
云平台安全策略提升 1.使用提供的云安全框架组件,将提供的OpenStack云平台的安全策略从http优化至https。
1 2 3 4 5 yum install -y mod_ssl mod_wsgi vi /etc/openstack-dashboard/local_settings 49 CSRF_COOKIE_SECURE = True --取消注释 50 SESSION_COOKIE_SECURE = True --取消注释 systemctl restart httpd
swift分片存储 使用自己搭建的openstack云平台,自行安装Swift服务,新建名为chinaskill的容器,将cirros-0.3.4-x86_64-disk.img镜像上传到chinaskill容器中,并设置分段存放,每一段大小为10M
1 2 3 4 5 swift post chinaskill # 创建容器 post 后面跟上容器名 swift list # 查看容器列表 swift list chinaskill swift upload chinaskill -S 10485760 cirros-0.3.4-x86_64-disk.img swift stat chinaskill cirros-0.3.4-x86_64-disk.img