Monday, May 13, 2013

netstat

netstat

netstat provides useful information regarding traffic flow.

In particular, netstat -i lists statistics for each interface, netstat -s provides a full listing of several counters, and netstat -rs provides routing table statistics. netstat -an reports all open ports.

netstat -k provides a useful summary of several network-related statistics up through Solaris 9, but this option was removed in Solaris 10 in favor of the /bin/kstat command. Through Solaris 9, netstat -k provides a listing of several component kstat statistics.

Here are some of the issues that can be revealed with netstat:

  • netstat -i: (Collis+Ierrs+Oerrs)/(Ipkts+Opkts) > 2%: This may indicate a network hardware issue.

  • netstat -i: (Collis/Opkts) > 10%: The interface is overloaded. Traffic will need to be reduced or redistributed to other interfaces or servers.

  • netstat -i: (Ierrs/Ipkts) > 25%: Packets are probably being dropped by the host, indicating an overloaded network (and/or server). Retransmissions can be dropped by reducing the rsize and wsize mount parameters to 2048 on the clients. Note that this is a temporary workaround, since this has the net effect of reducing maximum NFS throughput on the segment.

  • netstat -s: If significant numbers of packets arrive with bad headers, bad data length or bad checksums, check the network hardware.

  • netstat -i: If there are more than 120 collisions/second, the network is overloaded. See the suggestions above.

  • netstat -i: If the sum of input and output packets is higher than about 600 for a 10Mbs interface or 6000 for a 100Mbs interface, the network segment is too busy. See the suggestions above.
  • netstat -r: This form of the command provides the routing table. Make sure that the routes are as you expect them to be.

Sunday, May 12, 2013

Happy Mother's Day!

mpstat

mpstat

mpstat reports information which is useful in understanding lock contention and CPU loading issues.

mpstat reports the following:

  • CPU: Processor ID
  • minf: Minor faults
  • mjf: Major faults
  • xcal: Processor cross-calls (when one CPU wakes up another by interrupting it). If this exceeds 200/second, the application in question may need to be examined.
  • intr: Interrupts.
  • ithr: Interrupts as threads (except clock).
  • csw: Context switches
  • icsw: Involuntary context switches (this is probably the more relevant statistic when examining performance issues.)
  • migr: Thread migrations to another processor. If the migr measurement of mpstat is greater than 500, rechoose_interval should be sent longer in the kernel.
  • smtx: Number of times a CPU failed to obtain a mutex.
  • srw: Number of times a CPU failed to obtain a read/write lock on the first try.
  • syscl: Number of system calls.
  • usr/sys/wt/idl: User/system/wait/idle CPU percentages.

Saturday, May 11, 2013

UFS File System Troubleshooting

Filesystem corruption can be detected and often repaired by the format and fsck commands. If the filesystem corruption is not due to an improper system shutdown, the hard drive hardware may need to be replaced.

ufs filesystems contain the following types of blocks:

  • boot block: This stores information used to boot the system.
  • superblock: Much of the filesystems internal information is stored in these.
  • inode: Stores location information about a file--everything except for the file name. The number of inodes in a filesystem can be changed from the default if newfs -i is used to create the filesystem.
  • data block: The file's data is stored in these.

fsck

The fsck command is run on each filesystem at boot time. This utility checks the internal consistency of the filesystem, and can make simple repairs on its own. More complex repairs require feedback from the root user, either in terms of a "y" keyboard response to queries, or invocation with the -y option.

If fsck cannot determine where a file belongs, the file may be renamed to its inode number and placed in the filesystem's lost+found directory. If a file is missing after a noisy fsck session, it may still be intact in the lost+found directory.

Sometimes the fsck command complains that it cannot find the superblock. Alternative superblock locations were created by newfs at the time that the filesystem was created. The newfs -N command can be invoked to nondestructively discover the superblock locations for the filesystem.

ufs filesystems can carry "state flags" that have the value of fsclean, fsstable, fsactive or fsbad (unknown). These can be used by fsck during boot time to skip past filesystems that are believed to be okay.

format

The analyze option of format can be used to examine the hard drive for flaws in a nondestructive fashion.

df

df can be used to check a filesystem's available space. Of particular interest is df -kl, which checks available space for all local filesystems and prints out the statistics in kilobytes. Solaris 10 also allows us to use df -h, which presents the statistics in a more human-friendly form that doesn't require counting digits to decide whether a file is 100M or 1G in size.

du

du can be used to check space used by a directory. In particular, du -dsk will report useage in kilobytes of a directory and its descendants, without including space totals from other filesystems.

Filesystem Tuning

Filesystem performance can be improved by looking at filesystem caching issues.

The following tuning parameters may be valuable in tuning filesystem performance with tunefs or mkfs/newfs:

  • inode count: The default is based upon an assumption of average file sizes of 2 KB. This can be set with mkfs/newfs at the time of filesystem creation.
  • time/space optimization: Optimization can be set to allow for fastest performance or most efficient space useage.
  • minfree: In Solaris 2.6+, this is set to (64 MB / filesystem size) x 100. Filesystems in earlier OS versions reserved 10%. This parameter specifies how much space is to be left empty in order to preserve filesystem performance.
  • maxbpg: This is the maximum number of blocks a file can leave in a single cylinder group. Increasing this limit can improve large file performance, but may have a negative impact on small file performance.

Filesystem Performance Monitoring

McDougall, Mauro and Gregg suggest that the best way to see if I/O is a problem at all is to look at the amount of time spent on POSIX read() and write() system calls via DTrace. If so, we need to look at the raw disk I/O performance.

Friday, May 10, 2013

dtrace

DTrace Introduction

DTrace is Solaris 10's Dynamic Tracing facility. It allows us to peer into the innards of running processes and customize our view to exclude extraneous information and close in on the source of a problem.

DTrace also has capabilities that allow us to examine a crash dump or trace the boot process.

A number of freely available scripts have been made available as the DTrace Toolkit. The toolkit provides both programming examples and also extremely useful tools for different types of system monitoring.

The DTrace facility provides data to a number of consumers, including commands such as dtrace and lockstat, as well as programs calling libraries that access DTrace through the dtrace kernel driver.

Probes

DTrace is built on a foundation of objects called probes. Probes are event handlers that fire when their particular event occurs. DTrace can bind a particular action to the probe to make use of the information.

Probes report on a variety of information about their event. For example, a probe for a kernel function may report on arguments, global variables, timestamps, stack traces, currently running processes or the thread that called the function.

Kernel modules that enable probes are packaged into sets known as providers. In a DTrace context, a module is a kernel module (for kernel probes) or a library name (for applications). A function in DTrace refers to the function associated with a probe, if it belongs to a program location.

Probes may be uniquely addressed by a combination of the provider, module, function and name. These are frequently organized into a 4-tuple when invoked by the dtrace command.

Alternatively, each probe has a unique integer identifier, which can vary depending on Solaris patch level.

These numbers, as well as the provider, module, function and name, can be listed out through the dtrace -l command. The list will vary from system to system, depending on what is installed. Probes can be listed by function, module or name by specifying it with the -f, -m or -n options, respectively.

Running a dtrace without a -l, but with a -f, -m or -n option, enables all matching probes. All the probes in a provider can be enabled by using the -P option. An individual probe can be enabled by using its 4-tuple with the -n option.

