openstack使用

1.若虚机带磁盘,先卸载磁盘

for i in `cinder list --all-tenants |awk '{print 2}' \|grep -v 'ID'\|grep -v '\^'`;

do

j=`cinder list --all |grep $i | awk '{print 16}' \|grep -v 'Attached'\|grep -v '\^'`

nova volume-detach $j $i

done

2.删除磁盘

for i in `cinder list --all-tenants |awk '{print 2}' \|grep -v 'ID'\|grep -v '\^'`;do cinder delete $i;done

3.删除虚机

for i in `nova list --all-tenants |awk '{print 2}' \|grep -v 'ID'\|grep -v '\^'`;do nova delete $i;done

4.删除port

for i in `neutron port-list |awk '{print 2}' \|grep -v 'id'\|grep -v '\^'` ;do neutron port-delete $i;done

5.删除镜像

for i in `glance image-list | awk '{print 2}' \|grep -v 'ID'\|grep -v '\^'`;do glance image-delete $i;done

6.删除subnet

for i in `neutron subnet-list | awk '{print 2}' \|grep -v 'id'\|grep -v '\^'`;do neutron subnet-delete $i;done

7.删除net

for i in `neutron net-list |awk '{print 2}' \|grep -v 'id'\|grep -v '\^'`;do neutron net-delete $i;done

8.删除flavor

for i in `nova flavor-list | awk '{print 2}' \|grep -v 'ID'\|grep -v '\^'`;do nova flavor-delete $i;done

9.创建租户

openstack user create --domain default --password "cloud@123" pcp

openstack role add --project service --user nova admin

openstack role add --project admin --user pcp admin

10.普通租户

openstack project create --domain default test1

openstack user create --domain default --password "cloud@123" pcp

openstack role add --project test1 --user pcp admin

11.创建network

neutron net-create ceshi-vlan3999 --provider:network_type vlan --provider:physical_network physnet1 --provider:segmentation_id 3999

neutron subnet-create ceshi-vlan3999 --name subnet2050 --gateway 10.200.10.254 10.200.10.0/24

12.创建镜像

glance image-create --name=centos7.3_app --file /root/CentOS7U3_PublicNginxShow_64bit_75G_20180124_APP.qcow2 --disk-format qcow2 --container-format bare

13.创建虚机

nova boot ceshi-lvm1 --flavor 1c2g75g--image 002c5dd4-d93f-484a-bea4-60d92fe47a33 --nic net-id=2e8fb24a-282d-4102-b1e7-c02cea3fc8c3,v4-fixed-ip=10.200.10.50 --user-data=/opt/userdata.txt --config-drive true --availability-zone nova:xzto03n010027244144.sncloud.com

13.1 指定节点创建卷

cinder --os-volume-api-version 3.28 create --name ceshi-centos7-lvm1 --volume-type lvm 10 --lvm_instance_hostname xgo06sit010243097032.sncloud.com

14 快速启动虚机

for i in $(nova list --all-tenants --host=osnode010027244137.cnsuning.com | grep -v "+-\|ID" | awk '{ print $2}'); do nova start $i; done

15扩展卷

lvextend -L +100G /dev/mapper/vg_os-lv_os_data

resize2fs -p -F /dev/mapper/vg_os-lv_os_data

16并发创建虚机

nova boot --flavor 2c4g75g --image a9019a6c-d14e-4328-81d8-00710ef87ea3 --nic net-id=9f02e2f1-b700-4f2d-86dc-b1ac38d3ba8a 0e2bd229-7cab-4dd6-958b-cfdf45405e31 ceshi01

镜像通过在控制节点上glance image-list中选取

网段通过在控制节点上

17创建port

brctl addbr qbr4cb9397b-e1

brctl setfd qbr4cb9397b-e1 0

brctl stp qbr4cb9397b-e1 off

echo '0' > /sys/class/net/qbr4cb9397b-e1/bridge/multicast_snooping

echo '1' > /proc/sys/net/ipv6/conf/qbr4cb9397b-e1/disable_ipv6

ip link add qvb4cb9397b-e1 type veth peer name qvo4cb9397b-e1

ip link set qvb4cb9397b-e1 up

ip link set qvb4cb9397b-e1 promisc on

ip link set qvo4cb9397b-e1 up

ip link set qvo4cb9397b-e1 promisc on

ip link set qvb4cb9397b-e1 mtu 1500

ip link set qvo4cb9397b-e1 mtu 1500

ip link set qbr4cb9397b-e1 up

brctl addif qbr4cb9397b-e1 qvb4cb9397b-e1

ovs-vsctl -- --if-exists del-port qvo4cb9397b-e1 --add-port br-int qvo4cb9397b-e1 \

