openstack 常用操作与问题


常用命令

# 查看可用实例类型
openstack flavor list

# 查看可用启动镜像
openstack image list

# 查看可用网络
openstack network list

# 查看可用安全组
openstack security group list

# 启动一个实例
openstack server create --flavor m1.medium --image win7_x64 --nic net-id=6e85dfe1-f976-4407-87ae-a217a46c9dff --security-group default test-instance

# 查看创建的实例
openstack server list

# 查看浏览器vnc窗口访问连接
openstack console url show test-instance

# 查看浮动IP池
openstack ip floating pool list

# 从浮动IP池中获取一个浮动IP
openstack ip floating create nova

# 查看已经获取的浮动IP
openstack ip floating list

# 绑定浮动IP给实例
openstack ip floating add 192.168.10.129 test-instance


# 使用nova命令启动实例
nova boot --flavor m1.medium --image win7_x64 --nic net-id=6e85dfe1-f976-4407-87ae-a217a46c9dff --security-group default test-instance
openstack  network show 37828d8f-6665-44f7-993e-6d1395024170
openstack  network subport list
openstack compute agent list
openstack compute agent list
openstack compute service delete
openstack compute service delete 14
openstack compute service delete 15
openstack compute service list
openstack computer
openstack computer agent list
openstack computer list
openstack computer service list
openstack endpoint l
openstack flavor list
openstack host
openstack host list
openstack hypervisor list
openstack hypervisor show
openstack hypervisor show 37828d8f-6665-44f7-993e-6d1395024170
openstack network
openstack network
openstack network agent
openstack network agent delete
openstack network agent delete 3028a9b1-6dea-4e80-b192-02b10122b580
openstack network agent delete 6c618ed5-dfb6-4dbe-9dde-ed244bf37dcc
openstack network agent list
openstack network agent set
openstack network agent set 3028a9b1-6dea-4e80-b192-02b10122b580 --disable
openstack network agent set 6c618ed5-dfb6-4dbe-9dde-ed244bf37dcc
openstack network agent set 6c618ed5-dfb6-4dbe-9dde-ed244bf37dcc --disable
openstack network agent set 6c618ed5-dfb6-4dbe-9dde-ed244bf37dcc off
openstack network agent show
openstack network agent show 6c618ed5-dfb6-4dbe-9dde-ed244bf37dcc
openstack network list
openstack network meter list
openstack network segment list
openstack network service provider list
openstack network show
openstack neutron port-show 37828d8f-6665-44f7-993e-6d1395024170
openstack node
openstack node list

nove list  #查看主机UUID

openstack port list
openstack port show 37828d8f-6665-44f7-993e-6d1395024170
openstack port-show 37828d8f-6665-44f7-993e-6d1395024170   
openstack server
openstack server list
openstack server resize --confirm 45c89297-2b0b-421f-8dde-9e500b9f6c55
openstack server resize --flavor 1e0777fc-b294-4577-b4a4-219dc8b89265 ttte
openstack server show tttest
openstack serverlist
openstack volume list



md5-82c43777599d94e31a900f094e6f99c8



vi /etc/libvirt/qemu.conf
security_driver = "none"
service libvirtd restart



md5-01df2e4ba9647b60c9c8e292c5be1696



如果实例保持在中间状态,如 deleting,您可以使用 nova reset-state 命令来手动重置实例的状态为 error 状态。然后您就可以将实例删除。例如:
$ nova reset-state c6bbbf26-b40a-47e7-8d5c-eb17bf65c485
$ nova delete c6bbbf26-b40a-47e7-8d5c-eb17bf65c485
您也可以使用 --active 参数来强制实例回到 active 状态而不是 error 状态。例如:
$ nova reset-state --active c6bbbf26-b40a-47e7-8d5c-eb17bf65c485



md5-154c0c020723da2cc119f0a299797551



vi /etc/nova/nova.conf
resume_guests_state_on_host_boot=true



md5-56ae802c0d9d66f333b7f50208898836



#node02:
scp -r /data/nova/instances/f3b278bc-383c-47aa-b5dd-b8ee014dad45 nova@node01:/data/nova/instances/

#controller:
mysql -p
use nova
select host,node from instances where uuid='89d0f250-5920-417c-837b-2b6333e8dfa7';
update instances set host='node01', node='node01' where uuid='89d0f250-5920-417c-837b-2b6333e8dfa7';

#node01:
systemctl restart nova-compute



md5-e3ab6d813aa8f153711d25acbe4a9923



#增加一个IP(非dhcp段)
1.查找子网段ID
neutron subnet-list
2.查找网络段ID
neutron net-list
3.增加一个未使用的IP
neutron port-create --fixed-ip subnet_id=1817a471-e8a3-4029-8468-1a1a6cb1bf86【子网段ID】,ip_address=192.168.200.232 c5bc18ea-cfda-4e76-adb8-0d38d1b7663d【网络段ID】

#把增加的IP分配给虚拟机(或者给新虚拟机分配该IP):在面板操作为连接IP或新建虚拟机并选择此IP。

#允许新IP通过该虚拟机(openstack每个端口默认只允许一个Ip的数据报文通过)。
1.查看该虚拟机原来的IP的网卡所在的端口ID
neutron port-list | grep '192.168.200.44'
2.修改该端口,允许通过IP(面板操作为:添加可用地址对)
neutron port-update c1a258f9-b75c-45b3-b772-6396f763b56b --allowed-address-pairs type=dict list=true ip_address=192.168.200.231
2.1.也可修改通过一个网段
neutron port-update 1effb238-d49b-4679-91b9-d843a8ff3e30 --allowed-address-pairs type=dict list=true ip_address=172.16.8.0/24



md5-b13c3721ef84276d840ab2e387d753ff



vi /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE=eth0
NAME=eth0
TYPE=Ethernet
ONBOOT=yes
IPV6INIT=no
BOOTPROTO=static
USERCTL=no
NM_CONTROLLED=no
IPADDR=10.200.124.95
NETMASK=255.255.255.0
GATEWAY=10.200.124.254
DNS1=8.8.8.8