(Note: Do not enable more probes than necessary. If too many probes are enabled, it may adversely impact performance. This is particularly true of sched probes.)

Some probes do not list a module or function. These are called "unanchored" probes. Their 4-tuple just omits the nonexistent information.

Providers

Providers are kernel modules that create related groups of probes. The most commonly referenced providers are:

  • fbt: (Function Boundary Tracing) Implements probes at the entry and return points of almost all kernel functions.
  • io: Implements probes for I/O-related events.
  • pid: Implements probes for user-level processes at entry, return and instruction.
  • proc: Implements probes for process creation and life-cycle events.
  • profile: Implements timer-driven probes.
  • sched: Implements probes for scheduling-related events.
  • sdt: (Statistically Defined Tracing) Implements programmer-defined probes at arbitrary locations and names within code. Obviously, the programmer should define names whose meaning is intuitively clear.
  • syscall: Implements entry and return probes for all system calls.
  • sysinfo: Probes for updates to the sys kstat.
  • vminfo: Probes for updates to the vm kstat.

Command Components

The dtrace command has several components:

  • A 4-tuple identifier:
    provider:module :function:name
    Leaving any of these blank is equivalent to using a wildcard match. (If left blank, the left-most members of the 4-tuple are optional.)
  • A predicate determines whether the action should be taken. They are enclosed in slashes: /predicate/. The predicate is a C-style relational expression which must evaluate to an integer or pointer. If omitted, the action is executed when the probe fires. Some predicate examples are:
    • executable name matches csh:
      /execname == "csh"/
    • process ID does not match 1234:
      /pid != 1234/
    • arg0 is 1 and arg1 is not 0:
      /arg0 == 1 && arg1 !=0/
  • An action (in the D scripting language) to be taken when the probe fires and the predicate is satisfied. Typically, this is listed in curly brackets: {}

Several command examples are provided at the bottom of the page.

D Scripting Language

In order to deal with operations that can become confusing on a single command line, a D script can be saved to a file and run as desired. A D script will have one or more probe clauses, which consist of one or more probe-descriptions, along with the associated predicates and actions:

#!/usr/sbin/dtrace -s
probe-description[, probe-description...]
/predicate/
{
action; [action; ...]
}

The probe-description section consists of one or more 4-tuple identifiers. If the predicate line is not present, it is the same as a predicate that is always true. The action(s) specified are to be run if the probe fires and the predicate is true.

Each recording action dumps data to a trace buffer. By default, this is the principal buffer.

Several programming examples are provided at the bottom of the page.

D Variables

D specifies both associative arrays and scalar variables. Storage for these variables is not pre-allocated. It is allocated when a non-zero value is assigned and deallocated when a zero value is assigned.

D defines several built-in variables, which are frequently used in creating predicates and actions. The most commonly used built-in variables for D are the following:

  • args[]: The args[] array contains the arguments, specified from 0 to the number of arguments less one. These can also be specified by argn, where this is the n+1th argument.
  • curpsinfo: psinfo structure of current process.
  • curthread: pointer to the current thread's kthread_t
  • execname: Current executable name
  • pid: Current process ID
  • ppid: Parent process ID
  • probefunc: function name of the current probe
  • probemod: module name of the current probe
  • probename: name of the current probe
  • timestamp: Time since boot in ns

Variable scope can be global, thread-local or clause-local.

Thread-local variables allow separate storage for each thread's copy of that variable. They are referenced with names of the form:
self->variable-name

Associative arrays can be indexed by an arbitrary name. There is no pre-defined limit on the number of elements.

Scalar variables hold a single data value.

We can also access Solaris kernel symbols by specifying them in backquotes.

Providers define arguments based on their own requirements. Some of the more useful such arguments are listed below:

Provider-Specific Variables
io
arg[0] Pointer to a bufinfo structure.
arg[0]->b_bcount Byte count.
arg[0]->b_resid Bytes not transferred.
arg[0]->b_iodone I/O completion routine.
arg[0]->b_edev Extended device.
arg[1] Pointer to a devinfo structure.
arg[1]->dev_major Major number.
arg[1]->dev_minor Minor number.
arg[1]->dev_instance Instance number.
arg[1]->dev_name Device name.
arg[1]->dev_pathname Device pathname.
arg[2] Pointer to a fileinfo structure.
arg[2]->fi_name File name.
arg[2]->fi_dirname File directory location.
arg[2]->fi_pathname Full path to file.
arg[2]->fi_offset Offset within a file.
arg[2]->fi_fs Filesystem.
arg[2]->fi_mount Filesystem mount point.
pid
arg0-argn (entry) For entry probes, arg0-argn represent the arguments.
arg0-arg1 (return) For return probles, arg0-arg1 represent the return codes.
syscall
arg0-argn (entry) For entry probes, arg0-argn represent the arguments.
arg0-arg1 (return) For return probles, arg0-arg1 represent the return codes.
sysinfo
arg0 Value of statistic increment
arg1 Pointer to the current value of the statistic before increment.
arg2 Pointer to the cpu_t structure incrementing the statistic. Defined in sys/cpuvar.h
vminfo
arg0 Value of statistic increment
arg1 Pointer to the current value of the statistic before increment.
The full list for each provider can be found in the provider's chapter of the Solaris Dynamic Tracing Guide.

Actions

The most commonly used built-in actions are:

  • breakpoint(): System stops and transfers control to kernel debugger.
  • chill(number-nanoseconds): DTrace spins for the specified number of nanoseconds.
  • copyinstr(pointer): Returns null terminated string from address space referenced by pointer.
  • copyout(buffer, address, number-bytes): Copies number-bytes from the buffer to a memory address.
  • copyoutstr(string, address, max-length): Copies a string to a memory address.
  • normalize(aggregation, normalization-factor): Divides aggregation values by the normalization-factor.
  • panic(): Panics the kernel; may be used to generate a core dump.
  • printf(format, arguments): Dumps the arguments to the buffer in the specified format. printa(aggregation) does the same thing for aggregation data.
  • raise(signal): Sends the signal to the current process.
  • stack(number-frames): Copies the specified number of frames of the kernel thread's stack to the buffer.
  • stop(): Stops the process that fired the probe.
  • stringof(): Converts values to DTrace string values.
  • system(command): Runs a program as if from the shell.
  • trace(D-expression): Dumps the output of D-expression to the trace buffer.
  • tracemem(address, size_t number-bytes): Dumps the contents from the memory address to the buffer.
  • trunc(aggregation): Truncates or removes the contents of the specified aggregation.
  • ustack(number-frames): Copies the specified number of frames of the user stack to the buffer.

Multiple actions in a probe clause can be combined using a semicolon between them inside the curly brackets.

Aggregations

Aggregating functions allow multiple data points to be combined and reported. Aggregations take the form:
@name[ keys ] = aggregating-function( arguments );
Here, the name is a name assigned to the aggregation, the keys are a comma-separated list of D expressions which index the output, the arguments are a comma-separated list and the aggregating functions may be one of the following:

  • avg: Average of the expressions in the arguments.
  • count: Number of times that the function is called.
  • lquantize: The arguments are a scalar expression, a lower bound, an upper bound and a step value. This function increments the value in the highest linearly-sized bucket that is less than the expression.
  • max: The largest value among the arguments.
  • min: The smallest value among the arguments.
  • quantize: Increments the value in the highest power of two bucket less than the expression in the argument.
  • sum: Total value of the expressions in the arguments.

