Solaris tips

From JhuAcmWiki

Jump to: navigation, search

varcole noboce

Contents

Solaris Tips

Below are some either useful or fun tips that can help make your Solaris experience much easier and more enjoyable. Fnord

Adding to Your Path Variable

Note: Solaris puts some programs in different locations than they would be on Linux or *BSD. Until OpenSolaris comes out, we'll have to live with it. . . Below are suggestions for if you don't have administrative access to the Solaris machine you're using. If you _do_ have root, look at /etc/default/login and /etc/profile. And, by "look at", I mean "change them to set a sane PATH".

Normal user case:

From sh:

$ setenv PATH=$PATH:/{your new path}:/{another}
$ export PATH
$ echo $PATH
/usr/bin:/usr/lib/bin:/opt/sfw/bin:/usr/sfw/bin:/usr/ccs/bin:/opt/csw/bin:{your new path}:{another}
$ 

From bash:

-bash-3.00$ PATH=$PATH:/{your new path}:/{another}
-bash-3.00$ export PATH
-bash-3.00$ echo $PATH   #just to verify path changes worked
/usr/bin:/usr/lib/bin:/opt/sfw/bin:/usr/sfw/bin:{your new path}:{another}
-bash-3.00$ 

For the confused: $PATH can be read as "The contents of the variable PATH" whereas PATH can be considered "The variable PATH". This distinction may make the steps above make a bit more sense.


Solaris Zones

Solaris zones are quite possibly the most powerful part of the OS from a system administration standpoint. Well, they might be tied with DTrace. Zones are most simply thought of as independent operating systems running on the same machine. Their power lies in the fact that one of these virtual operating systems can be complely hosed without affecting any of the other virtual operating systems. This gives a systems administrator a great way to test out new servers/programs before worrying about the large scale deployment before thorough testing in an exact 'copy' of the current operating system.

There is an excellent tutorial on setting up zones at [*http://www.blastwave.org/docs/Solaris-10-b51/DMC-0002/dmc-0002.html]

DTrace

DTrace lets you examine what is going on inside a running Solaris system at a level of detail that has to be seen to be believed. See the Sun documentation at [*http://www.sun.com/bigadmin/content/dtrace/], and the example scripts in /usr/demo/dtrace on an S10 machine.

Note: we used to think that you had to be root to run DTrace. Actually, using Solaris' fine-grained permissions, any user can do it if they have been authorized. 'man permissions' and grep for PRIV_DTRACE_USER or PRIV_DTRACE_KERNEL. Do not give PRIV_DTRACE_KERNEL to ordinary users!!!

example: # grep acmguest /etc/user_attr acmguest::::defaultpriv=basic,dtrace_user,dtrace_proc

Automounter (NFS)

Solaris runs the automounter by default. That means you can mount nfs shares, even as a normal user.

For example, to mount a share "/mnt/scratch" on host "tiresias.acm.jhu.edu", you would

$ cd /net/tiresias.acm.jhu.edu/mnt/scratch

Note: tiresias (and other recent Linux computers) will pretend to support NFS version 4. They don't support it all that well. Thus, Solaris gets confused when it tries the above command (tiresais runs such a recent Linux distribution). The symptom is this error message:

nfs mount: mount: Not owner

A workaround (the correct solution is to diable the broken NFSv4 server) is to edit /etc/default/nfs, and remove the comment from the last line

# Sets the maximum version of the NFS protocol that will be used by
# the NFS client.  Can be overridden by the "vers=" NFS mount option.
# If "vers=" is not specified for an NFS mount, this is the version
# that will be attempted first.  The default is 4.
#NFS_CLIENT_VERSMAX=3

to read

NFS_CLIENT_VERSMAX=3

Or use this mount -o or /etc/vfstab option on the Solaris client: vers=3

Note: do _not_ try to mount NFS shares on computers you don't have permission to mount. If you are unsure whether you have permission, assume that you don't. Seriously!

Playing with Processors

Solaris has some really powerful tools for working with multiple processors... if you are using either the dual PII350's, this can be a lot of fun, especially when you are working with fairly processor intensive tasks.

psrinfo: Get information about processors

This command is good to see what is going on with the system. The most useful (in my opinion) syntax is shown below along with the results. Note: you must either have /usr/sbin in your current path (see above) or alternately just call the command with the full path (/usr/sbin/psrinfo). The -v flag just asks the program to be verbose about the output, which I suppose would not be desired by default if your system had hundreds of processors.

-bash-3.00$ /usr/sbin/psrinfo -v 
Status of virtual processor 0 as of: 02/19/2005 19:33:43
 on-line since 02/19/2005 02:49:29.
 The i386 processor operates at 350 MHz,
       and has an i387 compatible floating point processor.
Status of virtual processor 1 as of: 02/19/2005 19:33:43
 on-line since 02/19/2005 02:49:34.
 The i386 processor operates at 350 MHz,
       and has an i387 compatible floating point processor.
-bash-3.00$

psradm: Change status of the processors

For this feature you must be in a root shell. If you would like to play around with it, ask an ACM officer if they are in the room and we'll probably let you play around with it.

Some Useful syntax: -i disable interrupts. This feature prevents a processor from servicing any interrupts and as a result will give you a guaranteed latency. Probably not important for most ACMers, but nonetheless rather neat

-f take a processor offline. Fun to watch Solaris migrate processes over to the other process after issuing the command

-n Take the processor back online. Also fun to watch Solaris load balance after getting another processor. Quite noticeable if you're doing something processor intensive... like compiling

The syntax is generalized as:

psradm -{switch} {processor ID} {processor ID} ...

Actions can be verified by using psrinfo.

Automatic generation of NFS share lists

  • Solaris controls most (much? all?) NFS configuration in /etc/dfs.
  • There is /etc/dfs/dfstab on manticore. It's a shell script that Solaris runs to share things. Solaris puts the list of currently-shared things in /etc/dfs/sharetab. This is a little like /etc/fstab vs. /etc/mtab. (Of course, Solaris doesn't have /etc/mtab.)
  • The equivalent of no_root_squash is root=. You can see it in /etc/dfs/dfstab.

Swap

MPlayer compilation

On x86 Solaris 11 b48, I received the following error with 2007-1-27 SVN. Apparently it's a known issue that mplayer has random poorly-ifdef'd defines that break Solaris compilation, and they appear to get fixed whenever someone notices.

  • ldt_keeper.c:70: error: conflicting types for 'sysi86'

The solution is to just comment out the conflicting definition and build anyway. If this doesn't work for you, edit this wiki and maybe a better solution will appear.

Personal tools