Lofland bLOG

Patching SUN: (single patch)

Filed under Unix Notes on Tuesday, February 28th, 2006 @ 3:02pm by Christen

patchadd -p will list the installed patches

from console

patchadd PATCHNAME

this is done in multi-user mode

If it asks you, go to single user mode. The patch may actually tell you that it is better to go to single user mode.

To drop to single user mode on SUN:
init s

SUN requires the root password when you go to single-user mode
(You can’t “backdoor” SUN machines from single-user mode. If you don’t know the root password you have to boot from CD and mount the root file system and change the root password that way, kind of like Windows NT.)

Again, now in single user mode, the command is the same:
patchadd PATCHNAME

to get out of single user mode:
exit

It will ask you what runlevel to go to, and you want 3

NOTE: (This is Solaris specific:)

There is a huge difference between patchadd and pkgadd as pertaining to the -d option. Short story is you should NEVER use the -d option with patchadd. Unlike pkgadd where the -d specifies the device (location) for the package, the -d in patchadd tells it not to backup the files being patched, i.e you can never remove the patch if you need to….That is a bad thing. From the man pages:

patchadd:

-d Does not back up the files to be patched. The patch cannot be removed.

pkgadd:

-d device
Install or copy a package from device. device can be a
full path name to a directory or the identifiers for
tape, floppy disk, or removable disk (for example,
/var/tmp or /floppy/floppy_name ). It can also be a
device alias (for example, /floppy/floppy0).

Adding & Removing Disks on HPUX

Filed under Unix Notes on Tuesday, February 28th, 2006 @ 2:40pm by Christen

Exercise. Disk is removed and /dev files wiped out, return the disk to HPUX:

diskinfo /dev/rdsk/c0t8d0

ioscan -funCdisk

disk 4 8/4.8.0 sdisk CLAIMED DEVICE SEAGATE ST34572WC
/dev/dsk/c0t8d0 /dev/rdsk/c0t8d0
(The U option tells ioscan to pull info from the kernel’s memory. It avoids actually scanning the hardware. This is faster, but it also means any changes won’t be found. If you take out the U, then it will scan the hardware, and if there was a change, it will find it. You may not want the system to find hardware changes sometimes, like if an array has gone offline temporarily.)

yank disk 8/4.8.0

ioscan -funCdisk
-still shows the disk as CLAIMED because of the U switch

ioscan -fnCdisk
-finds hardware changes, and returns “NO_HW” instead of “CLAIMED”
-Same thing would happen if anything had tried to read/write the disk


now use rmsf to revove the /dev files for the drive.
-If you ever need to remove a /dev file, don’t use rm, use rmsf (man is your friend)

(The example here is removing a Hitachi SAN disk)

ioscan will show you both the hardware address (That number with the /’s) and the /dev files for the hardware:

disk    101  0/0/10/0/0.1.0.5.0.10.0  sdisk    NO_HW       DEVICE       HITACHI DF600F
/dev/dsk/c34t10d0   /dev/rdsk/c34t10d0
To wipe out a piece of hardare run:
rmsf -a /dev/dsk/c0t8d0

(The -a option should cause this to also remove the /dev/rdsk file and it shoudln’t show up in ioscan -funCdisk anymore either)

Now ioscan will show no signs of the hardware.

If you don’t use the “-a” option then you have to remove both the /dev/dsk and the /dev/rdsk files individually. Then ioscan will STILL see the drive:

disk    101  0/0/10/0/0.1.0.5.0.10.0  sdisk    NO_HW       DEVICE       HITACHI DF600F
So then you must use the hardware address to remove the drive:

rmsf -H  0/0/10/0/0.1.0.5.0.10.0

put disk back in (or put in a new disk)

(The “replace” example here is a local disk, the “new” example is an EMC SAN disk.)

ioscan -fnCdisk
- finds hardware changes and recognizes disk again

Devices physically attached to the system should automatically show up when you run ioscan without the “u” option, as above. However, there are no /dev files for things like disks, so you can’t use them yet.

insf is used to replace the /dev files
(opposite of rmsf)
insf -e is just like box rebooted, it tries to install EVERYTHING, if you don’t remember the hardware path, and youc an do that.
or
insf -e -Cdisk will JUST do the disks, instead of the entire box
or
insf -e -H 8/4.8.0 if you know the hardware address, this is right out of ioscan