Directives

Directives provide options to a D script that can increase readability of the output. Each option is enabled by including a line like the following at the beginning of a D script:
#pragma D option option-name

The following are the most commonly-used directives.

  • flowindent: Indentation increased on function entry; decreased on function return.
  • quiet: Don't print anything not explicitly specified.

Examples

To report on each active PID for the readch function:
dtrace -n 'readch {trace(pid)}'

To report on each system call's entry time:
dtrace -n 'syscall:::entry {trace(timestamp)}'

Tracing executable names (stored on a UFS filesystem):
dtrace -m 'ufs {trace(execname)}'

To print all functions from libc for process 123:
dtrace -n 'pid123:libc::entry'

To count the occurrences of each libc function for PID 123:

#!/usr/sbin/dtrace -s
pid123:libc::entry
{
@function_count[probefunc]=count();
}
(Once this script is stopped with control-c, the results will be printed out.)

To identify how much time is spent in each function, we would add a probe-clause as follows. In the below, the timestmp[] array stores the timestamps for each function as it is entered; the aggregation function_duration[] stores the sum total of durations for invocations of each function. Also note that the scope of the timestmp[] array is limited to a single thread to deal with the possibility of multiple concurrent copies of the same function:

#!/usr/sbin/dtrace -s
pid123:libc::entry
{
self->timestmp[probefunc] = timestmp;
}
pid123:libc::return
/self->timestmp[probefunc] != 0/
{
@function_duration[probefunc] = sum(timestmp - self->timestmp[probefunc]);
timestmp[probefunc] = 0;
}

The following script prints out the name of every program that calls the exec or exece system calls, as well as the name of the program being executed:

#!/usr/sbin/dtrace -s
syscall::exec*:entry
{
trace(execname);
trace(copyinstr(arg0));
}

While this script is straightforward, it may fail if arg0 has been written to disk as part of paging activity. (See Bennett, Part 2.) In that event, it may make more sense to use a variable to hold the pointer until return pulls any pointers back into memory. The below also uses printf to format the output and turn off default output with "quiet:"
#!/usr/sbin/dtrace -s
#pragma D option quiet
syscall::exec*:entry
{
self->prog = copyinstr(arg0);
self->exn = execname;
}
syscall::exec*:return
/ self->prog != NULL /
{
printf ("%-20s %s\n", self->exn, self->prog);
self->prog = 0;
self->exn = 0;
}

DTrace Toolkit

A number of freely available scripts have been made available as the DTrace Toolkit. The toolkit provides both programming examples and also extremely useful tools for different types of system monitoring.

DTrace Toolkit
Script Name Description
anonpgpid.d Attempts to identify which processes are suffering the most from a system that is hard swapping
bitesize.d Provides graphs of distributions of different I/O sizes
connections Displays server process that accepts each inbound TCP connection.
cputypes.d Reports on types of CPUs on the system.
cpuwalk.d Reports on which CPUs a process runs on.
cswstat.d Reports on context switches and time consumed.
dapptrace Traces user and library function usage. Similar to apptrace, but also gets elapsed and CPU times
dispqlen.d Measures dispatcher queue length (CPU saturation).
dnlcps.d Measures DNLC hits and misses by process.
dnlcsnoop.d Real time record of target, process and result of DNLC lookups.
dtruss truss replacement without the performance hit.
filebyproc.d Snoops files opened by process name.
fsrw.d Traces I/O events at a system call level.
hotspot.d Identifies disk "hot spots."
inttimes.d Reports on time spent servicing interrupts for each device.
iofile.d I/O wait times for each file by process.
iofileb.d I/O size for each file by process.
iopattern System-wide disk I/O usage patterns.
iosnoop Tracks system I/O activity.
iotop Displays processes with highest I/O traffic.
lockbydist.d Lock distribution by process.
lockbyproc.d Lock times by process.
nfswizard.d Identifies top NFS filename requests; reports on access and performance statistics.
opensnoop Snoops open files.
pfilestat I/O statistics for each file descriptor in a process.
priclass.d Reports distribution of thread priorites by class.
pridist.d Reports distribution of thread priorities by class.
procsystime Process system call details; elapsed time, CPU time, counts, etc.
rfileio.d Read size statistics from file systems and physical disks, along with a total miss rate for the file system cache.
rfsio Read size statistics from file systems and physical disks, along with a total miss rate for the file system cache.
rwsnoop Captures read/write activity, including identifying the source processes.
rwtop Displays processes with top read/write activity.
sampleproc Reports which process is on which CPU how much of the time.
seeksize.d Directly measure seek lengths of I/Os.
swapinfo.d Reports a summary of virtual memory use.
tcpstat.d Reports TCP error and traffic statistics.
tcpsnoop.d Snoops TCP packets and associates them with a port and a process.
tcptop Displays to TCP packet-generating processes.
threaded.d Measures effectiveness of thread utilization.
tcpsyscall Reports on busiest system calls.
udpstat.d Reports UDP error and traffic statistics.
vopstat Function-level timings of I/Os.
xcallsbypid.d Provides by-process cross-call information.
zvmstat Zone-specific vmstat.

Additional Resources

Thursday, May 09, 2013

iostat

iostat is the front-line command for examining disk performance issues. dtrace allows a more detailed examination of I/O operations.

As with most of the monitoring commands, the first line of iostat reflects a summary of statistics since boot time. To look at meaningful real-time data, run iostat with a time step (eg iostat 30) and look at the lines that report summaries over the time step intervals.

For Solaris 2.6 and later, use iostat -xPnce 30 to get information including the common device names of the disk partitions, CPU statistics, error statistics, and extended disk statistics.

For Solaris 2.5.1 and earlier, or for more compact output, use iostat -xc 30 to get the extended disk and CPU statistics.

In either case, the information reported is:

  • disk: Disk device name.
  • r/s, w/s: Average reads/writes per second.
  • Kr/s, Kw/s: Average Kb read/written per second.
  • wait: Time spent by a process while waiting for block
  • (eg disk) I/O to complete. (See Notes on Odd Behavior below.)
  • actv: Number of active requests in the hardware queue.
  • %w: Occupancy of the wait queue.
  • %b: Occupancy of the active queue with the device busy.
  • svc_t: Service time (ms). Includes everything: wait time, active queue time, seek rotation, transfer time.
  • us/sy: User/system CPU time (%).
  • wt: Wait for I/O (%).
  • id: Idle time (%).

Notes on Odd Behavior

The "wait" time reported by iostat refers to time spent by a process while waiting for block device (such as disk) I/O to finish. In Solaris 2.6 and earlier, the calculation algorithm sometimes overstates the problem on multi-processor machines, since it does not take into account that an I/O wait on one CPU does not mean that I/O is blocked for processes on the other CPUs. Solaris 7 has corrected this problem.

iostat also sometimes reports excessive svc_t (service time) readings for disks that are very inactive. This is due to the action of fsflush keeping the data in memory and on the disk up-to-date. Since many writes are specified over a very short period of time to random parts of the disk, a queue forms briefly, and the average service time goes up. svc_t should only be taken seriously on a disk that is showing 5% or more activity.

Wednesday, May 08, 2013

truss

truss traces library and system calls and signal activity for a given process. This can be very useful in seein where a program is choking.

