ZStack 云环境模拟器

来源:互联网 发布:winxp添加网络打印机 编辑:程序博客网 时间:2024/05/18 02:46

提供:ZStack云计算

介绍

熟悉OpenStack的同学应该知道OpenStack可以用devstack来搭建一个虚拟云环境, 使用CloudStack的同学也知道CloudStack也有一个虚拟云环境。 在虚拟云环境中,云主机不会在物理设备上真正创建出来,一切的云场景都是构建在一个虚无的世界中,唯有IaaS的数据库和消息总线还在真实的工作。 由于云模拟器的这种特性,我们可以用它来熟悉各种云操作和进行底层和虚拟机无关的集成测试,例如测试消息总线,测试数据库,测试IaaS的基本功能。 ZStack的模拟器是ZStack开发伊始就存在的,并随着ZStack功能的开发而不断增强。ZStack的数百个集成测试用例就是 跑在ZStack的模拟器之上的。ZStack首页上例举的很多大规模并发性能测试也是基于模拟器来进行的 (不过ZStack在用户的真实物理环境中已经拿到比在PC模拟器上还要好的数据了,平均云主机的创建时间可以低于0.08s)。在频繁的各种VM的操作之中, 我们可以稳定的获得ZStack仅仅用一个管理节点就可以高效的模拟管理数十万的计算节点和上百万的云主机的常规并发操作。 从而验证了Rabbitmq完全可以胜任大规模并发环境的IaaS操作(只要调度方法正确)。 ZStack模拟器是和ZStack天然集成的,用户不需要进行额外的配置。只要正常启动ZStack管理程序后,就可以部署虚拟云环境。

今天我们就要给大家展示一下ZStack的虚拟云环境如何创建。另外我们还要给大家展示一下如何一步部署ZStack模拟云环境。 ZStack模拟器和ZStack天然集成,最早的时候ZStack的Dashboard也是可以在UI界面上添加和部署虚拟云环境。但是后来为了避免用户的误操作, ZStack开发团队把UI界面上添加云环境的功能给禁止了。目前虚拟云环境需要通过zstack-cli来操作。 如果您只是想快速部署一个虚拟的云环境,而不在乎部署的过程,可以直接跳转到本文的最后,使用一键部署。 用户可以在半分钟内完成虚拟云环境的部署,并用其创建虚拟云主机。

前提

已经根据ZStack快速安装手册,完成ZStack的快速安装和启动。

登录zstack控制终端

  1. [zstack@localhost ~]$ sudo zstack-cli
  2.  
  3. ZStack command line tool
  4. Type "help" for more information
  5. Type Tab key for auto-completion
  6. Type "quit" or "exit" or Ctrl-d to exit
  7.  
  8. >>>LogInByAccount accountName=admin password=password
  9. {
  10. "inventory": {
  11. "accountUuid": "36c27e8ff05c4780bf6d2fa65700f22e",
  12. "createDate": "Aug 3, 2015 7:59:59 AM",
  13. "expiredDate": "Aug 3, 2015 9:59:59 AM",
  14. "userUuid": "36c27e8ff05c4780bf6d2fa65700f22e",
  15. "uuid": "d45bdd89b8984d65b35dd97f83387e4c"
  16. },
  17. "success": true
  18. }

创建Zone

  1. >>>CreateZone name=simulator-zone
  2. {
  3. "inventory": {
  4. "createDate": "Aug 3, 2015 8:00:25 AM",
  5. "lastOpDate": "Aug 3, 2015 8:00:25 AM",
  6. "name": "simulator-zone",
  7. "state": "Enabled",
  8. "type": "zstack",
  9. "uuid": "22331c109ef64f88a5826bcf96793941"
  10. },
  11. "success": true
  12. }

创建Cluster