Again:
disk     49  0/0/8/0/0.3.0.3.0.4.7    sdisk    CLAIMED     DEVICE       EMC     SYMMETRIX
insf -e -H 0/0/8/0/0.3.0.3.0.4.7

disk     49  0/0/8/0/0.3.0.3.0.4.7    sdisk    CLAIMED     DEVICE       EMC     SYMMETRIX
/dev/dsk/c29t4d7   /dev/rdsk/c29t4d7
Another good command to check that all disks are there:

for i in `ls /dev/dsk/*`;do pvdisplay $i;done

To check for disks that are not being used use diskinfo instead of pvdisplay:

for i in `ls /dev/rdsk/*`;do diskinfo $i;done

Xserver

Filed under Unix Notes on Tuesday, February 28th, 2006 @ 2:25pm by Christen

Server:
xinit (for no window manager (get from client)
or startx (includes window manager, in cygwin it integrates nicely with XP)
with CygWIn you can run C:\cygwin\usr\X11R6\bin\startxwin.bat without first starting Cygwin

xhost IPofXClient
or
xhost + (allows ANY client)

Client:
DISPLAY=IPofServer:0.0
export DISPLAY

AnyXProgram &

You can use a window manager from the client like thus:
openbox &
or just run a single program like a terminal on the client:
aterm &
xterm &

be sure to & the programs so that you don’t loose your prompt.

Dump Man pages to Word

Filed under Unix Notes on Monday, February 27th, 2006 @ 4:48pm by Christen

Dump text formatted man pages for all commands in /usr/sbin starting with mk* to testmans:
ls -1 /usr/sbin/mk* | cut -d’/’ -f 4 | xargs -l man | col -b >> testmans

There are lines that appear at the top/bottom of every man page. You may want to use grep to eliminate these.
use grep SOMETEXTINLINE file to see if it gets the right thing, then “grep -v SOMETEXTINFILE file > newfile” will output all lines WITHOUT that text to the new file.

Items to consider using to grep out extra lines:
“Hewlett-Packard Company” - Gets rid of page break fillers between pages on HPUX
‘(1M).*(1M)$’ - only want the ones with two occurences, one at the end of the line, b/c those are at every page top also.

Like so:
grep -v “Hewlett-Packard Company” testmans > testmans1
grep -v ‘(1M).*(1M)$’ testmans1 > testmans

Or put them onto one line if you are confident:
grep -v “Hewlett-Packard Company” testmans | grep -v ‘(1M).*(1M)$’ > testmans1;rm testmans

Open the file in winword and accept “Windows (Default)” as the Text encoding

Knock your top & bottom margins down to the minimum
(Adjusting the left/right margins will likely make no difference, so don’t bother)
(For very small jobs, you could leave top and bottom if you like, I’m usually working close to 100 page though)

Replace: ^p^p^p
with: ^p
-Do this repeatedly. The first time the page count may cut in half. After that you’ll get diminishing returns. Keep doing it until you either get 0 replacements, or the same number repeatedly. Sometimes there will be a string at the bottom of the document that can’t be removed this way.

Finally, make sure there are no blank pages at the end.

Scroll through the document and make sure it doesn’t have any huge white space sections.

Print if you like!

HPUX ServiceGuard Cluster Manager

Filed under Unix Notes on Monday, February 27th, 2006 @ 4:38pm by Christen

HPUX ServiceGuard Cluster Commands and “Patching” example:

First off, read the man pages. There aren’t that many, and they aren’t that long:

ls -1 /usr/sbin/mk* | cut -d’/’ -f 4 | xargs -l man | col -b >> clustermanpages
(See article on how to dump man pages to Word also.)

A node is a computer and a package is the application that runs on a node.

The cluster is two or more systems that see some of each others disks and can run each others applications.

The application, or package, can only be run on one node at a time. All of the cmxxx commands can be run on either node and you will get the exact same output regardless of which node you issue the command on.

cmhaltnode is very friendly and safe according to the man pages. Run on it’s own, it won’t halt the node if any packages are running on it. If you use the -f option, it will halt the packages first and then they will start on the other node (if failover is set). If a package fails to halt, then cmhaltnode will fail. It won’t stop a node with a package running on it.

Moving packages - There isn’t really a “move” command. The man pages say to move a package like this: (say from node 1 to 2)

cmhaltpkg package1
cmrunpkg -n node2 package1
cmmodpkg -e package1
(Note, both the halt and run commands will operate on the package no matter what node it is on, if a node isn’t given with the -n command)
(See note below for purpose of cmmodpkg)

cmhalt may confuse you. When it is run, the cluster knows it, and assumes you meant what you said, so it will not “fail over” to another node. Failover only happens when the package fails for other reasons, or if you use the cmhaltnode program with the -f option, which does allow them to move over.
In fact, due to this, after moving a package manually, you need to reenable package switching for the pacakge with “cmmodpkg -e packagename” since cmhaltpkg disabled package switching for that package. You can see the status of package switching with cmviewcl.

One issue is Failback. If it is set to “auto” on any package, it could present a problem. When your node comes back up, packages may unexpectedly fall back onto it.
Run:
cmviewcl -v | grep Failback
will list all of the Failback settings. If they all say “manual” then you are in good shape, because a package will not move back to its primary node without  manual intervention.
It is possible to use cmmodpkg to tell the packages that they may not move to a given node, which would help you in this case. See the man page for cmmodpkg

Before doing anything crazy, you should do a cmviewcl and a cmviewcl -v and copy down the info. That way you can see how things were set up before.

When you are done, do a cmviewcl -v and make sure “PKG_SWITCH” is enabled for all packages. It is possible for the cmhaltpkg to disable this on some of them, and for you to forget to put it back.
Here are some tests. These should come back with nothing:
cmviewcl -v | grep disabled
cmviewcl -v | grep down
These should come back with everything:
cmview -v | grep enabled
cmview -v | grep up
Check to see that everyone is running on their primary server:
cmviewcl -v | grep Primary
Run cmview -v through MORE also, and just look to see that it all looks right.

You should find out from application contact what order the package should go down and up in. 99.9% of the time the order does NOT matter. Common sense says the come up 1,2 3 and go down 3 2 1. On this box pkgftp* can go down anytime and pkg01-05 - go down in reverse and up in order.

cmviewcl

CLUSTER STATUS
clustername-cl5 up

NODE STATUS STATE
server1 up running

PACKAGE STATUS STATE PKG_SWITCH NODE
pkg01 up running enabled server1
pkg02 up running enabled server1
pkg03 up running enabled server1
pkg04 up running enabled server1
pkg05 up running enabled server1
pkgftp1 up running enabled server1

NODE STATUS STATE
server2 up running

PACKAGE STATUS STATE PKG_SWITCH NODE
pkg06 up running enabled server2
pkg07 up running enabled server2
pkg08 up running enabled server2
pkg09 up running enabled server2
pkg10 up running enabled server2
pkgftp2 up running enabled server2

So, as root from any member of the cluster:
(I suggest that you do a cmviewcl between these commands periodically to make sure that what you expect to happen is actually happening.)
cmhaltpkg pkgftp1
cmrunpkg -n server2 pkgftp1
(better to do it this way than just downing the node, unless you really feel cool, in which case, you could technially just do a ‘cmhaltcl server1′ and all packages should move over to server 2 automatically. See the man page.)
cmhaltpkg pkg05
cmrunpkg -n server2 pkg05
cmhaltpkg pkg04
cmrunpkg -n server2 pkg04
cmhaltpkg pkg03
cmrunpkg -n server2 pkg03
(you can’t hardly mess up these commands, they will complain if you tell it to do the wrong thing)
cmhaltpkg pkg02
cmrunpkg -n server2 pkg02
cmhaltpkg pkg01
cmrunpkg -n server2 pkg01
(Some boxes can take 30 minutes per package! Some boxes take 45 minutes to move stuff over!)
(The command will hang there until it is done moving the package, so that is one good reason to do them one at a time.)
(Remember, the order may be important, so ask the app contact ahead of time!)
cmmodpkg -e pkg01 pkg02 pkg03 pkg04 pkg05 pkgftp1
(Turns the enable for failover back on for all packages.)
(This should be done if there is a 3 node cluster, so that they can fail to node 3, otherwise they cannot fail over to  anywhere after this)
(By reenabling it, if the other node did go down after your patched node came back up, they could come over to it before you  did it. My trainer had this happen once, where his patched server came back up and then suddenly pakcages came to it, b/c another  box failed on him suddenly during the patching window)
(The cmhaltpkg command automaticall disables the “pkg_switch” option, as you will see in a cmviewcl display. This is covered in the man page for cmhaltpkg. The concept is that if you halt a package manuall, you don’t want it to go starting up anywhere, you want it to stay halted, or to start where you put it and stay there.)
(Also, you may get patrol alerts if the pkg_switch id disabled)

cmhaltnode server1

cmviewcl
(may take a few minutes, before the node finished reforming (reads soem files)) before cmviewcl shows things properly

shutdown -y 0, or whatever it is you need to do.

After the server comes back up, the cluster will come up by itself (remember, you halted it), but the packages should not move over to it, UNLESS you have AUTO_FALL_BACK set on, and the PKG_SWITCH is enabled.

(Some clients let the SA edit the pkg files, some clients don’t want the SA to mess with them at all.)

When moving packages BACK to their home server, you can use a little trick. Just cmhaltpkg the package, that halts it and disables the PKG_SWITCH, then just do a ‘cmmodpkg -e pacckage’ and it will automatically start back up, on the package’s primary server. You get to skip the ‘cmrunpkg -n server package’ command for each package.

cmhaltpkg pkgftp1
cmmodpkg -e pkgftp1

cmhaltpkg pkg05
cmmodpkg -e pkg05

cmhaltpkg pkg05
cmmodpkg -e pkg05

(Only downside here is the cmmodpkg comes back before the package has started, unlike the cmrunpkg, so you have to use cmviewcl to see when the package has started up.)

you can also:

cmhaltpkg pkg03 pkg02;cmmodpkg -e pkg03 pkg02

to save a little typing

(One cool note, if you are patching or upgrading boxes, moving all of the packages to server1 after you patched it and before you patch server2, and then testing the application gives you a quick and dirty real world test of whether whatever you did will break the application before you upgrade server2. If it does break the application right away, then you have server2 still in pre-broken state, so you can just move things there while you roll back server1.)

Cheat Sheet

Filed under Unix Notes on Monday, February 27th, 2006 @ 3:51pm by Christen

This is common stuff that I always forget at the wrong moment, so I print this and put it on my wall at work.

shell :

To see what shell you are using (being in just “sh” explains a lot):
echo $SHELL

Make vi your command line editory:
set -o vi
Or, if you are still in sh, to switch to ksh and set vi as the command line editor:
ksh -o vi

crontab:
minutes(0-59) hours(0-23) dates(1-31) months(1-12) days(0-6)
* * * * * command

Set your backspace key to work:
stty erase BACKSPACE
(It may be you just need to switch how Putty is set up)

Set CTRL-Z to suspend job:
stty susp ^Z

Set other Terminal parameters:
stty rows 80
stty cols 25
export DISPLAY=vt100

Command line completion:
HPX: ESC\ or ESC ESC
SUN: ESC\
AIX: ESC\
ABOVE: ESC= - List all options ESC* - Put all options on command line
LNX: TAB

vi:

h - left
j - up
k - down
l - right

i – insert
a - append (A - append at end of line)
x - delete
X - backspace

0 - start of line (or is it ^ ?)
$ - end of line

b - back word
w - forward word

CTRL-H - backspace

/ - search
n - next instance

Other handy vi commands:

#g - go to line # of file
G - last line of file

o - open a line below me to type in
O - open a line above me to type in

u - undo

:1,$ s/4/john/g - from first line to last line of file, search for 4 and replace with john globally (all instances on the line)

yy - yank the line (copy)
dd - cut current line
p - paste (below) P - Paste (above)

:x! - (as ROOT) write and quit, even Read-Only files

Firefox:
F7 - Carret Browsing - select text w/ keyboard
/ - search
‘ - Search only links

Simple awk lines I always use but never remember:

awk ‘{ print $3 }’ = cuts column 3
awk ‘/dev/{print $2}’ = print /dev/ with column 2
c=’$'$n;awk “{print $c}” = print column $n
More awk stuff:
http://mattwalsh.com/twiki/bin/view/Main/AwkTutorial

banner test > /dev/console

On the Sidelines

Filed under Personal on Monday, February 20th, 2006 @ 12:05pm by Christen

A friend of mine was recenlty killed in Iraq. I wasn’t particularly close to him. In fact, I knew his sisters much better than him. His death is one of those things that I look at more like something disturbing on the evening news, than as a personal tragedy.

I do however feel very deeply for his family who is left behind. Unfortuantly, because I neither share in their personal grief over the loss, because I was not close to him, nor do I have any personal experience of such a loss that will allow me to relate, nor is my friendship with them quite close enough to be the shoulder they might cry on, I am basically just a bystander.

It is very odd to just stand on the side, and watch people that you love suffer. I feel like I am in this place a lot though. It is how I felt about hurricane Katrina. Having lived there before, I felt the tragedy and loss very greatly, but now living in Kansas, I cannot personally participate in the grief. Just standing on the sidelines, watching people I love in great pain.

When we see a car wreck, we all naturally want to help, but most of us don’t really have the knowledge or resources to be much of any help. I struggle back and forth over whether my feelings are of a sincere wish that these people could be helped, or whether they are simply selfish feelings of wishing that I could somehow be some sort of hero. I don’t suppose it really matters what the cause is, and probably it is both.

Not My Faultism?

Filed under Personal on Monday, February 20th, 2006 @ 10:43am by Christen

I really get irritated by people who don’t take resonsibility for their lives. If you talk to me much, you probably know that. It drives me nuts to see people who just meander through life, wondering why it treats them the way it does, instead of taking it by the reins and living life on purpose.
It has recently occured to me, though, that calvinism may really be a way for people to do this, and claim they are backed by the Scriptures in this way of going about life.

Could calvinism really just be an excuse to abandon personal responsibility?

I consider myself to be somewhat* of a calvinist, so this occurance bothers me a bit. The only thing more fun than defending my position, though, is rethinking it. =)