In order to be able to use truss output, it is important to understand some basic vocabulary:

  • brk() requests memory during execution.
  • exec() opens a program.
  • fcntl() performs control functions on open files.
  • fstat() obtains information about open files.
  • getdents64() reads directory information.
  • ioctl() performs terminal I/O.
  • lstat() obtains file attributes.
  • mmap() maps the program image into memory.
  • open() opens a file. It returns a number which is referenced when the file is used.
  • write() writes to an open file/device.

Obviously, this is only a subset of the system calls seen in truss output, but this subset is usually sufficient to figure out what is going on. Other system calls can be looked up in the vendor web pages or man pages.

In most cases we will be looking for error messages in the truss output. These entries will contain the string "Err" in the last column of the output.

These errors can be categorized as system call errors or missing file errors. Many missing file errors are the result of a library not being in a directory early in the LD_LIBRARY_PATH or something of the sort. If the truss output shows a successful open() (or whatever) of the file name later in the process, that is probably not your culprit.

System call errors can be interpreted by looking at the man page of the specific system call or examining the file /usr/include/sys/errno.h.

Sometimes you need more information than truss offers. Dtrace offers a finer-grained method for examining every aspect of a process's functioning.

Tuesday, May 07, 2013

Sun Cluster

Sun Cluster

Introduction

Sun Cluster 3.2 has the following features and limitations:

  • Support for 2-16 nodes.
  • Global device capability--devices can be shared across the cluster.
  • Global file system --allows a file system to be accessed simultaneously by all cluster nodes.
  • Tight implementation with Solaris--The cluster framework services have been implemented in the kernel.
  • Application agent support.
  • Tight integration with zones.
  • Each node must run the same revision and update of the Solaris OS.
  • Two node clusters must have at least one quorum device.
  • Each cluster needs at least two separate private networks. (Supported hardware, such as ce and bge may use tagged VLANs to run private and public networks on the same physical connection.)
  • Each node's boot disk should include a 500M partition mounted at /globaldevices prior to cluster installation. At least 750M of swap is also required.
  • Attached storage must be multiply connected to the nodes.
  • ZFS is a supported file system and volume manager. Veritas Volume Manager (VxVM) and Solaris Volume Manager (SVM) are also supported volume managers.
  • Veritas multipathing (vxdmp) is not supported. Since vxdmp must be enabled for current VxVM versions, it must be used in conjunction with mpxio or another similar solution like EMC's Powerpath.
  • SMF services can be integrated into the cluster, and all framework daemons are defined as SMF services
  • PCI and SBus based systems cannot be mixed in the same cluster.
  • Boot devices cannot be on a disk that is shared with other cluster nodes. Doing this may lead to a locked-up cluster due to data fencing.

The overall health of the cluster may be monitored using the cluster status or scstat -v commands. Other useful options include:

  • scstat -g: Resource group status
  • scstat -D: Device group status
  • scstat -W: Heartbeat status
  • scstat -i: IPMP status
  • scstat -n: Node status

Failover applications (also known as "cluster-unaware" applications in the Sun Cluster documentation) are controlled by rgmd (the resource group manager daemon). Each application has a data service agent, which is the way that the cluster controls application startups, shutdowns, and monitoring. Each application is typically paired with an IP address, which will follow the application to the new node when a failover occurs.

"Scalable" applications are able to run on several nodes concurrently. The clustering software provides load balancing and makes a single service IP address available for outside entities to query the application.

"Cluster aware" applications take this one step further, and have cluster awareness programmed into the application. Oracle RAC is a good example of such an application.

