Skip to content

Instantly share code, notes, and snippets.

@alphajc
Created April 10, 2017 09:37
Show Gist options
  • Save alphajc/9dc0a3c77d1b41aed61367cdcf70e07c to your computer and use it in GitHub Desktop.
Save alphajc/9dc0a3c77d1b41aed61367cdcf70e07c to your computer and use it in GitHub Desktop.

导入镜像

远程导入镜像

sdc-imgadm import <uuid> -S <sources-url>

本地导入镜像

sdc-imgadm import -m <manifest> -f <file>

添加网卡

echo '{"add_nics":[{"nic_tag":"external","ip":"10.9.8.2","netmask":"255.255.255.0"}]}' | vmadm update <uuid>

创建自定义的Zone镜像

创建一个自定义的Zone镜像的过程如下:

  1. Create and customize a zone as you wish
  2. Purge the logs, etc. and run the sm-prepare-image to make the machine image-ready (remember to read the warning message!).
  3. Halt the zone: vmadm stop
  4. Snapshot the Zone dataset: zfs snapshot zones/@image
  5. Dump & Compress the dataset: zfs send zones/@image | gzip > image_name.zfs.gz
  6. Create the manifest as described above

创建一个自定义的KVM镜像

 创建一个自定义的KVM镜像的过程如下:

  1. Create and customize a KVM instance as you wish
  2. Purge and ready the instance
  3. Halt the VM: vmadm stop
  4. Snapshot the disk0 ZVol: zfs snapshot zones/-disk0@image
  5. Dump & Compress the dataset: zfs send zones/-disk0@image | gzip > image_name.zvol.gz

从已有的Zone创建镜像

imgadm create <vm-uuid> -f manifest

修改Triton服务镜像(以cnapi为例)

准备

  1. manifest文件:cnapi.manifest
{
  "v": 2,
  "owner": "00000000-0000-0000-0000-000000000000",
  "name": "cnapi",
  "version": "release-20170302-20170302T175529Z-g29b8eb5",
  "state": "active",
  "disabled": false,
  "public": false,
  "published_at": "2017-03-02T18:06:05.627Z",
  "type": "zone-dataset",
  "description": "SDDC",
  "requirements": {
    "min_platform": {
      "7.0": "20141030T081701Z"
    },
    "networks": [
      {
        "name": "net0",
        "description": "admin"
      }
    ]
  },
  "tags": {
    "smartdc_service": true
  }
}
  1. 从sdc-smartos 1.6.3创建好的虚机  最简单的创建方式是使用adminui创建,选择镜像的时候选sdc-smartos 1.6.3即可。也可以使用vmadm进行创建,指定manifest文件即可。
  2. 编译好的cnapi模块,以及其他模块。具体模块参照原cnapi建虚拟机/opt下:
    1. /opt/amon-agent
    2. /opt/smartdc/boot
    3. /opt/smartdc/cnapi
    4. /opt/smartdc/config-agent
    5. /opt/smartdc/registrar

拷贝编译好的模块

scp -r <> <目标>

关闭虚拟机

vmadm stop <uuid>

生成镜像和manifest文件

imgadm create <uuid> -c gzip -m cnapi.manifest

此操作将生成两个文件

替换datasets下对应文件

将上一个操作生成的两个文件,修改文件名后,替换掉原来的文件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment