2021云平台复习 搭建
系统准备
安装好两个节点,要求:
(1)controller:内存2G,CPU 2个,自动分区,网卡两块:NAT,仅主机,硬盘建议60G,创建新的虚拟磁盘,镜像centos7.2.虚拟机的名字为学号后两位+姓名全拼+ controller。
(2)compute:内存2G,CPU 2个,手动分区(交换分区4G,根分区25G,/boot 500M),网卡两块:NAT,仅主机,硬盘建议60G,创建新的虚拟磁盘,镜像centos7.2. 虚拟机的名字为学号后两位+姓名全拼+ compute。
云平台搭建
配置主机名
磁盘分区
[root@compute ~]# fdisk -l
Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0005adf9 Device Boot Start End Blocks Id System /dev/sda1 2048 104876031 52436992 8e Linux LVM Disk /dev/mapper/centos-root: 32.2 GB, 32212254720 bytes, 62914560 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/centos-swap: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/centos-home: 10.7 GB, 10737418240 bytes, 20971520 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@compute ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (2-4, default 2): 2 First sector (104876032-125829119, default 104876032): Using default value 104876032 Last sector, +sectors or +size{K,M,G} (104876032-125829119, default 125829119): +5G Partition 2 of type Linux and of size 5 GiB is set Command (m for help): t Partition number (1,2, default 2): Hex code (type L to list all codes): L 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT 1e Hidden W95 FAT1 80 Old Minix Hex code (type L to list all codes): 83 Changed type of partition 'Linux' to 'Linux' Command (m for help): P Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0005adf9 Device Boot Start End Blocks Id System /dev/sda1 2048 104876031 52436992 8e Linux LVM /dev/sda2 104876032 115361791 5242880 83 Linux Command (m for help): p Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0005adf9 Device Boot Start End Blocks Id System /dev/sda1 2048 104876031 52436992 8e Linux LVM /dev/sda2 104876032 115361791 5242880 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. 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) Syncing disks.
安全设置
网络设置
ls /mnt/centos
ls /mnt/iaas
配置yum源
编辑环境变量
基础服务构建
基础模块构建
搭建后运维
在OpenStack单节点启动之前,需要先关闭双节点。
OpenStack单节点:
环境变量
source /etc/keystone/admin-openrc.sh
认证
创建用户
[root@controller ~]# openstack user create --domain default --password 000000 mayuan
+-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | a01f4541a7364233b23adc8975be9ea6 | | enabled | True | | id | 75cfff6b324645ea9512b461e5a34524 | | name | mayuan |
[root@controller ~]# openstack user list
如何创建项目
[root@controller ~]# openstack project create --domain default bigbang
+-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | | | domain_id | a01f4541a7364233b23adc8975be9ea6 | | enabled | True | | id | 1fca58f634224097ac27edc5f13b18ac | | is_domain | False | | name | bigbang | | parent_id | a01f4541a7364233b23adc8975be9ea6 | +-------------+----------------------------------+
[root@controller ~]# openstack project list
+----------------------------------+----------+ | ID | Name | +----------------------------------+----------+ | 092544ea278d4ba29e28b405860d9cce | acme2 | | 1fca58f634224097ac27edc5f13b18ac | bigbang | | 2039fe0fcd2242269f26b94f2c221145 | acme2 | | 3ca3f1b85edd41ceb75497c6db07d5fa | acme3 | | 5f942ba70fed4d3b912138d89b44f795 | admin2 | | 6e33c852b46f4594828a77b273d0ad0c | acme | | 981bcb2641444b7eabc43f3605032b8e | acme | | c88f5a1b7619420dadb4309743e53f1a | service | | de7887f3ceb146118d15df923668a1a1 | acme1119 | | e14b3dabf5594684913f3868669f35af | demo | | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | admin | +----------------------------------+----------+
如何创建角色
[root@controller ~]# openstack role create manager
+-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | None | | id | 4810ee81b13c4d0f8a5c1c017d6ddc7e | | name | manager | +-----------+----------------------------------+
[root@controller ~]# openstack role list
+----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 0dc8f4d49a3341d79c5e6b5474f4b649 | computer-user1119 | | 398b127b3ac040c58b6629c58b776196 | heat_stack_user | | 4217695f42ba45e59434a3285cab5c07 | heat_stack_owner | | 4810ee81b13c4d0f8a5c1c017d6ddc7e | manager | | 54dd141975184734b6fc109ac1d2a07b | compute-user | | 5a9eac70b43a42f9ad55dfe44c455e9a | admin | | 6280f11c992f4b94a9d04e349150a14f | user | | 7c31824d545e491f9514b67cc85812ab | ResellerAdmin | | d50f03f0cf7b4fbc982feaa931b2b7eb | admin2 | +----------------------------------+-------------------+
将用户绑定到对应的项目和角色
openstack role add --project bigbang --user mayuan manager
显示用户详细信息
显示用户mayuan的详细信息
[root@controller ~]# openstack user show 75cfff6b324645ea9512b461e5a34524
+-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | a01f4541a7364233b23adc8975be9ea6 | | enabled | True | | id | 75cfff6b324645ea9512b461e5a34524 | | name | mayuan | +-----------+----------------------------------+
显示角色详细信息
显示角色manager的详细信息
[root@controller ~]# openstack role list
+----------------------------------+-------------------+ | ID | Name | +----------------------------------+-------------------+ | 0dc8f4d49a3341d79c5e6b5474f4b649 | computer-user1119 | | 398b127b3ac040c58b6629c58b776196 | heat_stack_user | | 4217695f42ba45e59434a3285cab5c07 | heat_stack_owner | | 4810ee81b13c4d0f8a5c1c017d6ddc7e | manager | | 53adeebffbe94f4b95587cd5d938fbd6 | manager2 | | 54dd141975184734b6fc109ac1d2a07b | compute-user | | 5a9eac70b43a42f9ad55dfe44c455e9a | admin | | 6280f11c992f4b94a9d04e349150a14f | user | | 7c31824d545e491f9514b67cc85812ab | ResellerAdmin | | d50f03f0cf7b4fbc982feaa931b2b7eb | admin2 | +----------------------------------+-------------------+
[root@controller ~]# openstack role show manager2
+-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | None | | id | 53adeebffbe94f4b95587cd5d938fbd6 | | name | manager2 | +-----------+----------------------------------+
镜像
创建镜像
创建一个名称为“cirros”镜像,镜像文件使用提供的“cirros-0.3.4-x86_64-disk.img
创建一个名称为“cirros2”镜像,镜像文件使用提供的“cirros-0.3.4-x86_64-disk.img
[root@controller ~]# glance image-create --name "cirros" --disk-format qcow2 --container-format bare --progress < cirros-0.3.3-x86_64-disk.img
[=============================>] 100% +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2021-12-14T04:50:00Z | | disk_format | qcow2 | | id | 12433a25-0b12-4e64-b493-4be576b9490b | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | protected | False | | size | 13287936 | | status | active | | tags | [] | | updated_at | 2021-12-14T04:50:04Z | | virtual_size | None | | visibility | private | +------------------+--------------------------------------+
查看镜像列表
查看镜像列表
[root@controller ~]# glance image-list
+--------------------------------------+--------------+ | ID | Name | +--------------------------------------+--------------+ | 7d4e66dd-a134-46f0-9521-a84e4dbc6281 | cirros | | 12433a25-0b12-4e64-b493-4be576b9490b | cirros | | 4fe63493-0ee4-4202-b2ff-a509bdb7f6de | cirros-0.4.0 | | 49c1dd1c-606d-4f24-ad2b-d0f9f26cab3f | cirros2 | | f6470290-41cf-4407-86a9-04fd05eae841 | maxin01 | | fad47b20-6de5-4c11-914c-742a733b2694 | mycirros | +--------------------------------------+--------------+
查看镜像详情
查看镜像cirros的详情
[root@controller ~]# glance image-show 12433a25-0b12-4e64-b493-4be576b9490b
+------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2021-12-14T04:50:00Z | | disk_format | qcow2 | | id | 12433a25-0b12-4e64-b493-4be576b9490b | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | protected | False | | size | 13287936 | | status | active | | tags | [] | | updated_at | 2021-12-14T04:50:04Z | | virtual_size | None | | visibility | private | +------------------+--------------------------------------+
更改镜像
更改镜像 cirros2 所需内存最低为1G
[root@controller ~]# glance image-update --min-disk=1 12433a25-0b12-4e64-b493-4be576b9490b
+------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2021-12-14T04:50:00Z | | disk_format | qcow2 | | id | 12433a25-0b12-4e64-b493-4be576b9490b | | min_disk | 1 | | min_ram | 0 | | name | cirros | | owner | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | protected | False | | size | 13287936 | | status | active | | tags | [] | | updated_at | 2021-12-14T04:55:23Z | | virtual_size | None | | visibility | private | +------------------+--------------------------------------+
计算
创建安全组
创建一个名为test的安全组,描述为'test the nova command about the rules'
[root@controller ~]# nova secgroup-create test 'test the nova command about the rules'
+--------------------------------------+------+---------------------------------------+ | Id | Name | Description | +--------------------------------------+------+---------------------------------------+ | cf7c7869-4136-4968-9531-279523ca276f | test | test the nova command about the rules | +--------------------------------------+------+---------------------------------------+
创建云主机类型
使用命令创建一个名为hello,ID为1,内存为256 MB,磁盘为1 GB,vcpu数量为1的云主机类型。
[root@controller ~]# openstack flavor create --ram 256 --disk 1 --vcpus 1 --id 111 hello
+----------------------------+-------+ | Field | Value | +----------------------------+-------+ | OS-FLV-DISABLED:disabled | False | | OS-FLV-EXT-DATA:ephemeral | 0 | | disk | 1 | | id | 111 | | name | hello | | os-flavor-access:is_public | True | | ram | 256 | | rxtx_factor | 1.0 | | swap | | | vcpus | 1 | +----------------------------+-------+
查看云主机类型
使用命令查看现有的云主机类型
[root@controller ~]# openstack flavor list
+----------+----------+-------+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----------+----------+-------+------+-----------+-------+-----------+ | 1 | m1.tiny | 512 | 1 | 0 | 1 | True | | 111 | hello | 256 | 1 | 0 | 1 | True | | 12 | exam | 1024 | 10 | 0 | 1 | True | | 2 | m1.small | 2048 | 20 | 0 | 1 | True | | 2d0b18b6 | m1.veryv | 256 | 1 | 0 | 1 | True | | -2b28 | erytiny | | | | | | | -4adb-b6 | | | | | | | | e1-6115a | | | | | | | | 7ef0f25 | | | | | | | | 3 | m1.mediu | 4096 | 40 | 0 | 2 | True | | | m | | | | | | | 4 | m1.large | 8192 | 80 | 0 | 4 | True | | 5 | m1.xlarg | 16384 | 160 | 0 | 8 | True | | | e | | | | | | | 7d666cc6 | m2.veryt | 128 | 1 | 0 | 1 | True | | -a149 | iny | | | | | | | -4b3d-9f | | | | | | | | 26-4cbff | | | | | | | | 5b5b363 | | | | | | | | cf893ae4 | m1.veryt | 512 | 1 | 0 | 1 | True | | -b330-4c | iny | | | | | | | 7f-a864- | | | | | | | | 86c8a584 | | | | | | | | ed1a | | | | | | | +----------+----------+-------+------+-----------+-------+-----------+
创建云主机
利用刚刚创建的云主机类型 和之前创建的镜像cirros 建立一台云主机test01
Nova可对云平台中的实例进行管理,包括创建实例、启动实例、删除实例和实例迁移等操作。
创建密钥
创建一个密钥:
nova keypair-add oskey > oskey.priv chmod 600 oskey.priv
你查看所有可用的云主机类型
nova flavor-list
查看现在可用的镜像类型
nova image-list
新建立云主机
最后,你利用刚才查到的云主机类型和镜像信息,在后台新建立一个云主机,
nova boot
功能:启动实例。格式:
nova boot --flavor [flavor-id] --key_name oskey --image [image-id] hostname
其中,flavor-id 就是上上步云主机类型表里的id号,建议选tiny的那个,oskey是你刚才创建的密钥,image-id就是上步镜像表里的id号,建议选cirros的那个,hostname换成你自己想起的云主机的名字。
[root@controller ~]# nova boot --flavor 111 --key_name oskey3 --image 12433a25-0b12-4e64-b493-4be576b9490b --nic net-id=7623e6a0-9346-4565-a01d-f8072472d6e6 test01
WARNING: Option "--key_name" is deprecated; use "--key-name"; this option will be removed in novaclient 3.3.0. +--------------------------------------+----------------------------------------------------+ | Property | Value | +--------------------------------------+----------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | | | OS-EXT-SRV-ATTR:host | - | | OS-EXT-SRV-ATTR:hostname | helloworld | | OS-EXT-SRV-ATTR:hypervisor_hostname | - | | OS-EXT-SRV-ATTR:instance_name | instance-00000002 | | OS-EXT-SRV-ATTR:kernel_id | | | OS-EXT-SRV-ATTR:launch_index | 0 | | OS-EXT-SRV-ATTR:ramdisk_id | | | OS-EXT-SRV-ATTR:reservation_id | r-pzthd0ge | | OS-EXT-SRV-ATTR:root_device_name | - | | OS-EXT-SRV-ATTR:user_data | - | | OS-EXT-STS:power_state | 0 | | OS-EXT-STS:task_state | scheduling | | OS-EXT-STS:vm_state | building | | OS-SRV-USG:launched_at | - | | OS-SRV-USG:terminated_at | - | | accessIPv4 | | | accessIPv6 | | | adminPass | isFF7YcbT9Cc | | config_drive | | | created | 2021-11-27T11:59:50Z | | description | - | | flavor | m1.verytiny (cf893ae4-b330-4c7f-a864-86c8a584ed1a) | | hostId | | | host_status | | | id | 27e64e5f-9e7b-44dc-8441-52d67cc46d82 | | image | cirros (7d4e66dd-a134-46f0-9521-a84e4dbc6281) | | key_name | oskey | | locked | False | | metadata | {} | | name | helloworld | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | security_groups | default | | status | BUILD | | tenant_id | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | updated | 2021-11-27T11:59:50Z | | user_id | 0befa70f767848e39df8224107b71858 | +--------------------------------------+----------------------------------------------------+
网络
查看租户信息
openstack project list
+----------------------------------+---------+ | ID | Name | +----------------------------------+---------+ | 5d4c854550c749b99d318ed040d0c6c5 | demo | | b9d68ac4b36a40dd996a298afd1ab47e | admin | | e1415d6ec88e4152a1c938234a2f80ec | service | +----------------------------------+---------+
创建网络
[root@controller ~]# neutron net-create --tenant-id 1fca58f634224097ac27edc5f13b18ac sharednet2 --shared --provider:network_type flat --provider:physical_network physnet1
Created a new network: +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | availability_zone_hints | | | availability_zones | | | created_at | 2021-12-13T19:20:50 | | description | | | id | 7623e6a0-9346-4565-a01d-f8072472d6e6 | | ipv4_address_scope | | | ipv6_address_scope | | | mtu | 1500 | | name | sharednet2 | | port_security_enabled | True | | provider:network_type | flat | | provider:physical_network | physnet1 | | provider:segmentation_id | | | router:external | False | | shared | True | | status | ACTIVE | | subnets | | | tags | | | tenant_id | 1fca58f634224097ac27edc5f13b18ac | | updated_at | 2021-12-13T19:20:50 | +---------------------------+--------------------------------------+
[root@controller ~]# neutron subnet-create sharednet2 192.168.10.0/24 --name extsubnet --enable_dhcp=True --gateway=192.168.10.1
Created a new subnet: +-------------------+----------------------------------------------------+ | Field | Value | +-------------------+----------------------------------------------------+ | allocation_pools | {"start": "192.168.10.2", "end": "192.168.10.254"} | | cidr | 192.168.10.0/24 | | created_at | 2021-12-13T19:24:11 | | description | | | dns_nameservers | | | enable_dhcp | True | | gateway_ip | 192.168.10.1 | | host_routes | | | id | 7a801d97-152e-4230-964e-466717b8c400 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | extsubnet | | network_id | 7623e6a0-9346-4565-a01d-f8072472d6e6 | | subnetpool_id | | | tenant_id | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | updated_at | 2021-12-13T19:24:11 | +-------------------+----------------------------------------------------+
创建云主机
[root@controller ~]# nova keypair-add oskey > oskey.priv
[root@controller ~]# chmod 600 oskey.priv
[root@controller ~]# nova flavor-list
+--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+ | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | +--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+ | 1 | m1.tiny | 512 | 1 | 0 | | 1 | 1.0 | True | | 12 | exam | 1024 | 10 | 0 | | 1 | 1.0 | True | | 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True | | 2d0b18b6-2b28-4adb-b6e1-6115a7ef0f25 | m1.veryverytiny | 256 | 1 | 0 | | 1 | 1.0 | True | | 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True | | 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True | | 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True | | 7d666cc6-a149-4b3d-9f26-4cbff5b5b363 | m2.verytiny | 128 | 1 | 0 | | 1 | 1.0 | True | | cf893ae4-b330-4c7f-a864-86c8a584ed1a | m1.verytiny | 512 | 1 | 0 | | 1 | 1.0 | True | +--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+
[root@controller ~]# nova image-list
+--------------------------------------+--------------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+--------------+--------+--------+ | 7d4e66dd-a134-46f0-9521-a84e4dbc6281 | cirros | ACTIVE | | | 4fe63493-0ee4-4202-b2ff-a509bdb7f6de | cirros-0.4.0 | ACTIVE | | | f6470290-41cf-4407-86a9-04fd05eae841 | maxin01 | ACTIVE | | | fad47b20-6de5-4c11-914c-742a733b2694 | mycirros | ACTIVE | | +--------------------------------------+--------------+--------+--------+
[root@controller ~]# nova boot
usage: nova boot [--flavor <flavor>] [--image <image>] [--image-with <key=value>] [--boot-volume <volume_id>] [--snapshot <snapshot_id>] [--min-count <number>] [--max-count <number>] [--meta <key=value>] [--file <dst-path=src-path>] [--key-name <key-name>] [--user-data <user-data>] [--availability-zone <availability-zone>] [--security-groups <security-groups>] [--block-device-mapping <dev-name=mapping>] [--block-device key1=value1[,key2=value2...]] [--swap <swap_size>] [--ephemeral size=<size>[,format=<format>]] [--hint <key=value>] [--nic <net-id=net-uuid,net-name=network-name,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,port-id=port-uuid>] [--config-drive <value>] [--poll] [--admin-pass <value>] [--access-ip-v4 <value>] [--access-ip-v6 <value>] [--description <description>] <name> error: too few arguments Try 'nova help boot' for more information.
[root@controller ~]# nova boot --flavor exam --key_name oskey --image 7d4e66dd-a134-46f0-9521-a84e4dbc6281 --nic net-id=7623e6a0-9346-4565-a01d-f8072472d6e6 myVM
WARNING: Option "--key_name" is deprecated; use "--key-name"; this option will be removed in novaclient 3.3.0. +--------------------------------------+-----------------------------------------------+ | Property | Value | +--------------------------------------+-----------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | | | OS-EXT-SRV-ATTR:host | - | | OS-EXT-SRV-ATTR:hostname | myvm | | OS-EXT-SRV-ATTR:hypervisor_hostname | - | | OS-EXT-SRV-ATTR:instance_name | instance-00000004 | | OS-EXT-SRV-ATTR:kernel_id | | | OS-EXT-SRV-ATTR:launch_index | 0 | | OS-EXT-SRV-ATTR:ramdisk_id | | | OS-EXT-SRV-ATTR:reservation_id | r-14wjemtj | | OS-EXT-SRV-ATTR:root_device_name | - | | OS-EXT-SRV-ATTR:user_data | - | | OS-EXT-STS:power_state | 0 | | OS-EXT-STS:task_state | scheduling | | OS-EXT-STS:vm_state | building | | OS-SRV-USG:launched_at | - | | OS-SRV-USG:terminated_at | - | | accessIPv4 | | | accessIPv6 | | | adminPass | BtK4UhWR2anP | | config_drive | | | created | 2021-12-13T19:45:07Z | | description | - | | flavor | exam (12) | | hostId | | | host_status | | | id | f40e4972-57f4-4c1c-b6eb-387cb86e5c1c | | image | cirros (7d4e66dd-a134-46f0-9521-a84e4dbc6281) | | key_name | oskey | | locked | False | | metadata | {} | | name | myVM | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | security_groups | default | | status | BUILD | | tenant_id | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | updated | 2021-12-13T19:45:07Z | | user_id | 0befa70f767848e39df8224107b71858 | +--------------------------------------+-----------------------------------------------+
云硬盘
云硬盘类型
创建一个类型叫super的云硬盘类型
[root@controller ~]# cinder type-create super
+--------------------------------------+-------+-------------+-----------+ | ID | Name | Description | Is_Public | +--------------------------------------+-------+-------------+-----------+ | 6253684c-de6b-4bd2-8cee-e81bea05a905 | type1 | - | True | +--------------------------------------+-------+-------------+-----------+
创建云硬盘
利用类型super 创建一个1G的云硬盘mydisk
[root@controller ~]# cinder create --display-name mydisk --volume_type super 1
+--------------------------------+--------------------------------------+ | Property | Value | +--------------------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | false | | consistencygroup_id | None | | created_at | 2021-12-13T20:00:38.000000 | | description | None | | encrypted | False | | id | 40c24547-5dcd-4324-957f-5a71cf69c561 | | metadata | {} | | migration_status | None | | multiattach | False | | name | type_test_demo | | 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 | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | replication_status | disabled | | size | 1 | | snapshot_id | None | | source_volid | None | | status | creating | | updated_at | None | | user_id | 0befa70f767848e39df8224107b71858 | | volume_type | type1 | +--------------------------------+--------------------------------------+
查看云硬盘
通过cinder-list命令查看云硬盘信息
查询云硬盘
查询云硬盘mydisk的具体信息
[root@controller ~]# cinder show mydisk
+--------------------------------+--------------------------------------+ | Property | Value | +--------------------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | false | | consistencygroup_id | None | | created_at | 2021-12-13T20:00:38.000000 | | description | None | | encrypted | False | | id | 40c24547-5dcd-4324-957f-5a71cf69c561 | | metadata | {} | | migration_status | None | | multiattach | False | | name | type_test_demo | | os-vol-host-attr:host | controller@lvm#LVM | | os-vol-mig-status-attr:migstat | None | | os-vol-mig-status-attr:name_id | None | | os-vol-tenant-attr:tenant_id | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | replication_status | disabled | | size | 1 | | snapshot_id | None | | source_volid | None | | status | available | | updated_at | 2021-12-13T20:00:40.000000 | | user_id | 0befa70f767848e39df8224107b71858 | | volume_type | type1 |
云硬盘挂载
将创建的这个云硬盘挂载到之前的云主机上
[root@controller ~]# cinder list
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+ | ID | Status | Name | Size | Volume Type | Bootable | Attached to | +--------------------------------------+-----------+----------------+------+-------------+----------+-------------+ | 40c24547-5dcd-4324-957f-5a71cf69c561 | available | type_test_demo | 1 | type1 | false | | +--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
[root@controller ~]# nova list +--------------------------------------+-------------+---------+------------+-------------+-------------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+-------------+---------+------------+-------------+-------------------------+ | 27e64e5f-9e7b-44dc-8441-52d67cc46d82 | helloworld | SHUTOFF | - | Shutdown | vlan115=172.30.15.3 | | 77311ff6-8173-4911-8d03-288b455791bc | helloworld2 | SHUTOFF | - | Shutdown | vlan115=172.30.15.4 | | f40e4972-57f4-4c1c-b6eb-387cb86e5c1c | myVM | ACTIVE | - | Running | sharednet2=192.168.10.3 | +--------------------------------------+-------------+---------+------------+-------------+-------------------------+</nowiki> [root@controller ~]# nova volume-attach f40e4972-57f4-4c1c-b6eb-387cb86e5c1c 40c24547-5dcd-4324-957f-5a71cf69c561
+----------+--------------------------------------+ | Property | Value | +----------+--------------------------------------+ | device | /dev/vdb | | id | 40c24547-5dcd-4324-957f-5a71cf69c561 | | serverId | f40e4972-57f4-4c1c-b6eb-387cb86e5c1c | | volumeId | 40c24547-5dcd-4324-957f-5a71cf69c561 | +----------+--------------------------------------+
[root@controller ~]# cinder list
+--------------------------------------+--------+----------------+------+-------------+----------+--------------------------------------+ | ID | Status | Name | Size | Volume Type | Bootable | Attached to | +--------------------------------------+--------+----------------+------+-------------+----------+--------------------------------------+ | 40c24547-5dcd-4324-957f-5a71cf69c561 | in-use | type_test_demo | 1 | type1 | false | f40e4972-57f4-4c1c-b6eb-387cb86e5c1c | +-------------------------
图形界面
是否浏览器 能登陆图形界面