smartos primer
DESCRIPTION
An introduction to SmartOS that will get you startedTRANSCRIPT
Agenda
■ Getting Started■ Disk Administration■ Images Administration■ Virtual Machines Administration■ Network Administration
www.cloudcomp.ch
Getting Started - Requirements
■ System Requirements○ Minimum 1GB RAM*○ 64-bit x86 CPU
■ To use KVM SmartOS requires an Intel CPU with VT-x extensions○ http://ark.intel.com/Products/VirtualizationTechnology
* Since SmartOS is a live OS, the more RAM the better
www.cloudcomp.ch
Getting Started - USB boot
■ Get the latest USB image from http://wiki.smartos.org/display/DOC/Download+SmartOS
■ Create a bootable USB drive from the image○ e.g.: on Linux, dd if=smartos-$RELEASE-usb.img
of=/dev/sdb bs=1024
■ Stick the USB drive in a port and boot
www.cloudcomp.ch
Getting Started - PXE boot
■ Get the latest Platform image from http://wiki.smartos.org/display/DOC/Download+SmartOS and unpack it in your netboot env
○ Make sure the kernel and the boot archive have the following path: (prefix)
/platform/i86pc/kernel/amd64/unix for the kernel and (prefix)/platform/i86pc/amd64/boot_archive for the boot archive. (prefix) can be any path, e.g. /tftpboot/smartos/20130724
www.cloudcomp.ch
Getting Started - PXE boot
■ Get a PXE client, e.g. iPXE, configure DHCP for PXE chainloading, e.g. http://ipxe.org/howto/dhcpd
■ Create a PXE boot script, e.g.#!ipxe
kernel /smartos/20130724/platform/i86pc/kernel/amd64/unix
initrd /smartos/20130724/platform/i86pc/amd64/boot_archive
boot
www.cloudcomp.ch
Getting Started - Gotcha's
■ Basic configuration is stored in /usbkey/config○ This is limited to networking, DNS, and NTP○ Root password and SSH config are also in /usbkey
■ /etc is non-persistent, /opt and /var are.
www.cloudcomp.ch
Disk Administration - Intro
■ ZFS is default in SmartOS■ Pools and datasets
○ Pool: a collection of one or more virtual devices, e.g. disks, files,..
○ Dataset: a control point for a volume or file system■ Two commands: zpool and zfs
www.cloudcomp.ch
Disk Administration - Pools
■ Create a pool# zpool create data c0t0d0 c0t1d0
■ Grow a pool# zpool add data c0t2d0
○ Note: as of today, pools cannot shrink.
www.cloudcomp.ch
Disk Administration - Datasets
■ Create a pool# zfs create data/db
■ Create a snapshot# zfs snapshot -r data/db@20130724
■ Rollback a snapshot# zfs rollback data/db@20130724
■ Clone a snapshot# zfs clone data/db@20130724 data/db2
www.cloudcomp.ch
Images Administration - Intro
■ Images are templates that contain data (ZFS dataset) and metadata (JSON)
■ Images are used in SmartOS when creating Virtual Machines
■ Default image server is datasets.joyent.com ○ found in /var/db/imgadm/sources.list
■ One tool: imgadm
www.cloudcomp.ch
Images Administration - imgadm
■ Get images
www.cloudcomp.ch
# imgadm update
updating local images database...
Get https://datasets.joyent.com/datasets...
done
# imgadm avail
UUID OS PUBLISHED URN
6bf31ce2-f384-11e1-a338-e39c2fe4ab59 smartos 2012-08-31 sdc:sdc:mongodb:1.3.2
a0f8cf30-f2ea-11e1-8a51-5793736be67c smartos 2012-08-30 sdc:sdc:standard64:1.0.7
3390ca7c-f2e7-11e1-8818-c36e0b12e58b smartos 2012-08-30 sdc:sdc:standard:1.0.7
9604da58-f1ee-11e1-aba1-dbda3337ec46 smartos 2012-08-29 sdc:sdc:mongodb:1.3.1
[...]
Images Administration - imgadm
■ Get images
www.cloudcomp.ch
# imgadm import 9eac5c0c-a941-11e2-a7dc-57a6b041988f
9eac5c0c-a941-11e2-a7dc-57a6b041988f doesnt exist. continuing with install
9eac5c0c-a941-11e2-a7dc-57a6b041988f successfully installed
image 9eac5c0c-a941-11e2-a7dc-57a6b041988f successfully imported
# imgadm list
UUID OS PUBLISHED URN
9eac5c0c-a941-11e2-a7dc-57a6b041988f smartos 2013-04-26 sdc:sdc:base64:13.1.0
Virtual Machines Administration - Intro
■ Two flavours: zone ("joyent" brand) and KVM ("kvm" brand)○ KVM VMs still run in a zone though
■ VM = Image + manifest (JSON)■ One tool: vmadm
www.cloudcomp.ch
Virtual Machines Administration - Creating a Zone
■ Get a zone image○ Use imgadm avail. Images with the OS type smartos
are zone images■ Zone manifest
{ "brand": "joyent", "image_uuid": "9eac5c0c-a941-11e2-a7dc-57a6b041988f ", "alias": "zone01", "hostname": "zone01", "max_physical_memory": 1024, "quota": 20, "nics": [ { "nic_tag": "admin", "ip": "10.20.50.24", "netmask": "255.255.255.0", "gateway": "10.20.50.1" } ]}
www.cloudcomp.ch
Virtual Machines Administration - Creating a KVM
■ Get a KVM image○ Use imgadm avail. Images with the OS type linux are
KVM images■ KVM manifest
{ "brand": "kvm", "resolvers": [ "208.67.222.222", "8.8.4.4" ], "default-gateway": "10.20.50.1", "ram": "2048", "vcpus": "1", ...
www.cloudcomp.ch
Virtual Machines Administration - Creating a KVM
■ KVM manifest"nics": [ { "nic_tag": "admin", "ip": "10.20.50.48", "netmask": "255.255.255.0", "gateway": "10.20.50.1", "model": "virtio", "primary": true } ], "disks": [ { "image_uuid": "e42f8c84-bbea-11e2-b920-078fab2aab1f", "boot": true, "model": "virtio", "image_size": 10240 } ]}
www.cloudcomp.ch
Virtual Machines Administration - vmadm
■ Create the VM# vmadm create -f zone01.json
Successfully created 4aac2fb2-f30a-49ef-08d2-41e6af10bde1
■ Zone login# vmadm console 4aac2fb2-f30a-49ef-08d2-41e6af10bde1
■ VM listing# vmadm listUUID TYPE RAM STATE ALIAS4aac2fb2-f30a-49ef-08d2-41e6af10bde1 OS 1024 running zone01f144656f-41d4-460f-75ab-26f38d8f9fc6 KVM 2048 running fedora01
www.cloudcomp.ch
Virtual Machines Administration - vmadm
■ VM start/stop/reboot/delete# vmadm start UUID
# vmadm stop UUID
# vmadm reboot UUID
# vmadm delete UUID
■ VM update, e.g. increase disk size# vmadm update 4aac2fb2-f30a-49ef-08d2-41e6af10bde1 quota=40
■ VM migration (experimental)# vmadm send 4aac2fb2-f30a-49ef-08d2-41e6af10bde1 |ssh 10.0.1.2 vmadm receivePassword:Succesfully sent VM 4aac2fb2-f30a-49ef-08d2-41e6af10bde1Succesfully received VM 4aac2fb2-f30a-49ef-08d2-41e6af10bde1
www.cloudcomp.ch
Network Administration - Intro
■ Each VM can get up to 32 VNICs■ VRRP, Link aggregation■ One tool: dladm
www.cloudcomp.ch
Network Administration - dladm
■ Create and configure the VNIC# dladm create-vnic -l e1000g0 -v 128 backup0# ifconfig backup0 plumb# ifconfig backup0 inet 10.30.50.7 netmask 255.255.255.0 up
■ To persist a VNIC across reboot store the configuration in /usbkey/config
www.cloudcomp.ch
Network Administration - Link Aggregation
■ Get available physical NICs# dladm show-phys -mLINK SLOT ADDRESS INUSE CLIENTe1000g0 primary 0:11:45:4f:a6:f5 yes e1000g0e1000g1 primary 0:11:45:47:90:aa yes e1000g1
■ Add a <name>_aggr config in /usbkey/config# List MAC address in the aggregationbackup_aggr=0:11:45:4f:a6:f5,0:11:45:47:90:aa # VM nics with backup nic_tags will now have # their vnics created on the aggregationadmin_nic=e1000g0backup_nic=backup
■ Reboot and verify # dladm show-aggr LINK POLICY ADDRPOLICY LACPACTIVITY LACPTIMER FLAGS backup L4 auto active short -----
www.cloudcomp.ch
References■ http://wiki.smartos.org■ http://smartos.org/2012/08/22/smartos-an-sa-primer/
www.cloudcomp.ch