Top Banner
SmartOS Primer Daniele Stroppa, ZHAW [email protected], @moviolone www.cloudcomp.ch
24

SmartOS Primer

May 21, 2015

Download

Technology

Daniele Stroppa

An introduction to SmartOS that will get you started
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SmartOS Primer

SmartOS PrimerDaniele Stroppa, ZHAW

[email protected], @moviolone

www.cloudcomp.ch

Page 2: SmartOS Primer

Agenda

■ Getting Started■ Disk Administration■ Images Administration■ Virtual Machines Administration■ Network Administration

www.cloudcomp.ch

Page 3: SmartOS Primer

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

Page 4: SmartOS Primer

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

Page 5: SmartOS Primer

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

Page 6: SmartOS Primer

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

Page 7: SmartOS Primer

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

Page 8: SmartOS Primer

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

Page 9: SmartOS Primer

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

Page 10: SmartOS Primer

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

Page 11: SmartOS Primer

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

Page 12: SmartOS Primer

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

[...]

Page 13: SmartOS Primer

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

Page 14: SmartOS Primer

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

Page 15: SmartOS Primer

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

Page 16: SmartOS Primer

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

Page 17: SmartOS Primer

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

Page 18: SmartOS Primer

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

Page 19: SmartOS Primer

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

Page 20: SmartOS Primer

Network Administration - Intro

■ Each VM can get up to 32 VNICs■ VRRP, Link aggregation■ One tool: dladm

www.cloudcomp.ch

Page 21: SmartOS Primer

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

Page 22: SmartOS Primer

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

Page 23: SmartOS Primer

Q&[email protected], @moviolone

Thank you!

www.cloudcomp.ch