需要大家把zoneUuid换成自己刚刚创建的Zone的UUID,并且把hypervisor的类型指定为“Simulator”:

  1. >>>CreateCluster name=simulator-cluster zoneUuid=22331c109ef64f88a5826bcf96793941 hypervisorType=Simulator
  2. {
  3. "inventory": {
  4. "createDate": "Aug 3, 2015 8:02:19 AM",
  5. "hypervisorType": "Simulator",
  6. "lastOpDate": "Aug 3, 2015 8:02:19 AM",
  7. "name": "simulator-cluster",
  8. "state": "Enabled",
  9. "type": "zstack",
  10. "uuid": "c237767682d947f58efaf5e485b713e7",
  11. "zoneUuid": "22331c109ef64f88a5826bcf96793941"
  12. },
  13. "success": true
  14. }

添加虚拟的计算节点

添加虚拟计算节点的时候,需要使用一个特别的API:AddSimulatorHost。(添加物理KVM计算节点的API是:AddKVMHost)。 由于是虚拟的计算节点,我们还需要给一个假设的CPU容量和内存容量(为了测试方便,该容量可以给的随意大):

  1. >>>AddSimulatorHost name=simulator-host clusterUuid=c237767682d947f58efaf5e485b713e7 cpuCapacity=200000 memoryCapacity=1000000000000 managementIp=10.10.10.10
  2. {
  3. "inventory": {
  4. "availableCpuCapacity": 200000,
  5. "availableMemoryCapacity": 1000000000000,
  6. "clusterUuid": "c237767682d947f58efaf5e485b713e7",
  7. "createDate": "Aug 3, 2015 8:05:08 AM",
  8. "hypervisorType": "Simulator",
  9. "lastOpDate": "Aug 3, 2015 8:05:08 AM",
  10. "managementIp": "10.10.10.10",
  11. "name": "simulator-host",
  12. "state": "Enabled",
  13. "status": "Connected",
  14. "totalCpuCapacity": 200000,
  15. "totalMemoryCapacity": 1000000000000,
  16. "uuid": "b879af2114794044a6ce2f8902da3e38",
  17. "zoneUuid": "22331c109ef64f88a5826bcf96793941"
  18. },
  19. "success": true
  20. }

添加虚拟主存储

同虚拟计算节点一样,我们需要使用一个特别的API(AddSimulatorPrimaryStorage)来添加虚拟主存储, 另外我们还需要给一个虚拟的可用空间以及设置类型为SimulatorPrimaryStorage:

  1. >>>AddSimulatorPrimaryStorage name=simulator-ps zoneUuid=22331c109ef64f88a5826bcf96793941 availableCapacity=10000000000000 totalCapacity=10000000000000 url=nfs://fake_url/fake_folder type=SimulatorPrimaryStorage
  2. {
  3. "inventory": {
  4. "attachedClusterUuids": [],
  5. "availableCapacity": 10000000000000,
  6. "availablePhysicalCapacity": 0,
  7. "createDate": "Aug 3, 2015 8:12:31 AM",
  8. "lastOpDate": "Aug 3, 2015 8:12:31 AM",
  9. "mountPath": "/primarystoragesimulator/c6c019a5b6dc494aaacbedfb5d3beb8e",
  10. "name": "simulator-ps",
  11. "state": "Enabled",
  12. "status": "Connected",
  13. "totalCapacity": 10000000000000,
  14. "totalPhysicalCapacity": 0,
  15. "type": "SimulatorPrimaryStorage",
  16. "url": "nfs://fake_url/fake_folder",
  17. "uuid": "c6c019a5b6dc494aaacbedfb5d3beb8e",
  18. "zoneUuid": "22331c109ef64f88a5826bcf96793941"
  19. },
  20. "success": true
  21. }

