Thursday, December 16, 2010

ZFS in Solaris 10

Features:
•    256 quadrillion zettabytes
•    RAID 0/1 & RAID Z (RAID 5 with enhancements) (2 required virtual devices)
•    Snapshots – read-only copies of file systems or volumes
•    Creates volumes
•    Uses storage pools to manage storage – aggregates virtual devices
•    File systems attached to pools grow dynamically as storage is added
•    File systems may span multiple physical disks
•    ZFS is transactional
•    Pools & file systems are auto-mounted. No need to maintain /etc/vfstab
•    Supports file system hierarchies: /pool1/{home(5GB),var(10GB),etc.}
•    Supports reservation of storage: /pool1/{home(10GB),var}
•    Provides a secure web-based management tool
•    Requires devices of min size 128mb
•    Web GUI - https://localhost:6789/zfs - served by smcwebserver




### Storage Pool ###

Commands:

1. To list the known pools :
# zpool list

2. To create a pool using a disk :
# zpool create pool1 c0t1d0s2

3. To  add a disk to an existing pool :
# zpool add pool1 /dev/dsk/c1t2d2

4. To list pools and the associated mount points :
# zfs mount 

5. To show the virtual devices that constitues all the pools :
# zpool status

6. To show the virtual devices associated with pool1 :
# zpool status –v pool1

7.To destroy a pool and its associated file systems :
# zpool destroy pool1

8. To change the mount point of a pool :

# zfs set mountpoint=/firstpool pool1



### File System ###

Commands :
 
1. To create ‘home’ file system in pool1 :
# zfs create pool1/home          

2. To set 10G quota to pool1/home :
# zfs set quota=10G pool1/home       

3. To create a file system under pool1/home :
# zfs create pool1/home/unixcbt       

4. To list quota related values for pool1 and its file systems :
# zfs get –r quota pool1           

5.  To list compression property for file systems associated with pool1 :
# zfs get –r compression pool1       

6. To rename a file system :
# zfs rename pool1/home1 pool1/home2



### ZFS Redundany/Replication ###

1.    Mirroring – RAID-1
2.    RAID-Z    - RAID-5

Note: Redundancy/Replication is associated with the pool

Commands :

1. To create a mirror pool :
# zpool create pool1 mirror c0t1d0 c0t2d0    Creates a mirror pool

2. To create a RAID-Z pool :

# zpool create pool2 raidz c0t1d0 c0t2d



### ZFS Snapshots ###

1.    Read only copies of volumes or file systems
2.    Use no additional space, initially

Commands :

1. To list the available snapshots :
# zfs list –t snapshot      

2. To create a snapshot for pool1/home :
# zfs snapshot pool1/home@homesnap1   

3.To destroy a snapshot :
# zfs destroy pool1/home@homesnap1  

4. To rename homesnap2 to homesnap3 :
# zfs rename pool1/home@homesnap2 pool1/home@homesnap3

5.  To rollback a file system using a snapshot :
# zfs rollback –f pool1/home@homesnap3   


### ZFS Clone ###

1.    Writable file systems or volumes
2.    Linked to a snapshot
3.    Clone can be stored anywhere in ZFS hierarchy

Commands :

1. Creates a clone file system using a snapshot :
# zfs clone pool1/home@homesnap3 pool2/home

Zones in Sun Servers

Features:
  • Virtualization
  • Solaris Zones can hosts only instances of Solaris. Not other OS
  • Limit 8192 zones per Solaris host
  • Primary (global) zone has access to ALL zones
  • Non-global zones, do NOT have access to other non-global zones
  • Default non-global zones derive packages from global zone
  • Program isolation – zone1 (Apache), zone2 (MySQL)
  • Provides ‘z’ commands to manage zones
  • At least 100mb required for the creation of non-global zone
  • Type:
    1. Sparse Root Zones – Share key files (/usr, /lib) with global zone. Default zone type.
    2. Whole Root Zones – Require more storage

### Global Zones ###
  1. Solaris ALWAYS boots to the global zone
  2. Knows about ALL hardware devices attached to the system
  3. Knows about ALL non-global zones

### Non-Global Zones ###
  1. Installed at a location on the file system of the Global zone ‘zone root path’ - /export/home/zones/{zone1,zone2,zone3,…}
  2. Share packages with the global zone
  3. Manage distinct hostname and tables files
  4. Cannot communicate with other non-global zones by default. Use standard tcpip
  5. GLOBAL zone admin can delegate non-global zone administration
  6. Requirements: hostname, zone rootpath, IP address,

### Zone Configuration ###

Commands:
zonename      Lists current zone name
zonecfg         Configure zones. Can run interactively, non-interactively, command-file modes
zlogin            To open the console fo zones
zoneadm       To administrate the zones


Steps for configuring non-global zone:
1.       mkdir /export/home/zones/testzone1 && chmod 700 /export/home/zones
2.       zonecfg –z testzone1
zonecfg:testzone1> create
zonecfg:testzone1> set zonepath=/export/home/sonez/testzone1
zonecfg:testzone1> add net
zonecfg:testzone1:net> set address=192.168.1.60
zonecfg:testzone1:net> set physical=e1000g0
zonecfg:testzone1:net> end
zonecfg:testzone1> info
zonecfg:testzone1> set autoboot=true    (OPTION)
zonecfg:testzone1> add attr                     (OPTION)
zonecfg:testzone1:attr> set name=comment
zonecfg:testzone1:attr> set type=string
zonecfg:testzone1:attr> set value=”TestZone1”
zonecfg:testzone1:attr> end
zonecfg:testzone1> verify
zonecfg:testzone1> commit
zonecfg:testzone1> exit

Other Commands:

1. To show details of a zone :
# zonecfg –x testzone1 info    

2. To install a zone :
# zoneadm –z testzone1 install

3. To view the state of the zones :  
# zoneadm list –iv

4. ReBoot the non-global zone :  
# zoneadm –x testzone1 boot|reboot

5. Login to console mode :
# zlogin –C testzone1

6. Login Interactively :                    
# zlogin –l username zonename

7. Login Non-Interactive :               
# zlogin options zonename

8. Safe mode Login : 
# zlogin –S zonename

NTP in Solaris

Configuration File :

/etc/inet/ntp.conf
server 192.168.2.1 version 3
server 192.168.2.2 version 3

Daemon :
/usr/lib/inet/xntpd - Normally called as xntpd

Commands :
1. To start ntp service :
# svcadm enable network/ntp

2. To stop ntp service :
# svcadm disable network/ntp

3. To synchronize date and time from another system :
# rdate server_name