首先创建三台虚拟机, 一台作为openstack管理主机, 另外两天坐nova计算节点
openstack管理主机
2cpu, 7.5G内存, 50G硬盘
静态IP: 192.168.1.10
nova01,nova02计算节点
2cpu, 3.5G内存, 100G硬盘
[root@room9pc01 ~]# vim cv.sh //编写节本, 创建三台虚拟机
#!/bin/bash
while(($#));do
cd /var/lib/libvirt/images/
qemu-img create -f qcow2 -b .node_base.qcow2 "$1".img
sed "s,node_base,"$1"", .node_base.xml > /etc/libvirt/qemu/"$1".xml
virsh define /etc/libvirt/qemu/"$1".xml
virsh start $1
shift
done
:wq
[root@room9pc01 ~]# ./cv.sh os nova1 nova2
[root@room9pc01 ~]# virsh edit os
...
<memory unit='KiB'>8100000</memory> //修改内存大小
<currentMemory unit='KiB'>8100000</currentMemory>
<vcpu placement='static'>2</vcpu> //修改cpu个数
...
:wq
[root@room9pc01 ~]# virsh edit nova1
...
<memory unit='KiB'>4100000</memory> //修改内存大小
<currentMemory unit='KiB'>4100000</currentMemory>
<vcpu placement='static'>2</vcpu> //修改cpu个数
...
:wq
[root@room9pc01 ~]# virsh edit nova2
...
<memory unit='KiB'>4100000</memory> //修改内存大小
<currentMemory unit='KiB'>4100000</currentMemory>
<vcpu placement='static'>2</vcpu> //修改cpu个数
...
:wq
[root@room9pc01 ~]# virsh domblklist os
目标 源
------------------------------------------------
vda /var/lib/libvirt/images/os.img
[root@room9pc01 ~]# virsh blockresize --path /var/lib/libvirt/images/os.img --size 50G os
重新定义 '/var/lib/libvirt/images/os.img' 块设备大小
[root@room9pc01 ~]# virsh domblklist nova1
目标 源
------------------------------------------------
vda /var/lib/libvirt/images/nova1.img
[root@room9pc01 ~]# virsh blockresize --path /var/lib/libvirt/images/nova1.img --size 100G nova1
重新定义 '/var/lib/libvirt/images/nova1.img' 块设备大小
[root@room9pc01 ~]# virsh domblklist nova2
目标 源
------------------------------------------------
vda /var/lib/libvirt/images/nova2.img
[root@room9pc01 ~]# virsh blockresize --path /var/lib/libvirt/images/nova2.img --size 100G nova2
重新定义 '/var/lib/libvirt/images/nova2.img' 块设备大小
[root@room9pc01 ~]# virsh console os
[root@localhost ~]# hostnamectl set-hostname os
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
# Generated by dracut initrd
DEVICE="eth0"
ONBOOT="yes"
NM_CONTROLLED="no"
TYPE="Ethernet"
BOOTPROTO="static"
PERSISTENT_DHCLIENT="yes"
IPADDR=192.168.1.10
NEMASK=255.255.255.0
GATEWAY