然后把刚创建的主存储挂载到虚拟cluster上去:

  1. >>>AttachPrimaryStorageToCluster primaryStorageUuid=c6c019a5b6dc494aaacbedfb5d3beb8e clusterUuid=c237767682d947f58efaf5e485b713e7
  2. {
  3. "inventory": {
  4. "attachedClusterUuids": [
  5. "c237767682d947f58efaf5e485b713e7"
  6. ],
  7. "availableCapacity": 10000000000000,
  8. "availablePhysicalCapacity": 0,
  9. "createDate": "Aug 3, 2015 8:12:31 AM",
  10. "lastOpDate": "Aug 3, 2015 8:12:31 AM",
  11. "mountPath": "/primarystoragesimulator/c6c019a5b6dc494aaacbedfb5d3beb8e",
  12. "name": "simulator-ps",
  13. "state": "Enabled",
  14. "status": "Connected",
  15. "totalCapacity": 10000000000000,
  16. "totalPhysicalCapacity": 0,
  17. "type": "SimulatorPrimaryStorage",
  18. "url": "nfs://fake_url/fake_folder",
  19. "uuid": "c6c019a5b6dc494aaacbedfb5d3beb8e",
  20. "zoneUuid": "22331c109ef64f88a5826bcf96793941"
  21. },
  22. "success": true
  23. }

添加虚拟备份存储

同添加虚拟主存储类似,我们也需要用到特殊的AddSimulatorBackupStorage,除了设定虚拟的可用空间外, 我们还需要指定存储类型为SimulatorBackupStorage。创建完成后,在把它挂载到zone上:

  1. >>>AddSimulatorBackupStorage name=simulator-bs url=/fake_url totalCapacity=1000000000000 availableCapacity=1000000000000 type=SimulatorBackupStorage
  2. {
  3. "inventory": {
  4. "attachedZoneUuids": [],
  5. "availableCapacity": 1000000000000,
  6. "createDate": "Aug 3, 2015 8:22:00 AM",
  7. "lastOpDate": "Aug 3, 2015 8:22:00 AM",
  8. "name": "simulator-bs",
  9. "state": "Enabled",
  10. "status": "Connected",
  11. "totalCapacity": 1000000000000,
  12. "type": "SimulatorBackupStorage",
  13. "url": "/fake_url",
  14. "uuid": "7bde50df528b45ffb1689229c3de105b"
  15. },
  16. "success": true
  17. }
  18.  
  19. >>>AttachBackupStorageToZone backupStorageUuid=7bde50df528b45ffb1689229c3de105b zoneUuid=22331c109ef64f88a5826bcf96793941
  20. {
  21. "inventory": {
  22. "attachedZoneUuids": [
  23. "22331c109ef64f88a5826bcf96793941"
  24. ],
  25. "availableCapacity": 1000000000000,
  26. "createDate": "Aug 3, 2015 8:22:00 AM",
  27. "lastOpDate": "Aug 3, 2015 8:22:00 AM",
  28. "name": "simulator-bs",
  29. "state": "Enabled",
  30. "status": "Connected",
  31. "totalCapacity": 1000000000000,
  32. "type": "SimulatorBackupStorage",
  33. "url": "/fake_url",
  34. "uuid": "7bde50df528b45ffb1689229c3de105b"
  35. },
  36. "success": true
  37. }

添加虚拟云主机模版

由于我们指定了备份存储为一个虚拟备份存储,添加Image的时候不需要使用真实的url。但是我们需要在Image的format上指定为simulator,而不是qcow2或者raw。

  1. >>>AddImage name=simulator-image backupStorageUuids=7bde50df528b45ffb1689229c3de105b format=simulator mediaType=RootVolumeTemplate url=http://fake_url
  2. {
  3. "inventory": {
  4. "backupStorageRefs": [
  5. {
  6. "backupStorageUuid": "7bde50df528b45ffb1689229c3de105b",
  7. "createDate": "Aug 3, 2015 8:46:40 AM",
  8. "imageUuid": "5e40b7d5fed442848830716bfe71ec2e",
  9. "installPath": "/fake_url/simulator-image",
  10. "lastOpDate": "Aug 3, 2015 8:46:40 AM"
  11. }
  12. ],
  13. "createDate": "Aug 3, 2015 8:46:40 AM",
  14. "format": "simulator",
  15. "lastOpDate": "Aug 3, 2015 8:46:40 AM",
  16. "md5Sum": "528068b1699f4495bcd90f1b901e6ee9",
  17. "mediaType": "RootVolumeTemplate",
  18. "name": "simulator-image",
  19. "platform": "Linux",
  20. "size": 100,
  21. "state": "Enabled",
  22. "status": "Ready",
  23. "system": false,
  24. "type": "zstack",
  25. "url": "http://fake_url",
  26. "uuid": "5e40b7d5fed442848830716bfe71ec2e"
  27. },
  28. "success": true
  29. }

