OpenStack 安装和使用(四)
查看项目(租户)配额:
# nova-manage project quota hanborq
metadata_items: 128
volumes: 10
gigabytes: 1000
ram: 51200
security_group_rules: 20
instances: 10
security_groups: 10
injected_file_content_bytes: 10240
floating_ips: 10
injected_files: 5
cores: 20
metadata_items: 128
volumes: 10
gigabytes: 1000
ram: 51200
security_group_rules: 20
instances: 10
security_groups: 10
injected_file_content_bytes: 10240
floating_ips: 10
injected_files: 5
cores: 20
注意点:
1. nova 不提供 shutdown 或 stop 命令,可以使用 nova suspend 命令和 nova reboot 命令组合来实现相同的效果。
2. nova suspend 命令会让VM挂起,而且host的qemu-kvm进程会退出,相当于电脑的休眠状态。
3. nova suspend把VM的内存内容写入硬盘,再挂起,host的qemu-kvm进程会退出;而nova pause 是VM停止执行任务,但不会把VM内存内容写入硬盘,host的qemu-kvm进程也不退出。
4. VM配置文件位置:/etc/libvirt/qemu/instance-XXXXXX.xml以及 /var/lib/nova/instances/instance-XXXXXX/libvirt.xml。
5. VM在flavor里面配置的硬盘的默认位置:/var/lib/nova/instances/,所以最好把/var/lib/nova/instances/挂载到比较大的存储上,以免产生空间不够的问题,后来增加的VM数据盘当然是从VG里面分配出来的。
6. 如果要实现live-migration,必须使用NFS或其他共享存储方式来mount /var/lib/nova/instances/目录,这样所有compute节点用的都是相同的存储,migrate时VM硬盘内容就不会变。
7. nova实际调用的是系统qemu-kvm命令来实现虚拟机运行的。
8. 可以使用# nova-manage project quota 来设置每个项目(租户)的配额。
解决如下问题:
1. 现象:
# vi /var/log/nova/network.log
2012-07-08 03:27:02 TRACE nova.rpc.amqp raise exception.NetworkNotFound(network_id=network_id)
2012-07-08 03:27:02 TRACE nova.rpc.amqp NetworkNotFound: Network 3 could not be found.
2012-07-08 03:27:02 TRACE nova.rpc.amqp NetworkNotFound: Network 3 could not be found.
解决,象重新安装一样,先把数据库清理掉,再建立:
mysql> drop database nova;
mysql> create database nova;
mysql> create database nova;
#nova-manage db sync
后面的步骤都需要。
2. 现象:
# vi /var/log/nova/compute.log
nova.rpc.amqp libvirtError: Unable to read from monitor: Connection reset by peer
解决方法:
这个应该是配置错了下面四个参数:
novncproxy_base_url = http://10.24.1.47:6080/vnc_auto.html 必须是cc的地址
vnc_enabled = true
vncserver_listen = 10.24.1.49 必须是该compute节点的地址
vncserver_proxyclient_address = 10.24.1.49 必须是该compute节点的地址
vnc_enabled = true
vncserver_listen = 10.24.1.49 必须是该compute节点的地址
vncserver_proxyclient_address = 10.24.1.49 必须是该compute节点的地址
3. 现象:
nova delete时出现:
# vi /var/log/nova/compute.log
nova.rpc.amqp TypeError: expected string or buffer
增加红字代码:
# vi /usr/lib/python2.7/site-packages/nova/compute/manager.py
def _get_instance_volume_block_device_info(self, context, instance_id):
bdms = self._get_instance_volume_bdms(context, instance_id)
block_device_mapping = []
for bdm in bdms:
try:
cinfo = utils.loads(bdm[‘connection_info’])
block_device_mapping.append({‘connection_info’: cinfo,
‘mount_device’:
bdm[‘device_name’]})
except TypeError:
# if the block_device_mapping has no value in connection_info
# (returned as None), don’t include in the mapping
bdms = self._get_instance_volume_bdms(context, instance_id)
block_device_mapping = []
for bdm in bdms:
try:
cinfo = utils.loads(bdm[‘connection_info’])
block_device_mapping.append({‘connection_info’: cinfo,
‘mount_device’:
bdm[‘device_name’]})
except TypeError:
# if the block_device_mapping has no value in connection_info
# (returned as None), don’t include in the mapping
pass
# NOTE(vish): The mapping is passed in so the driver can disconnect
# from remote volumes if necessary
return {‘block_device_mapping’: block_device_mapping}
# NOTE(vish): The mapping is passed in so the driver can disconnect
# from remote volumes if necessary
return {‘block_device_mapping’: block_device_mapping}