Showing posts with label Solaris. Show all posts
Showing posts with label Solaris. Show all posts

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

NFS in Solaris

Configuration Files (along with a sampel content):

/etc/dfs/dfstab
       share -F nfs -o rw /data
       share -F nfs -o ro=-client1:.max.com /export/share/man

/etc/default/fs        -  Lists the default file system type for local file systems
/etc/dfs/fstypes      -  Lists the default file system types for remote file systems
/etc/default/nfs       -  Lists the lockd and nfsd configuration details

/etc/default/nfslogd - Lists the nfslogd configuration details
/etc/mnttab            -  Lists the file systems currently mounted
/etc/rmtab              - Lists the filesystems (shares) currently mounted by the clients

Daemons :

automountd - Used by Autofs
lockd          - Used for file locking purposes
mountd       - Handles mount requests from the clients
nfsd            - Main NFS server daemon which handled the client requets
nfslogd       - Handles operational logging

Commands:

1. To share all the filesystems as defined in /etc/dfs/dfstab file
# shareall

2. To view the currently shared filesystems :
# share

3. To start the NFS server services :
# svcadm enable network/nfs/server

4. To mount a share as read only in a nfs client :

# mount -F nfs -o ro server10:/oracle /data/oracle

5. To start auto fs :
# svcadm enable system/filesystem/autofs

6. To check if NFS server service is running on the server :
# svcs network/nfs/server

7. To check nfs services on a server from a client machine :
# rpcinfo -s nfsserver| egrep 'nfs|mountd'

8. To list the file systems shared by a server from a client machine :
# showmount -e servername
# dfshares servername

9. To list the shares currently mounted by the clients :
# dfmounts

System Dump (Crash) Management in Solaris

dumpadm

User and Group Administration in Solaris

Configuration Files (and their contents) :

/etc/passwd :
UserName:x:UID:GID:comment:home_directory:login_shell

/etc/shadow :
UserName:password:lastchg:min:max:warn:inactive:expire:

/etc/group :
GroupName:group-password:GID:Username-list

/etc/default/password :

MAXWEEKS=
MINWEEKS=
PASSLENGTH=6
#MINDIFF=3
#MINALPHA=2
#MINNONALPHA=1
#MINUPPER=0
#MINLOWER=0
#MAXREPEATS=0
#MINSPECIAL=0
#MINDIGIT=0
#WHITESPACE=YES

/etc/security/policy.conf :
#LOCK_AFTER_RETRIES=NO

System-Wide Initialization Files:
Korn Shell     : /etc/profile
Bourne Shell  : /etc/profile
Bash Shell      : /etc/profile
C Shell          : /etc/.login

User Initialization Files:
Korn Shell     : $HOME/.profile, $HOME/.kshrc
Bourne Shell  : $HOME/.profile
Bash Shell      : $HOME/.profile
C Shell           : $HOME/.cshrc, $HOME/.login

Skeleton(Template) files for User Intialization Files :
Korn Shell     : /etc/skel/local.profile
Bourne Shell  : /etc/skel/local.profile
Bash Shell      : /etc/skel/local.profile
C Shell           : /etc/skel/local.cshrc and /etc/skel/local.login


Commands :

1. To add a user : (user any of the below commands)
# useradd -u 102 -g dba -d /export/home/jack -m -s /bin/bash -c "Jack Smith" jack

# smuser add -- -n jack -u 102 -g dba -d /export/home/jack -s /bin/bash -c "Jack Smith" -x

2. To modify a user's shell:
# usermod -s /bin/ksh jack

3. To modify a user's login name:
# usermod -l jsmith jack
# smuser modify -- -n jack -N jsmith

4. To delete a user :
# userdel jsmith
# smuser delete -- -n jack

5. To delete a user along with his/her home directory:
# userdel -r jsmith

6. To create a group :
# groupadd -g 402 dba
# smgroup add -- -n dba -g 402  -m jack

7. To modify a group's property :
# groupmod -g 410 dba
# smgroup modify -- -n dba -g 410

8. To delete a group :
# groupdel dba
# smgroup delete -- -n dba

9. To list all the users :
# listusers

10. To list the currently logged in users :
# who

11. To list last login report :
# last

12. To list all the users logged in the local and remote hosts :
# rusers -l

13. To display user information :
# finger jack

14. To record failed logins :
# touch /var/adm/loginlog
# chown root.sys /var/adm/loginlog
# chmod 600 /var/adm/loginlog