创建虚拟L2

添加一个虚拟的L2设备,当挂载给一个虚拟的Cluster的时候,ZStack不会检查该L2设备是否真实存在。

  1. >>>CreateL2NoVlanNetwork name=simulator-l2 physicalInterface=eth0 zoneUuid=22331c109ef64f88a5826bcf96793941
  2. {
  3. "inventory": {
  4. "attachedClusterUuids": [],
  5. "createDate": "Aug 3, 2015 8:26:46 AM",
  6. "lastOpDate": "Aug 3, 2015 8:26:46 AM",
  7. "name": "simulator-l2",
  8. "physicalInterface": "eth0",
  9. "type": "L2NoVlanNetwork",
  10. "uuid": "66d4801c02154daeb361bf0a703bd14b",
  11. "zoneUuid": "22331c109ef64f88a5826bcf96793941"
  12. },
  13. "success": true
  14. }
  15.  
  16. >>>AttachL2NetworkToCluster l2NetworkUuid=66d4801c02154daeb361bf0a703bd14b clusterUuid=c237767682d947f58efaf5e485b713e7
  17. {
  18. "inventory": {
  19. "attachedClusterUuids": [
  20. "c237767682d947f58efaf5e485b713e7"
  21. ],
  22. "createDate": "Aug 3, 2015 8:26:46 AM",
  23. "lastOpDate": "Aug 3, 2015 8:26:46 AM",
  24. "name": "simulator-l2",
  25. "physicalInterface": "eth0",
  26. "type": "L2NoVlanNetwork",
  27. "uuid": "66d4801c02154daeb361bf0a703bd14b",
  28. "zoneUuid": "22331c109ef64f88a5826bcf96793941"
  29. },
  30. "success": true
  31. }

添加一个L3网络

  1. >>>CreateL3Network name=simulator-l3 l2NetworkUuid=66d4801c02154daeb361bf0a703bd14b
  2. {
  3. "inventory": {
  4. "createDate": "Aug 3, 2015 8:29:23 AM",
  5. "ipRanges": [],
  6. "l2NetworkUuid": "66d4801c02154daeb361bf0a703bd14b",
  7. "lastOpDate": "Aug 3, 2015 8:29:23 AM",
  8. "name": "simulator-l3",
  9. "networkServices": [],
  10. "state": "Enabled",
  11. "system": false,
  12. "type": "L3BasicNetwork",
  13. "uuid": "af0c2a51dd954207af9f61e43bfee757",
  14. "zoneUuid": "22331c109ef64f88a5826bcf96793941"
  15. },
  16. "success": true
  17. }
  18. >>>AddIpRange name=simulator-ip-range l3NetworkUuid=af0c2a51dd954207af9f61e43bfee757 startIp=172.16.0.2 endIp=172.16.255.254 netmask=255.255.0.0 gateway=172.16.0.1
  19. {
  20. "inventory": {
  21. "createDate": "Aug 3, 2015 8:30:44 AM",
  22. "endIp": "172.16.255.254",
  23. "gateway": "172.16.0.1",
  24. "l3NetworkUuid": "af0c2a51dd954207af9f61e43bfee757",
  25. "lastOpDate": "Aug 3, 2015 8:30:44 AM",
  26. "name": "simulator-ip-range",
  27. "netmask": "255.255.0.0",
  28. "startIp": "172.16.0.2",
  29. "uuid": "24607ef0fa0b4b3fa6965e4c3c331abe"
  30. },
  31. "success": true
  32. }

