go4321 发表于 2018-5-30 11:51:58

OpenStack入门修炼之如何创建生产使用的openstack镜像(16)

  在linux-node1节点上:、

# yum install -y openstack-nova-compute
# yum install -y libvirt qemu-kvm
# systemctl start libvirtd
# systemctl enable libvirtd
# vim /etc/nova/nova.conf
增加novncproxy的地址:
novncproxy_base_url=http://192.168.56.11:6080/vnc_auto.html
# systemctl start openstack-nova-compute
# systemctl enable openstack-nova-compute
# source admin-openstack
# nova service-list

  当需要删除该节点时,只能从命令行进行删除:nova service-delete ID。在horizon界面上是只能关闭服务,无法进行删除。
  创建openstack镜像的过程:
  (1)创建一个虚拟机硬盘,格式qcow2,大小为10G

# qemu-img create -f qcow2 /tmp/centos.qcow2 10G
Formatting '/tmp/centos.qcow2', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16

  (2)创建虚拟机

# virt-install --virt-type kvm --name centos --ram 1024 \
--disk /tmp/centos.qcow2,format=qcow2 \
--network network=default \
--graphics vnc,listen=0.0.0.0 --noautoconsole \
--os-type=linux --os-variant=centos7.0 \
--location=/tmp/CentOS-7-x86_64-Minimal-1511.iso
# virsh list --all
Id    名称                         状态
----------------------------------------------------
-   centos                         关闭
# virsh start centos

  (3)TightVNC链接192.168.56.11进入系统安装
只分根分区,私有云不分swap分区

  (4)启动虚拟机

# virsh start centos
  (5)在虚拟机内安装默认的软件,或基础优化

yum install net-tools tree screen wget git vim
  (6)openstack上传镜像

# openstack image create "Centos-7-x86_64" --file=/tmp/centos.qcow2 --disk-format qcow2 --container-format bare --public
+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | 4ac6fb14f7e5bb3c9889df4bda71474a                     |
| container_format | bare                                                 |
| created_at       | 2017-12-07T08:06:55Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/5aa6e9a1-4aea-467c-a684-51080c326887/file |
| id               | 5aa6e9a1-4aea-467c-a684-51080c326887               |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | Centos-7-x86_64                                    |
| owner            | 21a45d59913d4c05b46ad3ec92e61656                     |
| protected      | False                                                |
| schema         | /v2/schemas/image                                    |
| size             | 1145896960                                           |
| status         | active                                             |
| tags             |                                                      |
| updated_at       | 2017-12-07T08:08:42Z                                 |
| virtual_size   | None                                                 |
| visibility       | public                                             |
+------------------+------------------------------------------------------+
# openstack image list
+--------------------------------------+-----------------+--------+
| ID                                    | Name            | Status |
+--------------------------------------+-----------------+--------+
| 5aa6e9a1-4aea-467c-a684-51080c326887 | Centos-7-x86_64 | active |
| 51e1e125-dbe3-49c6-a3d5-55c89f195f55 | cirros         | active |
+--------------------------------------+-----------------+--------+

  (7)通过上传的镜像创建centos7云主机
使用admin账户创建云主机类型,后使用demo用户进行创建云主机
页: [1]
查看完整版本: OpenStack入门修炼之如何创建生产使用的openstack镜像(16)