Introduction
SmartOS is a version of Sun's Solaris/SunOS with support for the excellent
dtrace
tool. dtrace
is starting to find its way into the Linux world
and there is also support for OSX (which I'm running). But it would be nice
to be able to use dtrace
in production which means that I need to look at
SmartOS for now. Joyent, which is behind SmartOS, has a cloud running on
SmartOS to it is easy to get started with a production server. But I'd
also like to develop and test on a similar setup. So here I am giving
SmartOS a first spin.
Quick reference
Some commands:
- List zones (containers):
vmadm list
- Show data links:
dladm show-link
- Show physical networks:
dladm show-phys
- Show NICs:
dladm show-vnic
- Show IP addresses:
ipadm show-addr
- Show network configuration of zone:
vmadm get 2d688169-9bd1-4677-bb67-99b8740d70e0|json nics
This gist automates the install (after SmartOS has been installed):
curl -k https://gist.githubusercontent.com/colmsjo/a0d5307e8b61ca905ce7/raw/60e80e70aced8bb12a1a544b40036c210b015efc/install.sh | bash
Installation
I'll setup SmartOS on VirtualBox in OSX. This is easy, just follow these instructions on the SmartOS wiki
Check what IP adress the machine received and login with ssh
. This is much
simpler than using the terminal in VirtualBox. I use bridged network to make this
easy.
The network within zones were not reachable with this approach. Testing this instead:
- Boot from the ISO as a LiveCD
- use "bridge mode"
- in the advanced settings, enable "promiscuous mode".
SmartOS first steps
I havent worked with zones, zfs etc. on Solaris so I needed to check otu the common commands:
Zones are created using images. This lists the availble images: imgadm avail
These are the basic images to build custom images from: imgadm avail|grep base64
Import the latest (at hthe time of writing) basic image: imgadm import 62f148f8-6e84-11e4-82c5-efca60348b9f
Put this into zone01.json:
{
"brand": "joyent",
"image_uuid": "62f148f8-6e84-11e4-82c5-efca60348b9f",
"alias": "zone01",
"hostname": "zone01",
"max_physical_memory": 512,
"quota": 10,
"resolvers": ["8.8.8.8", "208.67.220.220"],
"nics": [
{
"nic_tag": "admin",
"ip": "192.168.1.131",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1"
}
]
}
Create the zone:
vmadm create -f zone01.json
Successfully created VM 2d688169-9bd1-4677-bb67-99b8740d70e0
Login:
zlogin 2d688169-9bd1-4677-bb67-99b8740d70e0
# set password to make it possible to login with vmadm
passwd root
vmadm console 2d688169-9bd1-4677-bb67-99b8740d70e0
Now in the new zone, install some software:
[root@zone01 ~]# pkgin ls
reading local summary...
processing local summary...
updating database: 100%
Setup global zone
Make it possible to install packages in the global zone:
cd /
curl -k http://pkgsrc.joyent.com/packages/SmartOS/bootstrap/bootstrap-2013Q1-x86_64.tar.gz | gzcat | tar -xf -
pkg_admin rebuild
pkgin -y up
Install whatever you need: pkgin -y install nano ...
Networking
Networking with NIC, data links etc. connected to zones is a bit of a mystreri (at least for me). A found an introduction to data links that is good to check out.
- Show links:
dladm show-link
- This shows the physical interfaces (NIC) when executed in the global zone:
dladm show-phys
- There is also virtual NICs:
dladm show-vnic
- Show bridges:
dladm show-bridge
Create a NIC (not sure howto make this works):
dladm create-vnic -l e1000g0 zone0
ifconfig zone0 plumb
ifconfig zone0 dhcp
# dhcp timed out, tested thus instead (use inet of server+1)
ifconfig zone0 inet 192.168.1.135 netmask 255.255.255.0 up
Testing some more:
dladm show-phys
dladm show-link
ipadm show-addr
dladm create-vnic -l link vnic
ipadm create-ip vnic
ipadm create-addr -T static -a address addrobj
ipadm create-addr -T dhcp e1000g0/zone0
Troubleshooting:
- This seams promissing - VirtualBox and Zones
- VirtualBox and Solaris networking
- Check routes:
routeadm
- Restart route service : ``
Setup a firewall for zones using NAT
Followed this article NAT using Etherstubs
cat > /etc/ipf/ipnat.conf <<EOL
map net0 10.0.0.2/32 -> 0/32
EOL
routeadm -u -e ipv4-forwarding
svcadm enable ipfilter
ipnat -l
Services
SmartOS is built around services using Service Management Framework (SMF). Some intro can be found here
Resources