添加云主机模版

  1. >>>CreateInstanceOffering name=simulator-vm-offering cpuNum=2 cpuSpeed=128 memorySize=256000000
  2. {
  3. "inventory": {
  4. "allocatorStrategy": "DefaultHostAllocatorStrategy",
  5. "cpuNum": 2,
  6. "cpuSpeed": 128,
  7. "createDate": "Aug 3, 2015 8:33:14 AM",
  8. "lastOpDate": "Aug 3, 2015 8:33:14 AM",
  9. "memorySize": 256000000,
  10. "name": "simulator-vm-offering",
  11. "sortKey": 0,
  12. "state": "Enabled",
  13. "type": "UserVm",
  14. "uuid": "3ea91a8e7d3a4cd7b87eaf2f516aa827"
  15. },
  16. "success": true
  17. }

创建一个虚拟的云主机

创建一个虚拟的云主机我们需要指定L3,Image和InstanceOffering的UUID。它们的UUID都可以在之前的命令结果中找到:

  1. CreateVmInstance name=sim-vm1 l3NetworkUuids=af0c2a51dd954207af9f61e43bfee757 imageUuid=5e40b7d5fed442848830716bfe71ec2e instanceOfferingUuid=3ea91a8e7d3a4cd7b87eaf2f516aa827
  2. {
  3. "inventory": {
  4. "allVolumes": [
  5. {
  6. "createDate": "Aug 3, 2015 8:48:27 AM",
  7. "description": "Root volume for VM[uuid:63becebd92894c108a4c268d7a722ed9]",
  8. "deviceId": 0,
  9. "format": "simulator",
  10. "installPath": "nfs:/fake_url/fake_folder/vm/8657fb16029444bfb62e96eed0867cc0.qcow2",
  11. "lastOpDate": "Aug 3, 2015 8:48:27 AM",
  12. "name": "ROOT-for-sim-vm1",
  13. "primaryStorageUuid": "c6c019a5b6dc494aaacbedfb5d3beb8e",
  14. "rootImageUuid": "5e40b7d5fed442848830716bfe71ec2e",
  15. "size": 100,
  16. "state": "Enabled",
  17. "status": "Ready",
  18. "type": "Root",
  19. "uuid": "8657fb16029444bfb62e96eed0867cc0",
  20. "vmInstanceUuid": "63becebd92894c108a4c268d7a722ed9"
  21. }
  22. ],
  23. "allocatorStrategy": "DefaultHostAllocatorStrategy",
  24. "clusterUuid": "c237767682d947f58efaf5e485b713e7",
  25. "cpuNum": 2,
  26. "cpuSpeed": 128,
  27. "createDate": "Aug 3, 2015 8:48:27 AM",
  28. "defaultL3NetworkUuid": "af0c2a51dd954207af9f61e43bfee757",
  29. "hostUuid": "b879af2114794044a6ce2f8902da3e38",
  30. "hypervisorType": "Simulator",
  31. "imageUuid": "5e40b7d5fed442848830716bfe71ec2e",
  32. "instanceOfferingUuid": "3ea91a8e7d3a4cd7b87eaf2f516aa827",
  33. "lastHostUuid": "b879af2114794044a6ce2f8902da3e38",
  34. "lastOpDate": "Aug 3, 2015 8:48:27 AM",
  35. "memorySize": 256000000,
  36. "name": "sim-vm1",
  37. "platform": "Linux",
  38. "rootVolumeUuid": "8657fb16029444bfb62e96eed0867cc0",
  39. "state": "Running",
  40. "type": "UserVm",
  41. "uuid": "63becebd92894c108a4c268d7a722ed9",
  42. "vmNics": [
  43. {
  44. "createDate": "Aug 3, 2015 8:48:27 AM",
  45. "deviceId": 0,
  46. "gateway": "172.16.0.1",
  47. "ip": "172.16.199.179",
  48. "l3NetworkUuid": "af0c2a51dd954207af9f61e43bfee757",
  49. "lastOpDate": "Aug 3, 2015 8:48:27 AM",
  50. "mac": "fa:f1:91:9a:a7:00",
  51. "netmask": "255.255.0.0",
  52. "uuid": "888fdf0816714cdfa16a5797d6e2c8dc",
  53. "vmInstanceUuid": "63becebd92894c108a4c268d7a722ed9"
  54. }
  55. ],
  56. "zoneUuid": "22331c109ef64f88a5826bcf96793941"
  57. },
  58. "success": true
  59. }

