Escolar Documentos
Profissional Documentos
Cultura Documentos
Davide Restivo
4
Hard Partitions
For examples:
OS 0 OS 1
Operating System
HW 0 HW 1
Hardware
5
Very expensive!!!
Virtual Machines
For examples:
ENV 0 ENV 1
Environment
OS 0 OS 1
Operating System
Hardware
6
OS Virtualization
For examples:
ENV 0 ENV 1
Environment
Operating System
Hardware
7
Resource Management
For examples:
Environment
Operating System
Hardware
8
ZFS Overview
● ZFS is a new fs from SUN available from Solaris 10
(06/06)
● ZFS was designed by Jeff Bonwick
● ZFS is an open source project (CDDL)
● ZFS eliminates the need of a volume manager
● ZFS is a 128-bit fs (unlimited capacity)
● 2^48 — Number of snapshots
● 2^48 — Number of files in any individual filesystem
● Automatically repairs corrupted data (in redundant
configuration only)
9
ZFS Overview
● 16 exabytes (2^64 byte) — Maximum size of a
filesystem
● 16 exabytes (2^64 byte) — Maximum size of a single
file
● Copy-on-write model
● Transactional object model
● Portable between paltforms (x86 from/to SPARC)
● Simple administration
● All data and metadata are checksummed
P.S.: The name originally stood for "Zettabyte File System"
but is now an pseudo-acronym. 10
ZFS vs. Traditional filesystems
● Traditional filesystem
– resides on a single device
– requires a “Volume Manager” or “Raid Controller” to use more than one device
– Not portable between platforms
– Offline fsck utility
– Difficult to grow/shrink
● ZFS
– no partitions to manage
– is built on top of virtual storage pools called zpools.
– grow/shrink automatically
– No need to edit /etc/vfstab (automatically mounted)
– Online scrubbing (data available to users)
– Portable between paltform (e.g. X86 to/from SPARC) 11
ZFS vs. Raid
● RAID 5
– Suffers “Write Hole” (loss of power between data and parity)
– Workaround to “Write Hole”: NVRAM (..expensive!!!)
– Expensive controllers
● ZFS
– Everything is copy-on-write (no live data modified)
– Everything is transactional (related changes succeed or fail
as a whole, in other words Atomic)
– No extra hardware!!!
12
ZFS Pools
● Eliminates the notion of volume
● A pool is constructed from virtual devices (vdevs)
vdevs
● A vdev describes a single device or a collection of devices
organized according to certain performance and fault
characteristics
● It is possible to use whole disk or slice as vedv in a storage pool
(slices are not portable)
● The storage capacity of all vdevs are then available to all of the
file systems in the zpool
● The zpool command configures ZFS storage pools
● All datasets in a storage pool share the same space
13
Vdevs (Virtual DEVices)
● Vdevs can not be nested (no mirror or mirror, raidz of mirror,
ecc... )
● The following vdevs are supported:
– disk (/dev/dsk/c0t0d0, /dev/dsk/c0t0d0s2, c0t0d0)
– slices
– file (only for testing purpouse)
– mirror (minimum 2 disks)
– raidz ( raidz1), raidz2
– spare
14
Manage ZFS pool
Create a single root vdev (mirror)
# zpool create pool1 mirror c0t0d0 c1t0d0
15
Manage ZFS pool
Create a single root vdev (a mirror) with one hot spare disk
# zpool create pool1 mirror c0t0d0 c1t0d0 spare c2t0d0
Create a single root vdev (a mirror) and then add a hot spare disk
# zpool create pool1 mirror c0t0d0 c1t0d0
# zpool add pool1 spare c2t0d0
( # zpool remove pool1 c2t0d0 )
Destroy a pool
# zpool destroy pool1
16
List all available zpools and show info of a particular zpool
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
zones 68G 665M 67.4G 0% ONLINE -
# zpool status zones
pool: zones
state: ONLINE
scrub: scrub completed with 0 errors on Wed Dec 27 15:13:36 2006
config:
NAME STATE READ WRITE CKSUM
zones ONLINE 0 0 0
mirror ONLINE 0 0 0
c1t2d0 ONLINE 0 0 0
c1t3d0 ONLINE 0 0 0
17
errors: No known data errors
IOStat
18
Migrating ZFS Storage pool
In certain situations you might need to move a storage pool between
two machines.
ZFS enables you to export the pool from one machine and import it
on the destination machine. Migration consists of two steps:
19
2 - Import a ZFS Storage Pool
# zpool import
pool: pool1
id: 3778921145927357706
state: ONLINE
action: The pool can be imported using its name or numeric identifier.
Config:
pool1 ONLINE
mirror ONLINE
c1t0d0 ONLINE
c1t1d0 ONLINE
20
.. if something
.
21
1 - Recovering Destroyed ZFS Storage pools
# zpool import -D
pool: pool1
id: 3778921145927357706
state: ONLINE (DESTROYED)
action: The pool can be imported using its name or numeric identifier. The pool was
destroyed, but can be imported using the ’-Df’ flags.
config:
pool1 ONLINE
mirror ONLINE
c1t0d0 ONLINE
c1t1d0 ONLINE
config:
NAME STATE READ WRITE CKSUM
pool1 DEGRADED 0 0 0
mirror DEGRADED 0 0 0
c0t1d0 UNAVAIL 0 0 0 cannot open
c1t1d0 ONLINE 0 0 0
23
Let's change broken disk an bring the new disk online
# zpool online pool1 c0t1d0
24
3 - Replacing a broken device with another (on different channel)
# zpool replace pool1 c1t0d0 c2t0d0
Manually:
Manually using zpool replace command
Automatically:
Automatically When a fault is received, an FMAagent examines the
pool to see if it has any available hot spares. If so, it
replaces the faulted device with an available spare.
26
Manually spare activation
# zpool create pool1 mirror c1t2d0 c2t1d0 spare c1t3d0 c2t3d0
config:
NAME STATE READ WRITE CKSUM
pool1 ONLINE 0 0 0
mirror ONLINE 0 0 0
c1t2d0 ONLINE 0 0 0
c2t1d0 ONLINE 0 0 0
spares
c1t3d0 AVAIL
c2t3d0 AVAIL
errors: No known data errors
27
# zpool replace pool1 c2t1d0 c2t3d0
config:
NAME STATE READ WRITE CKSUM
pool1 ONLINE 0 0 0
mirror ONLINE 0 0 0
c1t2d0 ONLINE 0 0 0
spare ONLINE 0 0 0
c2t1d0 ONLINE 0 0 0
c2t3d0 ONLINE 0 0 0
spares
c1t3d0 AVAIL
c2t3d0 INUSE currently in use
errors: No known data errors
28
After the faulted device is replaced and the resilver is completed, use
the zpool detach command to return the hot spare back to the spare
set.
# zpool detach pool1 c2t3d0
# zpool status pool1
pool: pool1
state: ONLINE
scrub: resilver completed with 0 errors on Fri Jun 2 13:44:40 2006
config:
NAME STATE READ WRITE CKSUM
pool1 ONLINE 0 0 0
mirror ONLINE 0 0 0
c1t2d0 ONLINE 0 0 0
c2t1d0 ONLINE 0 0 0
spares
c1t3d0 AVAIL
c2t3d0 AVAIL
errors: No known data errors
An in-progress spare replacement can be cancelled by detaching the hot spare. If
the original faulted device is detached, then the hot spare assumes its place in the
29
configuration, and is removed from the spare list of all active pools.
...for all the other problems
start to pray
an search for a
valid backup!!!
30
Managing ZFS datasets
The zfs command configures ZFS datasets.
A storage pool is also the root of the ZFS file system hierarchy, it
can be accessed as a file system, inluding mounting, unmounting,
taking snapshots, ecc...
A dataset can be one of the following:
– file system
– volume (simulates a block device)
– snapshot (read-only)
– clone
31
Managing ZFS datasets
Create a dataset
# zfs create pool1/data1
● Directories are created and destroyed as needed.
● The default mountpoint for pool1/data1 is /pool1/data1.
● The mountpoint properties is inherited
● A file system mountpoint property of “none” prevents the file system from being
mounted.
● If a file system's mount point is set to "legacy", ZFS file systems can be managed
with traditional tools (mount, umount, /etc/vfstab).
Automatically NFS-export
# zfs set sharenfs=rw pool1/data1
Set compression
# zfs set compression=on pool1/data1
Set quota
# zfs set quota=10g pool1/data1
33
Managing ZFS datasets
Set reservation
# zfs set reservation=2g pool1/data1
<continue> 34
<continue>
35
ZFS Snapshots
Note: Snapshots are read-only!
Take a snapshot of pool1/data1
# zfs snapshot pool1/data1@first
36
ZFS Snapshots
Take a look at file foo.txt in a snapshot
# cat /export/data1/.zfs/snapshot/first/foo.txt
Note: The visibility of the ".zfs" directory can be controlled by the "snapdir" property.
38
Container Overview
Solaris Container consists of several technologies
that work together. In particular:
– ZFS
– Dynamic Resource Pool
– FSS (Fair Share Scheduler)
– Solaris Zones
39
Dynamic Resource Pools
Dynamic Resource Pools enables CPU resources
to be allocated to specific applications.
2 4
WebServer
Mail Server
Database
AS
4 / (1 + 2 + 3 + 4 ) = 0.4 = 40 %
globalzone# pooladm -e
globalzone# pooladm
system my_system
string system.comment
int system.version 1
boolean system.bind-default true
int system.poold.pid 638
<continue> 42
pool pool_default
int pool.sys_id 0
boolean pool.active true
boolean pool.default true
int pool.importance 1
string pool.comment
pset pset_default
pset pset_default
int pset.sys_id -1
boolean pset.default true
uint pset.min 1
uint pset.max 65536
string pset.units population
uint pset.load 7
uint pset.size 8
string pset.comment
cpu
int cpu.sys_id 1
string cpu.comment
string cpu.status on-line
<omitted> 43
4 - Create a processor set containing one CPU
globalzone# poolcfg -c 'create pset as-pset (uint pset.min=1; uint pset.max=1)'
globalzone# pooladm -c
44
globalzone# reboot
Solaris Zones
● Solaris Zones provide separate environments on a
machine and logically isolate applications.
● Two type of zones:
– Global zone
– Non-global zone
● A standard zone automatically shares the
– /usr (ro)
– /lib (ro)
– /platform (ro)
45
– /sbin (ro)
Create a simple zone
1 - Zone definition
globalzone# zonecfg -z zone1
zone1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:zone1> create
zonecfg:zone1> set zonepath=/export/home/zones/zone1
zonecfg:zone1> add net
zonecfg:zone1:net> set address=10.0.0.2
zonecfg:zone1:net> set physical=eri0
zonecfg:zone1:net> end
zonecfg:zone1> set pool=pool_default
zonecfg:zone1:net> verify
zonecfg:zone1:net> commit
zonecfg:zone1:net> exit
46
2 - Install the zone
globalzonel# zoneadm -z zone1 install
47
An advanced example
1 – Zone definition
zonecfg:zone2:fs> end
zonecfg:zone2> add device
zonecfg:zone2:device> set match=/dev/dsk/c0t0d0s6
zonecfg:zone2:device> end
zonecfg:zone2> add device
zonecfg:zone2:device> set match=/dev/rdsk/c0t0d0s6
zonecfg:zone2:device> end
zonecfg:zone2> verify
zonecfg:zone2> commit Block device
zonecfg:zone2> exit
Character device
49
2 - Install the zone
globalzonel# zoneadm -z zone2 install
50
How to add a dataset to a zone
1 - Create a dataset
zone3 zone4
52
Server 1 Server 2
1 - Halt the zone
Use -p
3 - Create the archive
globalzones1# cd /export/zones/zone4
globalzones1# tar cvpf /tmp/zone4.tar ./zone4
54
Reference Documentation
● “Solaris ZFS Administration Guide”
● The Sun BluePrints - “Guide to Solaris Containers”
● Solaris 10 How to Guides - “How to move a Solaris Container”
● Solaris 10 How to Guides - “Consolidating servers and
applications”
● Solaris 10 How to Guides - “ZFS in Solaris Containers”
● man pages
55
”Time for questions”
56