All the nodes in the cluster may be shut down with cluster shutdown -y -g0. To boot a node outside of the cluster (for troubleshooting or recovery operations, run boot -x

clsetup is a menu-based utility that can be used to perform a broad variety of configuration tasks, including configuration of resources and resource groups.

Cluster Configuration

The cluster's configuration information is stored in global files known as the "cluster configuration repository" (CCR). The cluster framework files in /etc/cluster/ccr should not be edited manually; they should be managed via the administrative commands.

The cluster show command displays the cluster configuration in a nicely-formatted report.

The CCR contains:

  • Names of the cluster and the nodes.
  • The configuration of the cluster transport.
  • Device group configuration.
  • Nodes that can master each device group.
  • NAS device information (if relevant).
  • Data service parameter values and callback method paths.
  • Disk ID (DID) configuration.
  • Cluster status.

Some commands to directly maintain the CCR are:

  • ccradm: Allows (among other things) a checksum re-configuration of files in /etc/cluster/ccr after manual edits. (Do NOT edit these files manually unless there is no other option. Even then, back up the original files.) ccradm -i /etc/cluster/ccr/filename -o
  • scgdefs: Brings new devices under cluster control after they have been discovered by devfsadm.

The scinstall and clsetup commands may

We have observed that the installation process may disrupt a previously installed NTP configuration (even though the installation notes promise that this will not happen). It may be worth using ntpq to verify that NTP is still working properly after a cluster installation.

Resource Groups

Resource groups are collections of resources, including data services. Examples of resources include disk sets, virtual IP addresses, or server processes like httpd.

Resource groups may either be failover or scalable resource groups. Failover resource groups allow groups of services to be started on a node together if the active node fails. Scalable resource groups run on several nodes at once.

The rgmd is the Resource Group Management Daemon. It is responsible for monitoring, stopping, and starting the resources within the different resource groups.

Some common resource types are:

  • SUNW.LogicalHostname: Logical IP address associated with a failover service.
  • SUNW.SharedAddress: Logical IP address shared between nodes running a scalable resource group.
  • SUNW.HAStoragePlus: Manages global raw devices, global file systems, non-ZFS failover file systems, and failover ZFS zpools.

Resource groups also handle resource and resource group dependencies. Sun Cluster allows services to start or stop in a particular order. Dependencies are a particular type of resource property. The r_properties man page contains a list of resource properties and their meanings. The rg_properties man page has similar information for resource groups. In particular, the Resource_dependencies property specifies something on which the resource is dependent.

Some resource group cluster commands are:

  • clrt register resource-type: Register a resource type.
  • clrt register -n node1name,node2name resource-type: Register a resource type to specific nodes.
  • clrt unregister resource-type: Unregister a resource type.
  • clrt list -v: List all resource types and their associated node lists.
  • clrt show resource-type: Display all information for a resource type.
  • clrg create -n node1name,node2name rgname: Create a resource group.
  • clrg delete rgname: Delete a resource group.
  • clrg set -p property-name rgname: Set a property.
  • clrg show -v rgname: Show resource group information.
  • clrs create -t HAStoragePlus -g rgname -p AffinityOn=true -p FilesystemMountPoints=/mountpoint resource-name
  • clrg online -M rgname
  • clrg switch -M -n nodename rgname
  • clrg offline rgname: Offline the resource, but leave it in a managed state.
  • clrg restart rgname
  • clrs disable resource-name: Disable a resource and its fault monitor.
  • clrs enable resource-name: Re-enable a resource and its fault monitor.
  • clrs clear -n nodename -f STOP_FAILED resource-name
  • clrs unmonitor resource-name: Disable the fault monitor, but leave resource running.
  • clrs monitor resource-name: Re-enable the fault monitor for a resource that is currently enabled.
  • clrg suspend rgname: Preserves online status of group, but does not continue monitoring.
  • clrg resume rgname: Resumes monitoring of a suspended group
  • clrg status: List status of resource groups.
  • clrs status -g rgname

Data Services

A data service agent is a set of components that allow a data service to be monitored and fail over within the cluster. The agent includes methods for starting, stopping, monitoring, or failing the data service. It also includes a registration information file allowing the CCR to store the information about these methods in the CCR. This information is encapsulated as a resource type.

The fault monitors for a data sevice place the daemons under the control of the process monitoring facility (rpc.pmfd), and the service, using client commands.

Public Network

The public network uses pnmd (Public Network Management Daemon) and the IPMP in.mpathd daemon to monitor and control the public network addresses.

IPMP should be used to provide failovers for the public network paths. The health of the IPMP elements can be monitored with scstat -i

The clrslh and clrssa commands are used to configure logical and shared hostnames, respectively.

  • clrslh create -g rgname logical-hostname

Private Network

The "private," or "cluster transport" network is used to provide a heartbeat between the nodes so that they can determine which nodes are available. The cluster transport network is also used for traffic related to global devices.

While a 2-node cluster may use crossover cables to construct a private network, switches should be used for anything more than two nodes. (Ideally, separate switching equipment should be used for each path so that there is no single point of failure.)

The default base IP address is 172.16.0.0, and private networks are assigned subnets based on the results of the cluster setup.

Available network interfaces can be identified by using a combination of dladm show-dev and ifconfig.

Private networks should be installed and configured using the scinstall command during cluster configuration. Make sure that the interfaces in question are connected, but down and unplumbed before configuration. The clsetup command also has menu options to guide you through the private network setup process.

Alternatively, something like the following command string can be used to establish a private network:

  • clintr add nodename1:ifname
  • clintr add nodename2:ifname2
  • clintr add switchname
  • clintr add nodename1:ifname1,switchname
  • clintr add nodename2:ifname2,switchname
  • clintr status

The health of the heartbeat networks can be checked with the scstat -W command. The physical paths may be checked with clintr status or cluster status -t intr.

Quorum

Sun Cluster uses a quorum voting system to prevent split-brain and cluster amnesia. The Sun Cluster documentation refers to "failure fencing" as the mechanism to prevent split-brain (where two nodes run the same service at the same time, leading to potential data corruption).

"Amnesia" occurs when a change is made to the cluster while a node is down, then that node attempts to bring up the cluster. This can result in the changes being forgotten, hence the use of the word "amnesia."

One result of this is that the last node to leave a cluster when it is shut down must be the first node to re-enter the cluster. Later in this section, we will discuss ways of circumventing this protection.

Quorum voting is defined by allowing each device one vote. A quorum device may be a cluster node, a specified external server running quorum software, or a disk or NAS device. A majority of all defined quorum votes is required in order to form a cluster. At least half of the quorum votes must be present in order for cluster services to remain in operation. (If a node cannot contact at least half of the quorum votes, it will panic. During the reboot, if a majority cannot be contacted, the boot process will be frozen. Nodes that are removed from the cluster due to a quorum problem also lose access to any shared file systems. This is called "data fencing" in the Sun Cluster documentation.)

  • Quorum devices must be available to at least two nodes in the cluster.
  • Disk quorum devices may also contain user data. (Note that if a ZFS disk is used as a quorum device, it should be brought into the zpool before being specified as a quorum device.)
  • Sun recommends configuring n-1 quorum devices (the number of nodes minus 1). Two node clusters must contain at least one quorum device.
  • Disk quorum devices must be specified using the DID names.
  • Quorum disk devices should be at least as available as the storage underlying the cluster resource groups.

Quorum status and configuration may be investigating using:

  • scstat -q
  • clq status

These commands report on the configured quorum votes, whether they are present, and how many are required for a majority.

Quorum devices can be manipulated through the following commands:

  • clq add did-device-name
  • clq remove did-device-name: (Only removes the device from the quorum configuration. No data on the device is affected.)
  • clq enable did-device-name
  • clq disable did-device-name: (Removes the quorum device from the total list of available quorum votes. This might be valuable if the device is down for maintenance.)
  • clq reset: (Resets the configuration to the default.)

By default, doubly-connected disk quorum devices use SCSI-2 locking. Devices connected to more than two nodes use SCSI-3 locking. SCSI-3 offers persistent reservations, but SCSI-2 requires the use of emulation software. The emulation software uses a 64-bit reservation key written to a private area on the disk.

In either case, the cluster node that wins a race to the quorum device attempts to remove the keys of any node that it is unable to contact, which cuts that node off from the quorum device. As noted before, any group of nodes that cannot communicate with at least half of the quorum devices will panic, which prevents a cluster partition (split-brain).

In order to add nodes to a 2-node cluster, it may be necessary to change the default fencing with scdidadm -G prefer3 or cluster set -p global_fencing=prefer3, create a SCSI-3 quorum device with clq add, then remove the SCSI-2 quorum device with clq remove.

NetApp filers and systems running the scqsd daemon may also be selected as quorum devices. NetApp filers use SCSI-3 locking over the iSCSI protocol to perform their quorum functions.

The claccess deny-all command may be used to deny all other nodes access to the cluster. claccess allow nodename re-enables access for a node.

Purging Quorum Keys

CAUTION: Purging the keys from a quorum device may result in amnesia. It should only be done after careful diagnostics have been done to verify why the cluster is not coming up. This should never be done as long as the cluster is able to come up. It may need to be done if the last node to leave the cluster is unable to boot, leaving everyone else fenced out. In that case, boot one of the other nodes to single-user mode, identify the quorum device, and:

For SCSI 2 disk reservations, the relevant command is pgre, which is located in /usr/cluster/lib/sc:

  • pgre -c pgre_inkeys -d /dev/did/rdks/d#s2 (List the keys in the quorum device.)
  • pgre -c pgre_scrub -d /dev/did/rdks/d#s2 (Remove the keys from the quorum device.)

Similarly, for SCSI 3 disk reservations, the relevant command is scsi:

  • scsi -c inkeys -d /dev/did/rdks/d#s2 (List the keys in the quorum device.)
  • scsi -c scrub -d /dev/did/rdks/d#s2 (Remove the keys from the quorum device.)

Global Storage

Sun Cluster provides a unique global device name for every disk, CD, and tape drive in the cluster. The format of these global device names is /dev/did/device-type. (eg /dev/did/dsk/d2s3) (Note that the DIDs are a global naming system, which is separate from the global device or global file system functionality.)

DIDs are componentsof SVM volumes, though VxVM does not recognize DID device names as components of VxVM volumes.

DID disk devices, CD-ROM drives, tape drives, SVM volumes, and VxVM volumes may be used as global devices. A global device is physically accessed by just one node at a time, but all other nodes may access the device by communicating across the global transport network.

The file systems in /global/.devices store the device files for global devices on each node. These are mounted on mount points of the form /global/.devices/node@nodeid, where nodeid is the identification number assigned to the node. These are visible on all nodes. Symbolic links may be set up to the contents of these file systems, if they are desired. Sun Cluster sets up some such links in the /dev/global directory.

Global file systems may be ufs, VxFS, or hsfs. To mount a file system as a global file system, add a "global" mount option to the file system's vfstab entry and remount. Alternatively, run a mount -o global... command.

(Note that all nodes in the cluster should have the same vfstab entry for all cluster file systems. This is true for both global and failover file systems, though ZFS file systems do not use the vfstab at all.)

In the Sun Cluster documentation, global file systems are also known as "cluster file systems" or "proxy file systems."

Note that global file systems are different from failover file systems. The former are accessible from all nodes; the latter are only accessible from the active node.

Maintaining Devices

New devices need to be read into the cluster configuration as well as the OS. As usual, we should run something like devfsadm or drvconfig; disks to create the /device and /dev links across the cluster. Then we use the scgdevs or scdidadm command to add more disk devices to the cluster configuration.

Some useful options for scdidadm are:

  • scdidadm -l: Show local DIDs
  • scdidadm -L: Show all cluster DIDs
  • scdidadm -r: Rebuild DIDs

We should also clean up unused links from time to time with devfsadm -C and scdidadm -C

The status of device groups can be checked with scstat -D. Devices may be listed with cldev list -v. They can be switched to a different node via a cldg switch -n target-node dgname command.

Monitoring for devices can be enabled and disabled by using commands like:

  • cldev monitor all
  • cldev unmonitor d#
  • cldev unmonitor -n nodename d#
  • cldev status -s Unmonitored

Parameters may be set on device groups using the cldg set command, for example:

  • cldg set -p failback=false dgname

A device group can be taken offline or placed online with:

  • cldg offline dgname
  • cldg online dgname

VxVM-Specific Issues

Since vxdmp cannot be disabled, we need to make sure that VxVM can only see one path to each disk. This is usually done by implementing mpxio or a third party product like Powerpath. The order of installation for such an environment would be:

  1. Install Solaris and patches.
  2. Install and configure multipathing software.
  3. Install and configure Sun Cluster.
  4. Install and configure VxVM

If VxVM disk groups are used by the cluster, all nodes attached to the shared storage must have VxVM installed. Each vxio number in /etc/name_to_major must also be the same on each node. This can be checked (and fixed, if necessary) with the clvxvm initialize command. (A reboot may be necessary if the /etc/name_to_major file is changed.)

The clvxvm encapsulate command should be used if the boot drive is encapsulated (and mirrored) by VxVM. That way the /global/.devices information is set up properly.

The clsetup "Device Groups" menu contains items to register a VxVM disk group, unregister a device group, or synchronize volume information for a disk group. We can also re-synchronize with the cldg sync dgname command.

Solaris Volume Manager-Specific Issues

Sun Cluster allows us to add metadb or partition information in the /dev/did format or in the usual format. In general:

  • Use local format for boot drive mirroring in case we need to boot outside the cluster framework.
  • Use cluster format for shared disksets because otherwise we will need to assume the same controller numbers on each node.

Configuration information is kept in the metadatabase replicas. At least three local replicas are required to boot a node; these should be put on their own partitions on the local disks. They should be spread across controllers and disks to the degree possible. Multiple replicas may be placed on each partition; they should be spread out so that if any one disk fails, there will still be at least three replicas left over, constituting at least half of the total local replicas.

When disks are added to a shared diskset, database replicas are automatically added. These will always be added to slice 7, where they need to remain. If a disk containing replicas is removed, the replicas must be removed using metadb.

If fewer than 50% of the replicas in a diskset are available, the diskset ceases to operate. If exactly 50% of the replicas are available, the diskset will continue to operate, but will not be able to be enabled or switched on another node.

A mediator can be assigned to a shared diskset. The mediator data is contained within a Solaris process on each node and counts for two votes in the diskset quorum voting.

Standard c#t#d#s# naming should be used when creating local metadb replicas, since it will make recovery easier if we need to boot the node outside of a cluster context. On the other hand, /dev/did/rdsk/d#s# naming should be used for shared disksets, since otherwise the paths will need to be identical on all nodes.

Creating a new shared diskset involves the following steps:
(Create an empty diskset.)
metaset -s set-name -a -h node1-name node2-name
(Create a mediator.)
metaset -s set-name -a -m node1-name node2-name
(Add disks to the diskset.)
metaset -s set-name -a /dev/did/rdsk/d# /dev/did/rdsk/d#
(Check that the diskset is present in the cluster configuration.)
cldev list -v
cldg status
cldg show set-name

ZFS-Specific Issues

ZFS is only available as a Sun Cluster failover file system, not as a global file system. No vfstab entries are required, since that information is contained in the zpools. No synchronization commands are required like in VxVM; Sun Cluster takes care of the synchronization automatically.

Zones

Non-global zones may be treated as virtual nodes. Keep in mind that some services, such as NFS, will not run in non-global zones.

Services can be failed over between zones, even zones on the same server. Where possible, it is best to use full rather than sparse zones. Certain types of failures within the non-global zone can cause a crash in the global zone.

Configuration of cluster resources and resource groups must be performed in the global zone. The rgmd runs in the global zone.

To specify a non-global zone as a node, use the form
nodename:zonename
or specify
-n nodename -z zonename

Additional Reading

Monday, May 06, 2013

Process Virtual Memory

Each process maps either 2^32 or 2^44 bytes of memory (depending on whether the OS is running in 32 or 64-bit mode). This works out to 4GB or 16TB. Not all of this memory is allocated (used); the virtual memory is used as address space that can be mapped to actual memory resources.

Virtual memory structure for a process can be described as in this diagram:

Kernel

While this is part of the address space, it cannot be addressed directly by the process. It must be addressed via system calls.
Stack

Used by the program for variables and storage. It grows and shrinks in size depending on what routines are called and what their stack space requirements are. It is normally about 8MB in size.
Shared Libraries
Shared libraries are position independent so that they can be shared by all programs that want to use them. One common example is libc.so.
hole

This is the address space that is unallocated and unused. It does not tie up physical memory. For most processes, this is the largest portion of the virtual memory for the process.
heap

Used for some types of working storage. It is allocated by the malloc function.
BSS

Uninitialized variables. These are not part of the executable file and their initial value is set to zeros.
Data

Global variables, constants, static variables from the program.
Text

Set of instructions from the compiler-generated executable file.

The virtual memory map for a process can be displayed using the pmap command.

Additional information is available on the Processes page.

Friday, May 03, 2013

Solaris Processes

The process is one of the fundamental abstactions of Unix. Every object in Unix is represented as either a file or a process. (With the introduction of the /proc structure, there has been an effort to represent even processes as files.)

Processes are usually created with fork or a less resource intensive alternative such as fork1 or vfork. fork duplicates the entire process context, while fork1 only duplicates the context of the calling thread. This can be useful (for example), when exec will be called shortly.

Solaris, like other Unix systems, provides two modes of operation: user mode, and kernel (or system) mode. Kernel mode is a more privileged mode of operation. Processes can be executed in either mode, but user processes usually operate in user mode.

Per-process Virtual Memory

Each process has its own virtual memory space. References to real memory are provided through a process-specific set of address translation maps. The computer's Memory Management Unit (MMU) contains a set of registers that point to the current process's address translation maps. When the current process changes, the MMU must load the translation maps for the new process. This is called a context switch.

The MMU is only addressable in kernel mode, for obvious security reasons.

The kernel text and data structures are mapped in a portion of each process's virtual memory space. This area is called the kernel space (or system space).

In addition, each process contains these two important kernel-owned areas in virtual memory: u area and kernel stack. The u area contains information about the process such as information about open files, identification information and process registers. The kernel stack is provided on a per-process basis to allow the kernel to be re-entrant. (ie, several processes can be involved in the kernel, and may even be executing the same routine concurrently.) Each process's kernel stack keeps track of its function call sequence when executing in the kernel.

The kernel can access the memory maps for non-current processes by using temporary maps.

The kernel can operate in either process context or system (or interrupt) context. In process context, the kernel has access to the process's memory space (including u area and kernel stack). It can also block the current process while waiting for a resource. In kernel context, the kernel cannot access the address space, u area or kernel stack. Kernel context is used for handling certain system-wide issues such as device interrupt handling or process priority computation.

Additional information is available on the Process Virtual Memory page.

Process Context

Each process's context contains information about the process, including the following:

  • Hardware context:
    • Program counter: address of the next instruction.
    • Stack pointer: address of the last element on the stack.
    • Processor status word: information about system state, with bits devoted to things like execution modes, interrupt priority levels, overflow bits, carry bits, etc.
    • Memory management registers: Mapping of the address translation tables of the process.
    • Floating point unit registers.
  • User address space: program text, data, user stack, shared memory regions, etc.
  • Control information: u area, proc structure, kernel stack, address translation maps.
  • Credentials: user and group IDs (real and effective).
  • Environment variables: strings of the form variable= value.

During a context switch, the hardware context registers are stored in the Process Control Block in the u area.

The u area includes the following:

  • Process control block.
  • Pointer to the proc structure.
  • Real/effective UID/GID.
  • Information regarding current system call.
  • Signal handlers.
  • Memory management information (text, data, stack sizes).
  • Table of open file descriptors.
  • Pointers to the current directory vnode and the controlling terminal vnode.
  • CPU useage statistics.
  • Resource limitations (disk quotas, etc)
The proc structure includes the following:
  • Identification: process ID and session ID
  • Kernel address map location.
  • Current process state.
  • Pointers linking the process to a scheduler queue or sleep queue.
  • Pointers linking this process to lists of active, free or zombie processes.
  • Pointers keeping this structure in a hash queue based on PID.
  • Sleep channel (if the process is blocked).
  • Scheduling priority.
  • Signal handling information.
  • Memory management information.
  • Flags.
  • Information on the relationship of this process and other processes.

Kernel Services

The Solaris kernel may be seen as a bundle of kernel threads. It uses synchronization primitives to prevent priority inversion. These include mutexes, semaphores, condition variables and read/write locks.

The kernel provides service to processes in the following four ways:

  • System Calls: The kernel executes requests submitted by processes via system calls. The system call interface invokes a special trap instruction.
  • Hardware Exceptions: The kernel notifies a process that attempts several illegal activities such as dividing by zero or overflowing the user stack.
  • Hardware Interrupts: Devices use interrupts to notify the kernel of status changes (such as I/O completions).
  • Resource Management: The kernel manages resources via special processes such as the pagedaemon.

In addition, some system services (such as NFS service) are contained within the kernel in order to reduce overhead from context switching.

Threads

An application's parallelism is the degree of parallel execution acheived. In the real world, this is limited by the number of processors available in the hardware configuration. Concurrency is the maximum acheivable parallelism in a theoretical machine that has an unlimited number of processors. Threads are frequently used to increase an application's concurrency.

A thread represents a relatively independent set of instructions within a program. A thread is a control point within a process. It shares global resources within the context of the process (address space, open files, user credentials, quotas, etc). Threads also have private resources (program counter, stack, register context, etc).

The main benefit of threads (as compared to multiple processes) is that the context switches are much cheaper than those required to change current processes. Sun reports that a fork() takes 30 times as long as an unbound thread creation and 5 times as long as a bound thread creation.

Even within a single-processor environment, multiple threads are advantageous because one thread may be able to progress even though another thread is blocked while waiting for a resource.

Interprocess communication also takes considerably less time for threads than for processes, since global data can be shared instantly.

Kernel Threads

A kernel thread is the entity that is scheduled by the kernel. If no lightweight process is attached, it is also known as a system thread. It uses kernel text and global data, but has its own kernel stack, as well as a data structure to hold scheduling and syncronization information.

Kernel threads store the following in their data structure:

  • Copy of the kernel registers.
  • Priority and scheduling information.
  • Pointers to put the thread on the scheduler or wait queue.
  • Pointer to the stack.
  • Pointers to associated LWP and proc structures.
  • Pointers to maintain queues of threads in a process and threads in the system.
  • Information about the associated LWP (as appropriate).

Kernel threads can be independently scheduled on CPUs. Context switching between kernel threads is very fast because memory mappings do not have to be flushed.

Lightweight Processes

A lightweight process can be considered as the swappable portion of a kernel thread.

Another way to look at a lightweight process is to think of them as "virtual CPUs" which perform the processing for applications. Application threads are attached to available lightweight processes, which are attached to a a kernel thread, which is scheduled on the system's CPU dispatch queue.

LWPs can make system calls and can block while waiting for resources. All LWPs in a process share a common address space. IPC (interprocess communication) facilities exist for coordinating access to shared resources.

LWPs contain the following information in their data structure:

  • Saved values of user-level registers (if the LWP is not active)
  • System call arguments, results, error codes.
  • Signal handling information.
  • Data for resource useage and profiling.
  • Virtual time alarms.
  • User time/CPU usage.
  • Pointer to the associated kernel thread.
  • Pointer to the associated proc structure.

By default, one LWP is assigned to each process; additional LWPs are created if all the process's LWPs are sleeping and there are additional user threads that libthread can schedule. The programmer can specify that threads are bound to LWPs.

Lightweight process information for a process can be examined with ps -elcL.

User Threads

User threads are scheduled on their LWPs via a scheduler in libthread. This scheduler does implement priorities, but does not implement time slicing. If time slicing is desired, it must be programmed in.

Locking issues must also be carefully considered by the programmer in order to prevent several threads from blocking on a single resource.

User threads are also responsible for handling of SIGSEGV (segmentation violation) signals, since the kernel does not keep track of user thread stacks.

Each thread has the following characteristics:

  • Has its own stack.
  • Shares the process address space.
  • Executes independently (and perhaps concurrently with other threads).
  • Completely invisible from outside the process.
  • Cannot be controlled from the command line.
  • No system protection between threads in a process; the programmer is responsible for interactions.
  • Can share information between threads without IPC overhead.

Priorities

Higher numbered priorities are given precedence. The scheduling page contains additional information on how priorities are set.

Zombie Processes

When a process dies, it becomes a zombie process. Normally, the parent performs a wait() and cleans up the PID. Sometimes, the parent receives too many SIGCHLD signals at once, but can only handle one at a time. It is possible to resend the signal on behalf of the child via kill -18 PPID. Killing the parent or rebooting will also clean up zombies. The correct answer is to fix the buggy parent code that failed to perform the wait() properly.

Aside from their inherent sloppiness, the only problem with zombies is that they take up a place in the process table.

Kernel Tunables

The following kernel tunables are important when looking at processes:
  • maxusers: By default, this is set to 2 less than the number of Mb of physical memory, up to 1024. It can be set up to 2048 manually in the /etc/system file.
  • max_nprocs: Maximum number of processes that can be active simultaneously on the system. The default for this is (16 x maxusers) + 10. The minimum setting for this is 138, the maximum is 30,000.
  • maxuprc: The default setting for this is max_nprocs - 5. The minimum is 133, the maximum is . This is the numberof processes a single non-root user can create.
  • ndquot: This is the number of disk quota structures. The default for this is (maxusers x 10) + max_nprocs. The minimum is 213.
  • pt_cnt: Sets the number of System V ptys.
  • npty: Sets the number of BSD ptys. (Should be set to pt_cnt.)
  • sad_cnt: Sets the number of STREAMS addressable devices. (Should be set to 2 x pt_cnt.)
  • nautopush: Sets the number of STREAMS autopush entries. (Should be set to pt_cnt.)
  • ncsize: Sets DNLC size.
  • ufs_ninode: Sets inode cache size.

proc Commands

The proc tools are useful for tracing attributes of processes. These utilities include:
  • pflags: Prints the tracing flags, pending and held signals and other /proc status information for each LWP.
  • pcred: Prints credentials (ie, EUID/EGID, RUID/EGID, saved UID/GIDs).
  • pmap: Prints process address space map.
  • pldd: Lists dynamic libraries linked to the process.
  • psig: Lists signal actions.
  • pstack: Prints a stack trace for each LWP in the process.
  • pfiles: Reports fstat, fcntl information for all open files.
  • pwdx: Prints each process's working directory.
  • pstop: Stops process.
  • prun: Starts stopped process.
  • pwait: Wait for specified processes to terminate.
  • ptree: Prints process tree for process.
  • ptime: Times the command using microstate accounting; does not time children.

These commands can be run against a specific process, but most of them can also be run against all processes on the system. See the above- referenced man page for details.

Thursday, May 02, 2013

Basic NFS Troubleshooting

NFS Troubleshooting

Sun's web pages contain substantial information about NFS services; search for an NFS Administration Guide or NFS Server Performance and Tuning Guide for the version of Solaris you are running. The share_nfs man page contains specific information about export options.

If NFS is not working at all, try the following:

  • Make sure that the NFS server daemons are running. In particular, check for statd, lockd, nfsd and rarpd. If the daemons are not running, they can be started by running /etc/init.d/nfs.server start. See Daemons below for information on NFS-related daemons.
  • Check the /etc/dfs/dfstab and type shareall.
  • Use share or showmount -e to see which filesystems are currently exported, and to whom. showmount -a shows who the server believes is actually mounting which filesystems.
  • Make sure that your name service is translating the server and client hostnames correctly on both ends. Check the server logs to see if there are messages regarding failed or rejected mount attempts; check to make sure that the hostnames are correct in these messages.
  • Make sure that the /etc/net/*/hosts files on both ends report the correct hostnames. Reboot if these have to be edited.

If you are dealing with a performance issue, check

  • Network Issues
  • CPU Useage
  • Memory Levels
  • Disk I/O
  • Increase the number of nfsd threads in /etc/init.d/nfs.server if the problem is that requests are waiting for a turn. Note that this does increase memory useage by the kernel, so make sure that there is enough RAM in the server to handle the additional load.
  • Where possible, mount filesystem with the ro option to prevent additional, unnecessary attribute traffic.
  • If attribute caching does not make sense (for example, with a mail spool), mount the filesystem with the noac option. If nfsstat reports a high getattr level, actimeo may need to be increased (if the attributes do not change too often).
  • nfsstat reports on most NFS-related statistics. The nfsstat page includes information on tuning suggestions for different types of problems that can be revealed with nfsstat.

If these steps do not resolve the issue, structural changes may be required:

  • cachefs can be used to push some of the load from the NFS server onto the NFS clients. To be useful, cfsadmin should be used to increase maxfilesize for the cache to a value high enough to allow for the caching of commonly-used files. (The default value is 3 Mb.)

NFS Client

When a client makes a request to the NFS server, a file handle is returned. The file handle is a 32 byte structure which is interpreted by the NFS server. Commonly, the file handle includes a file system ID, inode number and the generation number of the inode. (The latter can be used to return a "stale file handle" error message if the inode has been freed and re-used between client file accesses.)

If a response is not received for a request, it is resent, but with an incremented xid (transmission ID). This can happen because of congestion on the network or the server, and can be observed with a snoop session between server and client.

The server handles retransmissions differently depending on whether the requests are idempotent (can be executed several times without ill effect) or nonidempotent (cannot be executed several times). Examples of these would include things like reads and getattrs versus writes, creates and removes. The system maintains a cache of nonidempotent requests so that appropriate replies can be returned.

Daemons

The following daemons play a critical role in NFS service:

  • biod: On the client end, handles asynchronous I/O for blocks of NFS files.
  • nfsd: Listens and responds to client NFS requests.
  • mountd: Handles mount requests.
  • lockd: Network lock manager.
  • statd: Network status manager.

Wednesday, May 01, 2013

Native Solaris Storage Multipathing with mpathadm

The “Solaris FC and Storage Multipathing Software” is included with the Solaris 10 license. It is enabled by default with the Solaris 10x86 installation, but is optional in the Sparc installlation.

Currently, the software supports multipathing for fibre channel connections using supported host bus adapters. It does not currently support multipathing for parallel SCSI devices or IP over FC.

For Sparc-based systems, multipathing support is enabled and disabled via the stmsboot -e and stmsboot -d commands. This command reboots the system to complete the process, so make sure that the right boot-device is included in the EEPROM settings before proceeding.

When multipathing is enabled, copies of the /etc/vfstab and /kernel/drv/fp.conf files are preserved to allow the changes to be backed out if necessary.

For x86-based systems, directly edit the fp.conf to change the value of mpxio-disable to “no.” (Disabling it will involve changing it to “yes.”) After the change, run a reconfiguration reboot.

To enable or disable multipathing on a per-port basis, the mpxio-disable parameter may be set on a port-specific line in the fp.conf. (Syntax guidance is included in the comments of the fp.conf file.)

mpathadm Commands
TaskCommand
List available multipathing support mpathadm list mpath-support
View properties for supported multipathing facilities. mpathadm show mpath-support facilityname
List initiator ports. mpathadm list initiator-port
Get initiator port properties. mpathadm show initiator-port portname
List available logical units. mpathadm list lu
Get logical unit properties. mpathadm show lu lunname
List logical units associated with a target port. mpatadm list lu -t portname
Configure auto-failback. mpathadm modify mpath-support -a off facilityname
Disable a path. mpathadm disable path -i initportname -t tgtportname -l luname

Adding Third Party Device Support

Support for many third-party devices is not contained in the default version of the configuration file at /kernel/drv/scsi_vhci.conf. The following shows the changes necessary to bring EMC Symmetrix support into the multipathing software:

# cat /kernel/drv/scsi_vhci.conf
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "@(#)scsi_vhci.conf 1.9 04/08/26 SMI"
#
name="scsi_vhci" class="root";
...
# symmetric-option = 0x1000000;
device-type-scsi-options-list =
"EMC SYMMETRIX 5671", "symmetric-option";

symmetric-option = 0x1000000;

Unfortunately, the syntax on the scsi_vhci.conf file is incredibly picky. The vendor name must be exactly eight characters long, even if you have to pad it with spaces. The product ID can be “up to” 16 characters long, but most recommendations I've seen say to pad the product ID with spaces as well.

Fortunately, the scsi_vhci.conf file contains helpful syntax comments.