共享镜像 glance member-create fa47923c-2d3b-4d71-80cf-a047ba3bf342 eb3913b9ae5f41b09f2632389a1958d8
删除共享镜像 glance member-delete fa47923c-2d3b-4d71-80cf-a047ba3bf342 eb3913b9ae5f41b09f2632389a1958d8
列出私有镜像 glance image-list --is-public=False
列出公有镜像 glance image-list --is-public=True
镜像删除 glance image-delete 镜像ID
镜像上传 glance image-create --name=centos_7.4_x64_globalegrow --is-public=True --container-format bare --disk-format raw --property cloudinit_updated=True --property can_live_resize=Yes --property os_type=linux --property os_name=centos --file=centos_7.4_x64.img
glance image-create --name "镜像名字" --file 镜像文件名字 --disk-format raw --container-format bare --is-public=False --property os_type=linux --property cloudinit_updated=True --owner 项目ID --progress
镜像下载 glance image-download --file test_image f1bffb27-340f-4b0b-bd62-310b49e22c5b
查看所有云主机 nova list --all nova list --all --host compute6
查看镜像所有云主机 nova list --image 5a34b656-ed38-4911-b494-82236f254a1b --all
查看某个项目下的所有云主机 nova list --all|grep 1ee16a3fb843411eb7c8b1201bd182d
查看云主机详情 nova show 7e762e1f-c7df-4cb3-b7ac-332bf360330b
硬重启云主机:nova reboot --hard e93f26bf-2f39-43d2-9870-33227eba81c9
查看虚拟机历程:nova instance-action-list eec6d2f8-f295-417c-8d12-c31ea005c689
重置虚拟机状态:nova reset-state eec6d2f8-f295-417c-8d12-c31ea005c689 --active
创建磁盘 cinder qos-create ceph-ssd-qos consumer=front-end read_bytes_sec=50000000 write_bytes_sec=50000000 read_iops_sec=400 write_iops_sec=400
查看磁盘属性:cinder volume-qos-show c65be62c-64c2-4c45-b891-1f3d1a9f6fa9
查看QOS cinder qos-list
将卷类型和qos绑定 cinder qos-associate QOS_ID TYPE_ID
查看lb:neutron lbaas-loadbalancer-list
查看同一配置的云主机有多少台 nova list --all --flavor ff6da875-51cd-4ae5-9d8e-d5b7a7c8a7ed
列出所有子网 neutron subnet-list
查看云主机的生命历程 nova instance-action-list a1833d9a-a3b0-4df4-b3ba-5b79fbd99639
查看命名空间 ip netns
查看实例 nova flavor-list
创建实例 nova flavor-create --vcpus 1 --ram 1024 --disk 5 ram_type_1_1G_5G
列出用户 keystone user-list
列出租户 keystone tenant-list
获取ak sk keystone ec2-credentials-create --user-id 25b6d5fe34344e50a3c606e72deba23b --tenant-id ea1e8ebfb404454294ab16facb8ac287(项目ID)
查看单个实例的详细信息 nova show 50b6f7d5-ca78-423d-81c1-ad7671e6c07f
查看实例的生命过程 nova instance-action-list 50b6f7d5-ca78-423d-81c1-ad7671e6c07f
查看浮动ip列表 neutron floatingip-list
镜像格式转换 qemu-img convert -f qcow2 -O raw CentOS-7.3_x64.qcow2 centOS-7.3_x64.raw
https://blog.csdn.net/sinat_32079337/article/details/70245700 升级桌面
更改云主机状态、重启云主机 for i in `nova list --all --host compute23 | grep ERROR | awk '{print $2}'`;do echo $i;nova reset-state $i;sleep 3;nova reboot $i --hard;done
更改磁盘iops nova disk-qos-update eb132fd7-c8cb-41a1-a176-0b49c52601a7 vdb write_iops_sec=1500 read_iops_sec=1500
更改磁盘吞吐量 nova disk-qos-update c9ae05d4-6ce9-4748-976c-d17687f3c162 vdb write_bytes_sec=15728640 read_bytes_sec=15728640
在用U盘装完CentOS后,重新开机启动后显示:
Initial setup of CentOS Linux 7 (core)
1) [x] Creat user 2) [!] License information
(no user will be created) (license not accepted)
Please make your choice from above [‘q’ to quit | ‘c’ to continue | ‘r’ to refresh]:
解决方法:
输入“1”,按Enter键
输入“2”,按Enter键
输入“q”,按Enter键
输入“yes”,按Enter键
也就是出现如下情况。
vip设置
2018/03/05 17:29:32 root(root)@(10.60.0.253)[Pid:69391][LoginTime:2018-03-05 13:38] ExecuteCommand: neutron port-list --device_id 616aef07-f935-4a18-860e-269996e0cbaa --device_owner compute:None
2018/03/05 17:33:17 root(root)@(10.60.0.253)[Pid:69391][LoginTime:2018-03-05 13:38] ExecuteCommand: neutron port-update 0a537465-7d1e-4c21-87e2-ee43cfd955f2 --allowed-address-pairs type=dict list=true mac_address=fa:16:3e:f1:22:01,ip_ad
dress=10.61.99.254
2018/03/05 17:33:34 root(root)@(10.60.0.253)[Pid:69391][LoginTime:2018-03-05 13:38] ExecuteCommand: neutron port-list --device_id 461f2ebe-7814-4600-8991-9fd36629b0a7 --device_owner compute:None
2018/03/05 17:34:04 root(root)@(10.60.0.253)[Pid:69391][LoginTime:2018-03-05 13:38] ExecuteCommand: neutron port-update 847ae6c5-0946-4748-bdb4-704f46ee818e --allowed-address-pairs type=dict list=true mac_address=fa:16:3e:d8:dd:fa,ip_ad
dress=10.61.99.254
2018/03/05 17:34:20 root(root)@(10.60.0.253)[Pid:69391][LoginTime:2018-03-05 13:38] ExecuteCommand: neutron port-list --device_id 55656391-f7da-413c-9e17-ecb9248f4da8 --device_owner compute:None
2018/03/05 17:34:47 root(root)@(10.60.0.253)[Pid:69391][LoginTime:2018-03-05 13:38] ExecuteCommand: neutron port-update a5fc4a70-b39b-436c-945c-28a228d47340 --allowed-address-pairs type=dict list=true mac_address=fa:16:3e:7a:a1:a6,ip_ad
dress=10.61.99.254
2018/03/05 17:35:16 root(root)@(10.60.0.253)[Pid:69391][LoginTime:2018-03-05 13:38] ExecuteCommand: neutron floatingip-list |grep 10.60.35.0
2018/03/05 17:35:34 root(root)@(10.60.0.253)[Pid:69391][LoginTime:2018-03-05 13:38] ExecuteCommand: neutron port-list |grep 10.61.99.254
2018/03/05 17:36:03 root(root)@(10.60.0.253)[Pid:69391][LoginTime:2018-03-05 13:38] ExecuteCommand: neutron floatingip-associate 8103cc46-e78c-4365-ae0a-9459782ccc23 3dbe9771-9f6f-4797-af03-4c6e1c2bab3a
2018/03/05 18:05:38 root(root)@(10.60.0.253)[Pid:69391][LoginTime:2018-03-05 13:38] ExecuteCommand: neutron port-list
#!/bin/bash
source /home/op/keystonerc_admin
cat ip.txt|while read ID;do
fip_id=`mysql neutron -e "select id from floatingips where floating_ip_address ='$ID';"|grep -w id -A1|grep -v id`
neutron floatingip-update $fip_id --icp_registed True
done
'
网卡限速规则:
neutron qos-policy-list
neutron qos-policy-create 1000m-qos --tenant-id 1bddd69b5ffd4be3968b39a77da222d3
[root@controller2 ~(wsops)]# neutron qos-policy-list
+--------------------------------------+---------------------------+
| id | name |
+--------------------------------------+---------------------------+
| 510e649d-0bed-474e-8dde-c3150764866a | manila-neutron-qos-policy |
| a3c9b4e8-d020-48ad-8c78-3fc718d53ad6 | 1000m-qos |
| e7827845-89f6-4a31-8254-cdab28b1a654 | 800mb-limit |
| fa3ece1c-d1a9-4c10-a36e-d9ceac689523 | sz_of_Test_OpsAnsible01 |
+--------------------------------------+---------------------------+
neutron qos-bandwidth-limit-rule-create --max-kbps 1000000 --max-burst-kbps 1000000 a3c9b4e8-d020-48ad-8c78-3fc718d53ad6
neutron port-update 65fd217b-d9b0-45f6-aa19-70c07a2dead9 --qos-policy a3c9b4e8-d020-48ad-8c78-3fc718d53ad6
neutron port-show 65fd217b-d9b0-45f6-aa19-70c07a2dead9
[root@controller2 ~(wsops)]# nova interface-list 50b6f7d5-ca78-423d-81c1-ad7671e6c07f
+------------+--------------------------------------+--------------------------------------+--------------+-------------------+
| Port State | Port ID | Net ID | IP addresses | MAC Addr |
+------------+--------------------------------------+--------------------------------------+--------------+-------------------+
| ACTIVE | 0498098a-22ed-4527-b29a-c2c8265c3042 | bc459d85-f538-4a6a-a138-6acb99229110 | 10.62.36.142 | fa:16:3e:63:3e:27 |
rbd export vms/d021f2dc-ecfe-4658-9404-2fd12cdaed5e_disk huanq.raw
rbd info vms/d021f2dc-ecfe-4658-9404-2fd12cdaed5e_disk
qemu-img info rbd://vms/50b6f7d5-ca78-423d-81c1-ad7671e6c07f
qemu-img convert -f raw -O qcow2 huanq.raw huanq.qcow2
rbd -p volumes rm volume-3d976111-3bd9-4707-a4d8-105ceacc4574
rbd -p volumes import --image-format 2 --order 23 huanq.raw volume-3d976111-3bd9-4707-a4d8-105ceacc4574
for my-id in $(nova list --all --host compute5 |egrep ^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12} | awk '{print $2}');do
echo $my-id ;nova start ${my-id};done
2.4.1 浮动IP分配
创建浮动IP:
root@sun:~# neutron floatingip-create Extnet
Created a new floatingip:
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| fixed_ip_address | |
| floating_ip_address | 10.8.127.11 |
| floating_network_id | 9c9436d4-2b7c-4787-8535-9835e6d9ac8e |
| id | 7b4cee72-ffcd-4484-a5d8-371b23bb3cc3 |
关联到一个 port:
root@sun:~# neutron port-list | grep 192.168.10.26
| d74c703e-824a-41b1-b4b3-3cd4edfa22b3 | | fa:16:3e:14:ff:6d | {"subnet_id": "ccc80588-2b0d-459b-82e9-972ff4291b79", "ip_address": "192.168.10.26"} |
root@sun:~# neutron floatingip-associate 7b4cee72-ffcd-4484-a5d8-371b23bb3cc3 d74c703e-824a-41b1-b4b3-3cd4edfa22b3
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| fixed_ip_address | 192.168.10.26 |
| floating_ip_address | 10.8.127.11 |
每个浮动 IP 唯一对应一个 Router:浮动IP -> 关联的 Port -> 所在的 Subnet -> 包含该 subnet 以及 external subnet 的 Router。创建浮动 IP 时,在 Neutron 完成数据库操作来分配浮动IP后,它通过 RPC 来通知该浮动IP对应的 router 去设置该浮动IP对应的 iptables 规则。上面的例子中,固定IP 为 ‘192.168.10.26’ 的虚机可以在外网中使用浮动 IP ‘10.8.127.11’ 来访问了。
neutron floatingip-associate 8103cc46-e78c-4365-ae0a-9459782ccc23(floating_ip) 3dbe9771-9f6f-4797-af03-4c6e1c2bab3a(port_id)
neutron port-create --tenant-id 1ee16a3fb843411eb7c8b1201bd182d8 --fixed-ip subnet_id=e6ee8a90-fdc1-4b78-a6bc-b33ae6520939(subnets_id),ip_address=1
0.61.99.254 8e68b2bd-4774-474e-936f-d240cc8ef475(net-id)(内网ip创建)
[root@controller2 ~(wsops)]# ip netns exec qrouter-7d764c54-b30f-4b60-88e9-64fa7fc4e18b iptables -t nat -D neutron-vpn-agen-snat 3
[root@controller2 ~(wsops)]# ip netns exec qrouter-7d764c54-b30f-4b60-88e9-64fa7fc4e18b iptables -nL --line-number -t nat
[root@controller2 ~(wsops)]# ip netns exec qrouter-7d764c54-b30f-4b60-88e9-64fa7fc4e18b iptables -t nat -I neutron-vpn-agen-float-snat -s 10.62.50.5 -j SNAT --to 10.60.52.49