15. To prohibit a user from using ftp.

Add him in /etc/ftpd/ftpusers file.

16. To enable password-less login from remote servers :
Add the hsotname and username in the below format to /etc/hosts.equiv or $HOME/.rhosts file

hostname
hostname username
+

17. To list the groups the current user belongs to :
# groups

18. To list the groups an user belongs to :
# groups jack

19. To list the uid, gid of the current user :
# id

20. To display the uid and Primary gid of a user :
# id jack

21. To display the uid and Primary as well as secondary gids of a user :
# id -a jack

Managing Services in Solaris

This post is mainly based on SMF facility in Solaris 10. But also contains few commands for older versions.

Points to remember about run levels / milestones :

Runlevels are used in Solaris 9 to describe the set of services. "who -r" tells you which level you're in.

Starting from Solaris version 10, runlevels are replaced by milestones.

Run Levels in Solaris 8/9 :
S : Single user state (useful for recovery)
0 : Access Sun Firmware ( ok> prompt)
1 : System administrator mode
2 : Multi-user w/o NFS
3 : Multi-user with NFS
4 : Unused
5 : Completely shutdown the host (like performing a power-off @ OBP) [ thanks to Marco
6 : Reboot but depend upon initdefault entry in /etc/inittab

Different milestones in Solaris 10 :
single-user           : Single User Mode
multi-user             : Multi-User with/o NFS
multi-user-server  : Multi-User with/o NFS
all                        :  Starts all the services
none                    :  Doe not start any services. Normally used for troubleshooting purposes.

Different states of services in SMF:
online                 : Service instance enabled and running.
offline                 : Service instance enabled, but not running due to some fault.
disabled             : Service instace is disabled and not running.
maintenance       : Service instance encountered an error, troubleshooting is required.
legacy_run         : Legacy service (controlled by /etc/rcx.net scripts).
                            SMF can only monitor this service, but  can't control it.
degraded           : Service instance enabled but running at limited capacity.
uninitialized        : This is the initial stat for all services before their configuration has been read.

Commands :

1. To list all the services and their status :
# svcs -a

2. To stop SSH service :
# svcadm disable -t network/ssh:default      <--- Solaris 10
# /etc/init.d/sshd stop                      <--- Solaris 9

3. To start SSH service :
# svcadm enable -t network/ssh:default       <--- Solaris 10

# /etc/init.d/sshd start                    <--- Solaris 9

4. To refresh SSH service :

# svcadm refresh -t network/ssh:default      <--- Solaris 10

# ps -ef | grep ssh
# kill -HUP pid                            
<--- Solaris 9 

5. To restart SSH service :

# svcadm restart -t network/ssh:default     <--- Solaris 10

# /etc/init.d/sshd stop                  
# /etc/init.d/sshd start                    <--- Solaris 9 

6. To find out what went wrong or the reason behind a service shutdown :
# svcs -x

7. To find out the dependents of a failed service :
# svcs -x -v

8. To find out the status and PID of a service :
# svcs -p network/smtp:sendmail

9. To find out the dependent services :
# svcs -d milestone/multi-user:default

10. To show on what service, the current service depends on :
# svcs -D network/smtp:sendmail

11. To view the detailed status of a service :
# svcs -v network/smtp:sendmail

12. To view the details of a service :
# svcs -l network/smtp:sendmail

13. To list all the internet services :
# inetadm

Note:
/etc/inet/inetd.conf is not used in Solaris 10.

14. To enable a internet service :
# inetadm -e network/telnet

15. To disable a internet service :
# inetadm -d network/telnet

16. To show the details of telnet service :
# inetadm -l network/telnet

17. To modify a property of ftp service :
# inetadm -m network/ftp exec="/usr/sbin/in.ftpd -l"


18. To change the default milestone (run level) :
# svcadm milestone -d milestone/single-user:default
In solaris 9, you have to change it in /etc/inittab.

19. To go to a milestone (run level) :

# svcadm milestone milestone/single-user:default

In solaris 9, # init 1

20. To boot a machine in single user mode from OK prompt :
ok> boot -m milestone=single-user

21. To boot a machine in multi user mode from OK prompt :
ok> boot -m milestone=multi-user

22. To restore SMF repository :
# /lib/svc/bin/restore_repository

23. Daemon that controls SMF :
While booting the system, svc.startd gets started via /etc/inittab and it starts the services based on the milestone selected.

Wednesday, December 15, 2010

Managing HBA adapter in Sun Servers


How to view the HBA controllers ?

You can use any of the below commands

# /usr/sbin/lpfc/lputil
# vxdmpadm listctlr all
# cfgadm -al

How to reset a HBA ?

Method 1:
# /usr/sbin/hbanyware/hbacmd Reset 10:01:00:00:bc:c9:3b:ca

Method 2:
# /usr/sbin/lputil/lputil
LightPulse Common Utility for Solaris/SPARC. Version 2.0a5 (4/7/2005).
Copyright (c) 2005, Emulex Corporation

Emulex Fibre Channel Host Adapters Detected: 3
Host Adapter 0 (lpfc3) is an LP9802 (Ready Mode)
Host Adapter 1 (lpfc4) is an LP9802 (Ready Mode)
Host Adapter 2 (lpfc5) is an LP9802 (Ready Mode)

MAIN MENU

1. List Adapters
2. Adapter Information
3. Firmware Maintenance
4. Reset Adapter
5. Persistent Bindings

0. Exit

Enter choice => 4
0. lpfc3
1. lpfc4
2. lpfc5

Select an adapter => 0

MAIN MENU

1. List Adapters
2. Adapter Information
3. Firmware Maintenance
4. Reset Adapter
5. Persistent Bindings

0. Exit

Enter choice => 0

Once the adaptor is reset, you should see a message similar to the following in the system logfile:

lpfc: [ID 728700 kern.warning] WARNING: lpfc3:1303:LKe:Link Up Event x1 received Data: x1 x0 x8 x14

Emulex makes a killer HBA, and provides several awesome software utilities to manage host side SAN connectivity.


Some Commands :

1. To view ports :
# luxadm -e port
# cfgadm -o show_FCP_dev -al

2. To view detailed information of a LUN :
# luxadm diplay /dev/rdsk/c2t2d12s2

3. To scan for new luns in a HBA :
# luxadm -e forcelip /devices/pci@8,700000/SUNW,qlc@2/fp@0,0:devctl

4. To show all devices :
# luxadm probe

5. To display all the HBA:
# fcinfo hba-port

6. To display WWN for each HBA
# /usr/sbin/lpfc/lputil listhbas

7. To list info about HBA :
# prtpicl -v -c scsi-fcp
# prtpicl -v -c scsi-fcp | grep port-wwn
# prtpicl -v -c scsi-fcp | grep devfs-path

8.  To see if the Qlogic driver is loaded :
# modinfo | grep qlc

9. To see if QLogic driver is configured to load on boot :
# grep qlc /etc/system
forceload: drv/qlc

10. To see the number of HBA instances/devices :
# prtdiag -v | grep qlc

Device Management in Solaris

Associated Directories:

/dev - Contains logical device files
/devices - Contains physical device files

Commands :

1. To clean up the files for non-existent devices :
# devfsadm -C

2. To clean up the files for non-existent tape drive devices with detailed output :
# devfsadm -C -c tape -v

3. To scan for new devices :
# devfsadm

4. To scan for new disk drive :
# devfsadm -c disk

5. How to do a reconfigure reboot for connecting a new device :

Option 1:
# touch /reconfigure
# sync;sync;sync
# shutdown -y -i 0
# connect the new devce
# Boot the server

Option 2:
# shutdown -i -i 0
# Connect the new device
# "boot -r" from OK prompt

Option 3:
# reboot -- -r

System Information in Solaris

1. To view the timezone:

 # grep '^TZ' /etc/TIMEZONE

2. To change the timezone :

a. Check for the available timezones :
# cat /usr/share/lib/zoneinfo

b. Set the timezone by modifying the TZ= line in /etc/TIMEZONE file

c. Reboot the machine :
# shutdown -y -i 0

3. To display processor information :
# psrinfo -v

4. To enable a processor of id 0 :
# psradm -f 0

5. To enable it :
# psradm -n 0

6. To display RAM size :
# prtconf | grep Memory

7. To display processor bits :
# isainfo -bv

8. To display kernel bits :
# isainfo -kv

9. To determine the current boot device :

a. Find the boot path of the device
# prtconf -vp | grep bootpath
bootpath: '/pci@1f,700000/scsi@2/disk@0,0:a'

b. Find the device name using the boot path (replace 'disk' with 'sd')
# ls -l /dev/dsk | grep "/pci@1f,700000/scsi@2/sd@0,0:a"
lrwxrwxrwx 1 root root 43 Dec 13 2006 c1t1d0s0 -> ../../devices/pci@1f,700000/scsi@2/sd@0,0:a

10. To display the values of environment values :
# env

11. To find the architecture of the server
# arch -k

returns sun4u in Ultra 5 System and sun4m in SPARC system.

12. To display general system information :
# showrev -a

13. To display host id :
# hostid

14. To display the solaris release version details :
# cat /etc/release

15. To display system name and model :
# prtconf -b

16. To display system name, model, prom version :
# prtconf -vb

17. To dispaly the currently installed locales :
# localeadm -l

18. To determine if a locale is installed in the system :
# localeadm -q ja

19. To install a locale :
# localeadm -a ja -d /mnt/install/latest/Solaris/Product

20. To remove an installed locale :
# localeadm -r ja

Patch Management in Solaris

Associated Directory :
/var/sadm/patch            Contains the list of applied patches

Commands :

1. To install a patch :
# patchadd 123456-78   

2. To find out if a patch has been already installed :
# showrev –p | grep 123456-78

3. To uninstall a patch :
# patchrm 123456-78

4. To display all patches applied to the system :
# patchadd –p

5. Installs the recommended patch cluster :
# install_cluster –q –nosave

Software (Package) Management in Solaris

Files involved:
/var/sadm/install/contents    - Contains the list of installed packages

Commands:

1. To install all packages available in the cdrom :
# pkgadd –d /cdrom/cdrom       

2. To install a specific package from the /mnt directory :
# pkgadd –d /mnt SUNWaudio   

3. To copy a package from the /mnt directory to spool :
# pkgadd –d /mnt –s SUNWaudio   

4. To list the contents of spool directory :
# pkginfo –d spooldir       

5. To find out the package “abc” in the installed package list :
# pkginfo | grep abc       

6. To list detailed info on an installed package :
# pkginfo –l SUNWcar       

7. To check the consistency of a package :
# pkgchk –v SUNWaudio       

8.To find out which package a file belongs to :
# pkgchk -l -p /usr/bin/ls       

9. To uninstall a package :
# pkgrm SUNWaudio       

10.Removes a package from a spool directory :
# pkgrm –s spooldir SUNWcar

Open Boot PROM Commands in Sun Servers

1. To display all the current device aliases :
ok> devalias

2. To define an alias ofr a device path :
ok> devalias alias device-path

3. To delete an alias from NVRAMRC :
ok> nvunalias alias           

4. To list the available disks :
ok> show-disks

5. To boot from default boot device :
ok> boot       

6. To boot from cdrom :
ok> boot cdrom   

7. To boot from the alia "disk" :
ok> boot disk           

8. To boot from network :
ok> boot net       

9. To start jumpstart boot :
ok> boot net – install

10. To do an interactive boot from the default boot device :
ok> boot –a   

11. To do a reconfigure boot from the default boot device :
ok> boot –r       

12. To boot from 32bit kernel :
ok> boot kernel/unix   

13. To boot from 64bit kernerl :
ok> boot kernel/sparcv9/unix   

14. To do a verbose boot :
ok> boot –v    

15. To boot in single user mode :
ok> boot –s   

15. To diplay OBP verion :
ok> .version       

16. To display ethernet address :
ok> .enet-addr       

17. To diplay poweron banner :
ok> banner               

18. To display processor and bus speeds :
ok> .speed               

19. To display major/minor CPU firmware version :
ok> firmware-version           

20. To call OS to write information to harddisk :
ok> sync               

Normally we do it thrice. ie., sync;sync;sync

21. To reset entire system :
ok> reset       

22. To reset entire system :       
ok> reset-all       

23. To reset all PROM setting to factory default :
ok> set-defaults           

24. To set PROM password :
ok> setenv security –password password

25. To set autoboot :
ok> setenv auto-boot? true       

26. To display the current boot-device :
ok> printenv boot-device       

27. To identify devices attached to a SCSI bus :
ok> probe-scsi           

28. To identify devices attached to all SCSI buses :
ok> probe-scsi-all           

29. To test the primary network adapter :
ok> test net               

30. To test the primary scsi adapter :
ok> test scsi               

31. To test all devices available with self test capability :
ok> test-all