保存当前云环境

如果觉得每次创建一个虚拟云环境还是需要花费一些时间来一步步添加各种资源。我们可以利用zstack-cli的dump云环境的功能, 把当前的云环境给dump下来,然后在以后的测试中,直接还原。

使用zstack-cli -h 来获取相关的参数信息

  1. [zstack@localhost ~]$ sudo zstack-cli -h
  2. Usage: -c [options]
  3.  
  4. Options:
  5. -h, --help show this help message and exit
  6. -H HOST, --host=HOST [Optional] IP address or DNS name of a ZStack
  7. management node. Default value: localhost
  8. -p PORT, --port=PORT [Optional] Port that the ZStack management node is
  9. listening on. Default value: 8080
  10. -d DEPLOY_CONFIG_FILE, --deploy=DEPLOY_CONFIG_FILE
  11. [Optional] deploy a cloud from a XML file.
  12. -t DEPLOY_CONFIG_TEMPLATE_FILE, --tempate=DEPLOY_CONFIG_TEMPLATE_FILE
  13. [Optional] variable template file for XML file
  14. spcified in option '-d'
  15. -D ZSTACK_CONFIG_DUMP_FILE, --dump=ZSTACK_CONFIG_DUMP_FILE
  16. [Optional] dump a cloud to a XML file

然后使用 -D 来dump刚刚部署好的虚拟云环境

  1. [zstack@localhost ~]$ sudo zstack-cli -D /tmp/simulator-zstack-cloud.xml

如果还没有登录zstack-cli或者session已经超时,请使用zstack-cli LogInByAccount accountName=admin password=password来登录系统。