*I know, accepting SOME of the five points, but not all of them is considered illogical by most, but that is an issue for another post.

Scientology

Filed under Personal on Monday, February 20th, 2006 @ 10:40am by Christen

Wow, I am stunned. How can these people even exist?

Personally, I find it somewhat difficult to exist, as a believer in Jesus Christ, in a world that demands physical proof for any and everything. However, I believe that the difficulty is a good one. I would rather people be sceptical, than wishy-washy. Of course, the funny thing is, most people believe a huge number of falsehoods everyday that are not substantiated by any physical evidence. Things like, “If you buy this big screen TV, you will be happy.” =)

However, I had absolutely no idea just how wacky Scientology was! They are absolutely insane. The stuff is not even good science fiction.

Start here for a good shock at the weirdness, and then go to the front of the book and read it all if you have time. If nothing else, it will allow you to know what it is when you hear about it.

I always thought they were harmless weirdos with boxes, but they are crazy!

Kill Usage

Filed under Unix Notes on Monday, February 20th, 2006 @ 9:38am by Christen

kill -HUP PID
kill -TERM PID
kill -KILL PID
(I did not write this, I just found it and posted it here for my own reference.)
Why does everyone jump straight to -9?

DO NOT USE -9 AS YOUR FIRST KILL SIGNAL.