--set Interface qvo4cb9397b-e1 external-ids:iface-id=4cb9397b-e1ff-48c2-b57c-d5f55afb96e1 \

external-ids:iface-status=active external-ids:attached-mac=fa:16:3e:a0:49:90 external-ids:\

vm-uuid=150b5217-5113-43f7-acff-831a328bcd77

18.创建port

neutron port-create 7ca29955-fa01-4e3a-99d5-95a15e7b3d76 --fixed-ip subnet_id=f088c2e8-2c2e-4933-a35d-6fc3fced842d,ip_address=10.10.10.36

19.虚机绑定port

nova interface-attach a77c54bb-aa73-4b86-887a-54f81bfa9d3d --port-id 3caa4ef9-6bd5-4039-a81f-04d36ea2131f

20.数据库查询虚机ip

mysql -e "select ip_address from neutron.ipallocations ip inner join neutron.ports p on ip.port_id=p.id inner join nova.instances v on p.device_id=v.uuid where v.node='xgto02n010027244148.sncloud.com' and v.deleted='0';"|grep -v 'ip_address'

21.销毁虚机

先解绑数据盘,删除数据盘然后再删除虚机

source /root/openrc;

nova volume-detach vm_uuid volume_uuid #解绑数据盘和虚机的关系

cinder delete volume_uuid #删除数据盘

nova delete vm_uuid虚机uuid #删除虚机(创建成功的,虚机创建失败的,虚机创建成功的,迁移失败的,迁移成功的)

22.虚拟异常后重启

重启异常断电虚机(虚机状态为shutoff)

nova reset-state --active uuid

nova reboot --hard uuid

23.集群

计算节点的服务:neutron

控制节点查集群各节点:nova service-list

nova host-list

openstack hypervisor list

查看节点资源

nova hypervisor-show xxx.aws.com|grep -Ei "local_gb|vcpus|memory_mb|cinder_vgs"

24.ha

pcs resource show

25.计算节点网络

yum install bridge-utils

brctl show

brctl list

neutron net-list

neutron port-list

手动up

ip l set dev service0 up

ip l set dev service1 up

26.查看虚机

nova list --al

nova list --all-tenants --fields instance_name,host,networks,name

nova list --all --host "xxx.aws.com"

查看虚机云盘:cinder list --all

27.查看所有创建的虚拟机:virsh list --all

virsh edit 61

virsh edir instance-00002edf

28.镜像

控制节点查看集群所有镜像:# glance image-list

控制节点查看集群指定镜像:# glance image-show d3b336e6-8860-47a8-ac3f-40061de160e6

29.迁移进度查询

nova migration-progress 80382828-85a1-4749-91f8-ad2588f1efe4

31.服务检查

检查rabbitmq

rabbitmqctl list_users

#重新创建 openstack用户

rabbitmqctl add_user openstack RABBIT_PASS

#重启驱动rabbitmq-server 和nova服务的组件

ECONNREFUSED?

32.清理环境

查计算节点:

openstack host list

nova service-list

置为不可用

nova service-disable linux-node2.openstack nova-compute

清理计算节点

#mysql

mysql> use nova

mysql> delete from compute_node_stats where compute_node_id in

(select id from compute_nodes where hypervisor_hostname='xxx.aws.com');

mysql> delete from compute_nodes where hypervisor_hostname='xxx.aws.com' ;

mysql> delete from services where host='xxx.aws.com';

相关推荐
終不似少年遊*3 天前
云计算HCIP-OpenStack01
云原生·云计算·学习笔记·openstack·hcip·虚拟化
終不似少年遊*6 天前
云计算HCIP-OpenStack03
linux·网络·云原生·云计算·学习笔记·openstack·hcip
終不似少年遊*6 天前
云计算HCIP-OpenStack02
云原生·云计算·学习笔记·openstack·hcip
終不似少年遊*6 天前
云计算HCIP-OpenStack04
云原生·云计算·学习笔记·openstack·hcip·虚拟化
終不似少年遊*7 天前
华为云(openstack)常用命令行
linux·服务器·网络·华为云·云计算·操作系统·openstack
ZVAyIVqt0UFji14 天前
openstack内部rpc消息通信源码分析
网络·网络协议·rpc·openstack
four-hour18 天前
openstack 报错合集
openstack
葡萄爱22 天前
构建高可用系统设计OpenStack、Docker、Mesos和Kubernetes(简称K8s)
docker·kubernetes·openstack
four-hour23 天前
四:工具、环境准备-compute node
linux·ubuntu·openstack
胖胖不胖、1 个月前
解决:Openstack创建实例进入控制台报错Something went wrong, connection is closed
linux·服务器·openstack