Dump好的xml文件内容

  1. <?xml version="1.0" ?>
  2.  
  3. <deployerConfig>
  4.  
  5. <nodes>
  6. <node hostName="10.10.3.230" uuid="8ff3c1babe0d44c0a75ab3a93eb7c867"/>
  7. </nodes>
  8.  
  9. <instanceOfferings>
  10. <instanceOffering allocatorStrategy="DefaultHostAllocatorStrategy"
  11. cpuNum="2"
  12. cpuSpeed="128"
  13. memorySize="256000000"
  14. name="simulator-vm-offering"
  15. sortKey="0"
  16. state="Enabled"
  17. type="UserVm"
  18. uuid="3ea91a8e7d3a4cd7b87eaf2f516aa827"/>
  19. </instanceOfferings>
  20.  
  21. <backupStorages>
  22. <simulatorBackupStorage availableCapacity="1000000000000"
  23. name="simulator-bs"
  24. state="Enabled"
  25. status="Connected"
  26. totalCapacity="1000000000000"
  27. type="SimulatorBackupStorage"
  28. url="/fake_url"
  29. uuid="7bde50df528b45ffb1689229c3de105b"/>
  30. </backupStorages>
  31.  
  32. <images>
  33. <image format="simulator"
  34. mediaType="RootVolumeTemplate"
  35. name="simulator-image"
  36. platform="Linux"
  37. state="Enabled"
  38. status="Ready"
  39. system="False"
  40. type="zstack"
  41. url="http://fake_url"
  42. uuid="5e40b7d5fed442848830716bfe71ec2e">
  43.  
  44. <backupStorageRef>
  45. simulator-bs
  46. </backupStorageRef>
  47. </image>
  48. </images>
  49.  
  50. <zones>
  51. <zone name="simulator-zone"
  52. state="Enabled"
  53. type="zstack"
  54. uuid="22331c109ef64f88a5826bcf96793941">
  55.  
  56. <backupStorageRef>
  57. simulator-bs
  58. </backupStorageRef>
  59.  
  60. <primaryStorages>
  61. <simulatorPrimaryStorage availableCapacity="9999999999900"
  62. availablePhysicalCapacity="0"
  63. name="simulator-ps"
  64. state="Enabled"
  65. status="Connected"
  66. totalCapacity="10000000000000"
  67. totalPhysicalCapacity="0"
  68. url="nfs://fake_url/fake_folder"
  69. uuid="c6c019a5b6dc494aaacbedfb5d3beb8e"/>
  70. </primaryStorages>
  71.  
  72. <clusters>
  73. <cluster hypervisorType="Simulator"
  74. name="simulator-cluster"
  75. state="Enabled"
  76. type="zstack"
  77. uuid="c237767682d947f58efaf5e485b713e7"
  78. zoneUuid="22331c109ef64f88a5826bcf96793941">
  79.  
  80. <hosts>
  81. <host managementIp="10.10.10.10"
  82. name="simulator-host"
  83. state="Enabled"
  84. status="Connected"
  85. uuid="b879af2114794044a6ce2f8902da3e38"/>
  86. </hosts>
  87.  
  88. <primaryStorageRef>
  89. simulator-ps
  90. </primaryStorageRef>
  91.  
  92. <l2NetworkRef>
  93. simulator-l2
  94. </l2NetworkRef>
  95. </cluster>
  96. </clusters>
  97.  
  98. <l2Networks>
  99. <l2NoVlanNetwork name="simulator-l2"
  100. physicalInterface="eth0"
  101. description="l2"
  102. uuid="66d4801c02154daeb361bf0a703bd14b">
  103.  
  104. <l3Networks>
  105. <l3BasicNetwork name="simulator-l3"
  106. state="Enabled"
  107. system="False"
  108. uuid="af0c2a51dd954207af9f61e43bfee757">
  109. <ipRange endIp="172.16.255.254"
  110. gateway="172.16.0.1"
  111. name="simulator-ip-range"
  112. netmask="255.255.0.0"
  113. startIp="172.16.0.2"
  114. uuid="24607ef0fa0b4b3fa6965e4c3c331abe"/>
  115. </l3BasicNetwork>
  116. </l3Networks>
  117. </l2NoVlanNetwork>
  118. </l2Networks>
  119. </zone>
  120. </zones>
  121. </deployerConfig>

还原虚拟云环境

当进行了一些测试后,希望快速还原初始化的虚拟云环境,我们就可以使用上一节的xml内容进行恢复。我们假设xml的文件为:/tmp/simulator-zstack-cloud.xml

停止zstack管理节点

  1. zstack-ctl stop_node

始化数据库

注意:该操作会清空整个数据库中的数据

  1. zstack-ctl deploydb --drop

如果设置了mysql的root密码,还需要添加 --root-password=MY_MYSQL_ROOT_PASSWORD 的参数。

启动zstack管理节点

  1. zstack-ctl start_node

一键恢复zstack云环境

如果还没有登录zstack-cli或者session已经超时,请使用zstack-cli LogInByAccount accountName=admin password=password来登录系统。

  1. zstack-cli -d /tmp/simulator-zstack-cloud.xml

创建一个虚拟云主机试试

  1. sudo zstack-cli CreateVmInstance name=sim-vm1 l3NetworkUuids=af0c2a51dd954207af9f61e43bfee757 imageUuid=5e40b7d5fed442848830716bfe71ec2e instanceOfferingUuid=3ea91a8e7d3a4cd7b87eaf2f516aa827

总结

在本文中,我们介绍了如何使用zstack-cli 命令来搭建一个模拟的zstack 云环境。也介绍了如何把搭建好的云环境备份下来,之后可以一键还原。 欢迎ZStack的用户使用模拟器来熟悉ZStack云环境,以及进行各种性能和压力测试,看看ZStack系统是否可以响应数万的并发API请求。

0 0
原创粉丝点击