Try a nice friendly -HUP … perhaps a little stronger -TERM.

If, for some reason, these don’t work, knock a little louder with -KILL (ie: -9), but don’t whine if something else gets hosed due to the strong signal (not to scare anyone, it’s unlikely that anything critical is happening anyway, any more than just writing a file– but you could leave resources locked/in use (ie: memory, etc)).

Also, use -HUP and -TERM and -KILL …. you’ll be thankful when you miss your kill -1 and do a kill 1 instead … you’ll use -HUP from then on (well, maybe not on a pda, but on a production server etc.)

UNIX kill signals

Signal
Name

Signal
Number

Action

HUP

1

Hangup

INT

2

Interrupt

QUIT

3

Quit (dumps core file)

ILL

4

Illegal instruction (dumps core file)

TRAP

5

Breakpoint trap (dumps core file)

IOT

6

I/O trap (dumps core file)

EMT

7

Emulator trap (dumps core file)

FPE

8

Floating Point Exception (dumps core file)

KILL

9

Kill with extreme prejudice

BUS

10

Bus error (dumps core file)

SEGV

11

Segment Violation (dumps core file)

SYS

12

Bad system call argument (dumps core file)

PIPE

13

Write to nonexistent pipe

ALRM

14

Alarm clock timeout

TERM

15

Terminate

USR1

16

User defined signal

USR2

17

User defined signal

CHLD

18

Child status (aka CLD)

PWR

19

Power failure or restart

WINCH

20

Window size change

URG

21

Urgent socket condition

IO

22

Socket I/O (aka POLL)

STOP

23

Stop from non-tty process (see CONT)

TSTP

24

Stop from tty process (see CONT)

CONT

25

Continue a stopped process

TTIN

26

Waiting for background tty input (see CONT)

TTOU

27

Waiting for background tty output (see CONT)

VTALRM

28

Virtual alarm timeout

PROF

29

Profiling timeout

XCPU

30

CPU time limit exceeded (dumps core file)

XFSZ

31

File size limit exceeded (dumps core file)

Powered by WordPress