Install packages into zone with alternative basedir

March 11th, 2010

Recently I was on the task to install package into the zone. Those packages were from SFW, and where using /usr, which I inherited from global zone. To get past this, decision was made to install the package into another dir, which is called basedir. Lets make it more clear with examples:

We have an package:


# ls
db-4.2.52.NC-sol10-sparc-local

Try to install it:


# pkgadd -d db-4.2.52.NC-sol10-sparc-local

The following packages are available:
1 SMCdb db
(sparc) 4.2.52.NC

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: all

Processing package instance SMCdb from

db(sparc) 4.2.52.NC
Sleepycat Software

The selected base directory must exist before
installation is attempted.

Do you want this directory created now [y,n,?,q] y
pkgadd: ERROR: unable to make directory .

Installation of SMCdb failed (internal error).

By default, pkgadd command reads “/var/sadm/install/admin/default”, which specifies the base directory in which to install software. Let`s create alternative one for our needs!


# echo "basedir=/apps/$PKGINST" > /var/sadm/install/admin/custom

and use it with pkgadd command to get this package installed into new directory:


# pkgadd -a custom -d db-4.2.52.NC-sol10-sparc-local
...
/apps/SMCdb/BerkeleyDB.4.2/docs/utility/db_verify.html
/apps/SMCdb/BerkeleyDB.4.2/docs/utility/index.html
/apps/SMCdb/BerkeleyDB.4.2/include/db.h
/apps/SMCdb/BerkeleyDB.4.2/include/db_185.h
/apps/SMCdb/BerkeleyDB.4.2/include/db_cxx.h
/apps/SMCdb/BerkeleyDB.4.2/lib/libdb-4.2.a
/apps/SMCdb/BerkeleyDB.4.2/lib/libdb-4.2.la
/apps/SMCdb/BerkeleyDB.4.2/lib/libdb-4.2.so
/apps/SMCdb/BerkeleyDB.4.2/lib/libdb-4.so
/apps/SMCdb/BerkeleyDB.4.2/lib/libdb.a
/apps/SMCdb/BerkeleyDB.4.2/lib/libdb.so
verifying class none

Installation of SMCdb was successful.

Thats it! No we just need to tweak the $PATH to make it easily accessible.

OK prompt and link on server NIC

March 4th, 2010

I have received an Sun Fire 440 server to install, though only info I had for it was the ALOM password. To JumpStart/JET this server, I need to know what NIC`s have the link attached to them, and their corresponding MAC addresses. A little bit of black magic and googling - and that`s the way to get the NIC list on the server, theirs link status and MAC addresses.

Let`s go:

- get the list of the NICs at the server:


{1} ok show-nets
a) /pci@1d,700000/network@2,1
b) /pci@1d,700000/network@2
c) /pci@1d,700000/pci@1/network@3
d) /pci@1d,700000/pci@1/network@2
e) /pci@1d,700000/pci@1/network@1
f) /pci@1d,700000/pci@1/network@0
g) /pci@1f,700000/network@2,1
h) /pci@1f,700000/network@2
q) NO SELECTION
Enter Selection, q to quit: c

- get the MAC address of the selected NIC:


{1} ok show-nets
a) /pci@1d,700000/network@2,1
b) /pci@1d,700000/network@2
c) /pci@1d,700000/pci@1/network@3
d) /pci@1d,700000/pci@1/network@2
e) /pci@1d,700000/pci@1/network@1
f) /pci@1d,700000/pci@1/network@0
g) /pci@1f,700000/network@2,1
h) /pci@1f,700000/network@2
q) NO SELECTION
Enter Selection, q to quit: f
/pci@1d,700000/pci@1/network@0 has been selected.
Type ^Y ( Control-Y ) to insert it in the command line.
e.g. ok nvalias mydev ^Y
for creating devalias mydev for /pci@1d,700000/pci@1/network@0
{1} ok cd /pci@1d,700000/pci@1/network@0
{1} ok .properties
...

network-interface-type ethernet
device_type network
name network
local-mac-address 00 03 ba db 80 1b

...

- get the link status of the selected NIC:


{1} ok apply watch-net /pci@1d,700000/pci@1/network@2
/pci@1d,700000/pci@1/network@2: link down
{1} ok apply watch-net /pci@1d,700000/pci@1/network@1
/pci@1d,700000/pci@1/network@1: link down
{1} ok apply watch-net /pci@1d,700000/pci@1/network@0
/pci@1d,700000/pci@1/network@0: 1000 Mbps full duplex link up
Watch ethernet packets
'.' is a good packet and 'X' is a bad packet
Press any key to stop

Aha! Seems like network@0 is the NIC to boot from. Booting from a specific NIC is very easy:


{1} ok boot /pci@1d,700000/pci@1/network@0 -v

-v is for verbose.

That`s it, this info is enough to get info needed to jumpstart server :D

Take care!

SSH no kex alg

February 27th, 2010

Having recently JumpStarted an new server, I found it unable to login via ssh


root@chiscadm01~# ssh 10.23.3.103
no kex alg

Solution was to regenerate the SSH keys on that server


# /lib/svc/method/sshd -c
# svcadm refresh ssh

and voila! It works as it should.

Cheers!

Shell useful tricks (basic stuff)

February 26th, 2010

Nice tricks with shell, I discovered in internet darkest corners :)

Credits & kudos goes to:

Prentice Bisbal

Brace expansion takes a list of strings separated by commas and expands those strings into separate arguments for you. The list should be enclosed by braces.


# echo {1,2,3,4,5}
1 2 3 4 5

# cp .zshrc{,_backup}
# ls | grep .zsh
.zshrc
.zshrc_backup

Command substitution - enclose any command that generates output to standard output inside parentheses and precede the opening parenthesis with a dollar sign, $(command).


echo $(aptitude search mc | grep cube)
p wmcube - spinning 3D object that shows the current

new syntax
echo `aptitude search mc | grep cube`
p wmcube - spinning 3D object that shows the current

Error redirect will redirect all errors to the /dev/null, or file of yourchoise (this is based on the file descriptors, google around if you interested).


# find / -name hzchetakoe 2> /dev/null

Route error output to normal output.

# find / -name hzchetakoe > output.txt 2>&1

Bash loops work like this:


for i in `cat hosts.txt` ; do ssh $i "uname -a" ; done

Shell snooping with DTrace

February 24th, 2010

Lurking around the inet, getting info about Solaris Audit - I stumbled upon this wonderful DTrace script. What it basically do - is to snoop all activity around shells, such as keystrokes and command outputs. Very handy indeed, smth like BSA for cheap :)

Grab the script here.

Kudos goes to the author!

vSphere 4 implementation videos

February 5th, 2010

Lurking around internet, I found this wonderful free videos about VMWare ESX 4. Nicely shown, thanks!

Link to the videos

Attach disk to the ZFS root mirror pool

January 28th, 2010

Having broke root mirror pool, trying to migrate it to RAID-Z to boot from (until I figured out, that booting from RAID-Z is not yet supported in Solaris, but works in Free-BSD - WTF!!?!?), I was forced to put disk back into root mirror pool...but failed. That`s what have I done to fix this:



-bash-3.00# zpool attach rpool c0t0d0 c0t1d0
cannot label 'c0t1d0': EFI labeled devices are not supported on root pools.



-bash-3.00# prtvtoc /dev/rdsk/c0t0d0s0 | fmthard -s - /dev/rdsk/c0t1d0s0
fmthard:  New volume table of contents now in place.
-bash-3.00# zpool attach rpool c0t0d0s0 c0t1d0s0
Please be sure to invoke installboot(1M) to make 'c0t1d0s0' bootable.

-bash-3.00# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c0t1d0s0
-bash-3.00# zpool status
pool: rpool
state: ONLINE
scrub: resilver completed after 0h5m with 0 errors on Thu Jan 28 17:22:02 2010
config:
NAME          STATE     READ WRITE CKSUM
rpool         ONLINE       0     0     0
mirror      ONLINE       0     0     0
c0t0d0s0  ONLINE       0     0     0
c0t1d0s0  ONLINE       0     0     0  6.00G resilvered
errors: No known data errors

That`s it! Works, up and running.

PS - sun.com is gone...being an rational man I do believe, that Oracle will get most of Sun`s great engineers with Oracle`s sales managers (`cos Sun`s sales are the worst ever, and Johnny Schwartz should be banned from IT forever), and I wish that Solaris/Oracle will make an great deal. Godspeed!

 

Solaris Infrequently Asked and Obscure Questions

January 14th, 2010

Perfect information for unix admin to read through, absolutely worth reading! Get it here.

 

 

Nokia 5530 issues with Media Library

January 1st, 2010

Post completely unrelated to Solaris :>>

 

I do have this baby - and it rock! Nice OS, 200$, mp3 playback at the mid-range PMP device level and nice design is giving me faith to Nokia.

5530

 

 

But today I had first issues with music library - I grabbed some album from inet, unpacked it - but it was flacky, so I removed it physically from Memory card - but it didn`t dropped down from Player, not allowing me to get rid from it, nor delete it from within the Player. Googling a little, I figured the way to make your Nokia (5530 in particular) to forcefully totally refresh the musical library. This instructions helped me - they could help you:

 

Manually remove deleted artists from Music Library
1. Connect your 5800 to you PC in Mass Storage Mode

2. On your PC you will need to have allowed to "Show" hidden files, do this from Explorer/Tools/ Folder Options/ View and select "Show hidden files and Folder"

3. Open your SD memory card/Removable Disk in My Computer on PC

4. Go to E:\ Private there you will see 3 folders 101f8857, 101ffca9 and 10281e17 . Shown below left.

5. Go to Private\101f8857\Cache\E there you will see .dat files. Delete all the .dat file BUT NOT the E Folder. 

6. Now go to Private\101ffca9 there you will see another .dat file, Delete the dat file NOT the folder. Shown below Left.

7. Finally go to Private\10281e17 There you should see 4 files 2 are Mp3 files other are Podcast files. Delete mpxv2_2.db & mpxv2_2.db-journal for Mp3 files list and Delete pcv6_1.db & pcv6_1.db-journal for Podcast files list. Shown above right

8. Close all windows and disconnect your Phone. Go to Music Library and it should automatically start a refresh.


When user has last changed his password in Solaris

December 24th, 2009

Title says it all.  Since, the date of last change of password is in /etc/shadow:

 

root:x:14602::::::

That means, that root has last changed his password 14602 days after beginning of unix epoch, i.e. 1 Jan 1970.

But we need to convert this into normal date, and almost all converters think, that this number is in seconds, not days. To do this, this perl script will be handy (thanks to someone, I found this on inet):

 

#!/usr/bin/perl

# Output date format is YYYY-MM-DD

open( S, "/etc/shadow" );

while( <S> )

{

($user,$lastchg) = (split /:/)[0,2];

@t = localtime( $lastchg*86400 );

printf "User %-8s last changed password %0.4d-%0.2d-%0.2d (%5d)\n",

$user, $t[5]+1900, $t[4]+1, $t[3], $lastchg;

}

close( S );

exit 0;

 

Handy instrument indeed!

Zones related commands

December 16th, 2009

Digging through internet while deep-diving into Solaris zones, I have found few interesting commands, that related to the zones. Worth checking out:

zonename - prints the name of the current zone

ifconfig e1000g0:1 -zone zone01 - get the IP for this Virtual NIC back to the global zone from the local zone01

ifconfig e1000g0:1 zone zone01 - vice versa, i.e. get the IP from the global zone, attached to this VNIC to the local zone01

ifconfig -Z - executes command for all interfaces in the users zone

ipcrm -z <zonename> - deletes a message queue, a semaphore set or a shared memory ID of a zone

patchadd/pkgadd -G - install patch/package only in global zone

pkill -z <zoneID> - pkill applied to that zone

poolbind -i zoneid <zonename> - attach all processes in that zone to the pool

prctl -i zoneid <zonename> - Displaying and modification of resource controls of zone processes

priocntl -i zoneid <zonename> - Displaying and changing the scheduling parameters in a zone.

rctladm - Displaying and modification of global settings for resource controls

renice -i zoneid <zonename> - modifies the priority of the processes inside the zone

df -hZ - display zone mounts

ipcs -z - displays interprocess communication parameters of a zone

pgrep -z <zoneid> - grep through processes inside the zone

prstat -z <zonename> - show info re processes in particular zone

prstat -Z - show info re global zone AND local zones in the bottom

ps -z <zonename> -  show info re processes in particular zone

ps -Z - display the zone process belongs to



Solaris 10 container guide

December 2nd, 2009

Very nice and worth-to-read document about the containers in Solaris 10, best practices and how-to`s. Definatley worth to check it here.

IPMP configuration on Solaris

November 21st, 2009

Take a read through this wonderful article on IPMP configuration in Solaris! Highly recommended.

 

http://saifulaziz.wordpress.com/2009/05/08/configuring-ip-network-multipathing-on-solaris/

Solaris Volume Manager recovery of metdb on Solaris 9

November 12th, 2009

We had an sad issue, when someone was patching v240 with Solaris 9 with some patch cluster, and accidently everything went nuts. Maybe not making reconfigure reboot, but just ordinary one cause this, I don`t know - we were seeing this horror after reboot:

 

Rebooting with command: boot
Boot device: disk  File and args:                                              
SunOS Release 5.9 Version Generic_122300-42 64-bit                             
Copyright 1983-2003 Sun Microsystems, Inc.  All rights reserved.

Use is subject to license terms.                                               
sorry, variable 'ssfcp_enable_auto_configuration' is not defined in the 'fcp' mo
dule                                                                           
Cannot mount root on /pseudo/md@0:0,0,blk fstype ufs                           

panic[cpu1]/thread=140a000: vfs_mountroot: cannot mount root


0000000001409970 genunix:vfs_mountroot+70 (0, 0, 0, 200, 1472178, 0)           
%l0-3: 0000000001465800 0000000001465800 0000000000002000 00000000014af400   
%l4-7: 00000000014b5000 0000000001411e88 0000000001466000 0000000001469400   
0000000001409a20 genunix:main+90 (1409ba0, f005bf10, 1409ec0, 395dac, 2000, 500)
%l0-3: 0000000000000001 000000000140a000 0000000001413048 0000000000000000   
%l4-7: 0000000078002000 000000000039e000 00000000014bdc10 0000000001067f00   

skipping system dump - no dump device configured                               
rebooting...


Googling on this issue led to conclusion, that metadb went nuts to some reason, and now system cannot correctly startup. To resolve this issue we need to boot system off net or dvd, mount HDD with root on it, tweak some files responsible for metadb and SVM in general, recreate metadevices & metadb, reattach them and restart.

So, let`s go:

1. Boot system from net (in my case I have JET server in same subnet)

 

{l} ok boot net -s

2. Mount root slice of one of the HDD`s that were used in / partition

# mount /dev/dsk/c1t0d0s0 /mnt

3. Modify /mnt/etc/system file to delete (or comment with * symbol) everything between

 

 

 

Begin MDD root info (Do not edit this line.)

End MDD root info (Do not edit this line.)

4. Modify the /mnt/etc/vfstab file to replace or comment all the /dev/md/dsk entries with /dev/dsk, i.e like this one:

 

 

#/dev/md/dsk/d0   /dev/md/rdsk/d0   /   ufs   1   no   logging
/dev/dsk/c1t0d0s0   /dev/rdsk/c1t0d0s0   /   ufs   1   no   logging

You could consult the format command for partition / slice info for particular HDD.

5. Solaris Volume Manager is using three files for SVM configuration: /kernel/drv/md.conf, /etc/lvm/mddb.cf, and /etc/lvm/md.cf. Overwrite two last of them files from a system that does not use Solaris Volume Manager, and in the first one delete everything except for the first uncommented line, i.e. leave only this uncommented line:

name="md" parent="pseudo" nmd=128 md_nmsets=4;

6. Be sure, that you have both / and swap partitions enabled to load from HDD in vfstab, and restart server & boot from this HDD

 

 

init 0

{1} ok boot disk0

7. So, you`re booted into server, good! Now, we`ll need to recreate all metadevices, since I had RAID1 (mirror), I need to create metadb, mirrors, make root mirrored and bootable and put new devices in /etc/vfstab.

8. Creating metadb

 

 

metadb –a –c 3 -f c1t0d0s7 c1t1d0s7

9. Create metadevices - submirrors for root partition

metainit -f d10 1 1 c1t0d0s0 && metainit -f d20 1 1 c1t1d0s0

10. Create metadevice - main mirror for root partition (we`ll add only one submirror, and later after reboot we`ll attach another for resync)

metainit d0 -m d10

11. Make root mirror bootable (only needed for root mirror!)

metaroot d0

12. Repeat steps 9-10 for any mirror that needs to be created alongside with their submirror

13. Revert /etc/vfstab for it to be again using md pathes to metadevices, i.e. like this:

#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
fd      -       /dev/fd fd      -       no      -
/proc   -       /proc   proc    -       no      -
/dev/md/dsk/d1  -       -       swap    -       no      -
#/dev/dsk/c1t0d0s1      /dev/rdsk/c1t0d0s1      -       swap    -       no      -
/dev/md/dsk/d0  /dev/md/rdsk/d0 /       ufs     1       no      logging
/dev/md/dsk/d3  /dev/md/rdsk/d3 /var    ufs     1       no      logging
#/dev/dsk/c1t0d0s3      /dev/rdsk/c1t0d0s3      /var    ufs     1       no      logging
/dev/md/dsk/d5  /dev/md/rdsk/d5 /apps   ufs     1       no      logging
#/dev/dsk/c1t0d0s5      /dev/rdsk/c1t0d0s5      /apps   ufs     1       no      logging
swap    -       /tmp    tmpfs   -       yes     -

14. Reboot (you could issue reconfiguration reboot, just to be sure, and you should be again in your system with svm mirrors attached.

15. Attach submirror to every mirror, to launch resync procedure:

metattatch d0 d20

16. Repeat step 15 for every mirror

17. Check the metastat output, you should see every mirror has submirrors, which are resyncing

18. Grab a beer - you deserve it! B)

 

MAC address from OBP prompt

November 11th, 2009

When you are Jumpstarting/JET`ing server, the first info you`ll need is the MAC address of the interface you`ll be using as primary for client.


To get MAC address of the primary interface from OBP use this command:

 

 

{1} ok .enet-addr

0:3:ba:d2:96:cf

 

Cheers!

 

Squid log rotation with timestamp

November 6th, 2009

I had a task on implementing the Squid log rotation, but with timestamps. System was on Solaris - but logadm wasn`t the chosen weapon for this task, and we moved to the squid internal capabilities on logs rotation. Only task was to add the timestamp, which also was done.

I hope, someone will find this useful.

 

 

 

- rotatelogs.sh- will force the Squid to rotate logs, timestamp them


#!/bin/bash
# this script rotates squid logs hourly and renames with a timestamp
/usr/local/squid/sbin/squid -k rotate
sleep 10
mv /var/log/squid/access.log.0  /var/log/squid/access.${NOW:=$(date +"%m-%d-%Y_%H_%M")}.log
mv /var/log/squid/cache.log.0 /var/log/squid/cache.${NOW:=$(date +"%m-%d-%Y_%H_%M")}.log
chmod +r /var/log/squid/*

 

How to migrate from dying system disk to new one in Solaris

November 4th, 2009

If your HDD with system is dying, you have the same HDD (in matter of size), and you`re using UFS - you could do the next steps to completly recreate this disk to a new one:


1. Check the disks (with attached new one):

# format

2. Copy the VTOC from old one to a new one:

# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c1t0d0s2

3. Create new filesystem:

# newfs /dev/rdsk/c1t0d0s0

4. Mount slice to copy to:

#mount /dev/rdsk/c1t0d0s0 /mnt

5. UFSdump from old slice to a new mounted one:

# ufsdump 0f - /dev/rdsk/c0t0d0s0 | (cd /mnt && ufsrestore rf - )

6. Umount the new slice, with dumped information from from old one:

# umount /mnt

Steps 3 - 6 should be repeated for each slice to migrate.

7. Install bootblocks into a new disk partition:

# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t0d0s0

 

That`s it, grab a beer ;D

Change failed hdd in submirror in Solaris Volume Manager (SVM)

November 3rd, 2009

I had an hdd failed in SVM. Well, nothing special - everyone met this situation, when output like this on prod box scare you as hell:

 

 

 

 

# iostat -En

 

 

...

c1t0d0          Soft Errors: 607 Hard Errors: 122 Transport Errors: 130
Vendor: SEAGATE  Product: ST373207LSUN72G  Revision: 065A Serial No: 054432ZX97
Size: 73.40GB
Media Error: 99 Device Not Ready: 0 No Device: 11 Recoverable: 607

Illegal Request: 0 Predictive Failure Analysis: 9
c1t1d0          Soft Errors: 0 Hard Errors: 2 Transport Errors: 5

Vendor: FUJITSU  Product: MAT3073N SUN72G  Revision: 0602 Serial No: 0517B04DKE
Size: 73.40GB
Media Error: 0 Device Not Ready: 0 No Device: 1 Recoverable: 0
Illegal Request: 0 Predictive Failure Analysis: 0
c1t2d0          Soft Errors: 60 Hard Errors: 119 Transport Errors: 78
Vendor: SEAGATE  Product: ST373207LSUN72G  Revision: 065A Serial No: 064135KFJE

Size: 73.40GB
...

 

Well, what are this "errors" stuff is about?


Device Not Ready: The drive returned the sense key 0x2 (Not ready).

Media Error: The drive returned the sense key 0x3(Medium Error).

No Device: The drive returned the sense key 0x6 (Unit Attention) or in the case of a removable device it must have happened multiple times.

Hard Errors: All the above conditions are counted as Hard errors with the addition of the SCSI sense key 0x4 (Hardware Error).

Illegal Request: The drive returned the sense key 0x5 (Illegal Request). This also treats as a Soft Error and that kstat is also incremented.

Recoverable: The drive returned the sense key 0x1 (Recovered Error) to indicate that the last command completed successfully but some recovery action had to be taken by the drive. This also treats as a Soft Error and that kstat is also incremented.

Predictive Failure Analysis: The drive returned sense key 0x6 (Unit Attention) with and ASC (Additional Sense Code) of 0x5D indicating that the drive has exceeded it's predictive failure threshold. This is treated as a soft error.

Transport Error: This error occurs for a number of reasons all related to being unable to transport the command. The command could have been timed out or reset or the host bus adapter unable to put the command onto the SCSI bus. This is neither as soft nor a hard error.

 

Device Not Ready: The drive returned the sense key 0x2 (Not ready).

Media Error: The drive returned the sense key 0x3(Medium Error).

No Device: The drive returned the sense key 0x6 (Unit Attention) or in the case of a removable device it must have happened multiple times.

Hard Errors: All the above conditions are counted as Hard errors with the addition of the SCSI sense key 0x4 (Hardware Error).

Illegal Request: The drive returned the sense key 0x5 (Illegal Request). This also treats as a Soft Error and that kstat is also incremented.

Recoverable: The drive returned the sense key 0x1 (Recovered Error) to indicate that the last command completed successfully but some recovery action had to be taken by the drive. This also treats as a Soft Error and that kstat is also incremented.

Predictive Failure Analysis: The drive returned sense key 0x6 (Unit Attention) with and ASC (Additional Sense Code) of 0x5D indicating that the drive has exceeded it's predictive failure threshold. This is treated as a soft error.

Transport Error: This error occurs for a number of reasons all related to being unable to transport the command. The command could have been timed out or reset or the host bus adapter unable to put the command onto the SCSI bus. This is neither as soft nor a hard error.


Since I have a lot of hard/transport errors, and my company have Platinum support from Sun, I reordered the parts (2 hdds) to swap the old ones, which throw errors.


This is my steps to change the faulted hdd in SVM for RAID-O (mirroring) (in this example, faulting hdd is c1t1d0, and submirror living on it is d100, mirror using this submirror is d1):

1. Identify the submirrors which reside on faulting disk drives

 

# metastat

 

<look for the slices that are being used on faulting drives, note them>

2.  Detatch this submirrors from the mirrors

 

 

# metadetatch d1 d100

<example, detatching from mirror d1 submirror d100, that lives on faulty hdd>

 

3. Clear the info used by SVM on detatched submirror

 

# metaclear d100

4. Check that you get rid of that submirror:

# metastat -p | grep d100

5. Remove SVM database replicas on that disk, that will be replaced

# metadb | grep c1t1d0

6. If you`ll find any replicas on this disk - delete them - and check, that they were deleted

# metadb -d /dev/c1t1d0s7 && metadb | grep c1t1d0

7.  If there is open filesystem, that is not being controlled by SVM - unmount them

8. Find & unconfigure the faulty hdd, replace the hdd - checking the dmesg - and configure the new one

# cfgadm -al

# cfgadm -c unconfigure c1::dsk/c1t1d0

# dmesg

# cfgadm -c configure c1::dsk/c1t1d0

# cfgadm -al

<assumed, that you replaced hdd in the same slot that was occupied by the faulty one>

9. Format & place VTOC on this hdd, as it was used by the another in other submirror (or you can save the VTOC output previously to replace the HDD)

# prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s - /dev/rdsk/c1t1d0s2

10. Update the DevID

# metadevadm -u c1t1d0

11. Recreate, if necessary the replica DB

# metadb -a -c 2 c1t1d0s1

12. Recreate and attatch submirror to corresponding mirror

 

 

# metainit d100 1 1 c1t1d0s0

# metattatch d100 d1

 

13. Check that everything ok, and submirrors are resyncing

 

 

# metastat d1

 

 

...

metastat d100
d100: Mirror
Submirror 0: d120
State: Resyncing
Submirror 1: d110
State: Okay
Resync in progress: 14 % done
...

 

 

14. Grab a beer!

Only thing that keeps me wondering - how to reset the "iostat -En" output to reset the error counters? This will require reboot - but I wanna to find another way to implement this...

Cheers!

Rotating logs on Solaris with logadm

November 2nd, 2009

Logadm is the tool appeared in Solaris 9, and in 10 it`s the default one. I had a task to rotate Squid logs, and decided to take the generic instuments to do this - logadm & friends.

So, at first, we need to be sure, that logadm is being run on daily basis - and change this if needed:


# crontab -l
...
10 3 * * * /usr/sbin/logadm

So, each day at 1030 we`ll have logadm launched, nice.

Logadm uses /etc/logadm.conf file as it`s configuration one. You could take a look at it, to became more or less familiar with it.


# less /etc/logadm.conf
...
/var/log/syslog -C 8 -P 'Tue Oct 27 03:10:00 2009' -a 'kill -HUP `cat /var/run/syslog.pid`'
/var/adm/messages -C 4 -P 'Tue Oct 27 03:10:00 2009' -a 'kill -HUP `cat /var/run/syslog.pid`'
/var/cron/log -c -s 512k -t /var/cron/olog
...

Preferred way to add files to rotate to logadm is with -w key:


# logadm -w /apps/squid/logs/cache.log -p 1d -t '/apps/squid/logs/rotated/$basename.$n.%Y_%m_%d' -z 0

This will make Squid`s cache log rotate once per day


-p 1d

writing it`s output to


-t '/apps/squid/logs/rotated/$basename.$n.%Y_%m_%d'

numbered, and datestamped - i haven`t found this in man, and figured by myself, and compressed by gzip


-z 0


0 means, that no files will be left unzipped, i.e. if there would be 5 - that means, that last 5 logs will be non-zipped, thus making them more comfortably to process.

Pretty simple, though powerful. To take a look at logadm`s debug and command executed (pretty useful while debugging), run


# logadm -vn


In general, logadm could do an whole bunch of stuff - executing commands pre and post rotating, emailing you re what`s going one, and more. But, as always - Keep It Simple, Stupid B)

Solaris divece mappings

October 13th, 2009

Ever wondered on what`s the heck is:
/ssm@0,0/pci@18,600000/SUNW,qlc@1/fp@0,0/ssd@w5006048c49ae7f78,52
?

Well, wonder no more, since this wonderful article will definately shed some light on device mappings on Solaris.

Cheers!

Solaris patchadd & patchrm return codes

October 8th, 2009

I needed to patch some severs, due to the overall "patch em`all" mood at my current company, but without the list of Solaris patchadd and patchrm commands it`s pretty hard.

So, for those of you needed the return codes - here they are:


patchadd return codes
----------------
0 No error
1 Usage error
2 Attempt to apply a patch that's already been applied
3 Effective UID is not root
4 Attempt to save original files failed
5 pkgadd failed
6 Patch is obsoleted
7 Invalid package directory
8 Attempting to patch a package that is not installed
9 Cannot access /usr/sbin/pkgadd (client problem)
10 Package validation errors
11 Error adding patch to root template
12 Patch script terminated due to signal
13 Symbolic link included in patch
14 NOT USED
15 The prepatch script had a return code other than 0.
16 The postpatch script had a return code other than 0.
17 Mismatch of the -d option between a previous patch install and the current one.
18 Not enough space in the file systems that are targets of the patch.
19 $SOFTINFO/INST_RELEASE file not found
20 A direct instance patch was required but not found
21 The required patches have not been installed on the manager
22 A progressive instance patch was required but not found
23 A restricted patch is already applied to the package
24 An incompatible patch is applied
25 A required patch is not applied
26 The user specified backout data can't be found
27 The relative directory supplied can't be found
28 A pkginfo file is corrupt or missing
29 Bad patch ID format
30 Dryrun failure(s)
31 Path given for -C option is invalid
32 Must be running Solaris 2.6 or greater
33 Bad formatted patch file or patch file not found
34 Incorrect patch spool directory
35 Later revision already installed
36 Cannot create safe temporary directory
37 Illegal backout directory specified
38 A prepatch, prePatch or a postpatch script could not be executed
39 A compressed patch was unable to be decompressed
40 Error downloading a patch
41 Error verifying signed patch


patchrm return codes
-------------------------
0 No error
1 Usage error
2 Attempt to backout a patch that hasn't been applied
3 Effective UID is not root
4 No saved files to restore
5 pkgrm failed
6 Attempt to back out an obsoleted patch
7 Attempt to restore CPIO archived files failed
8 Invalid patch id format
9 Prebackout script failed
10 Postbackout script failed
11 Suspended due to administrative defaults
12 Patchrm could not locate the backout data
13 The relative directory supplied can't be found
14 Patchadd has been interrupted, re-invoke patchadd
15 This patch is required by a patch already installed, can't back it out
16 Unable to create safe temporary directory
17 Must be running Solaris 2.6 or greater
18 Error unable to retrieve patch information from SQL DB.
19 Lock file not available
20 Insufficient space to uncompress undo.Z files
21 Unable to copy pkginfo file to pspool directory

AcademicEarth lectures

October 5th, 2009

An awesome site to spend your free hour. Huge amount of great lectures on everything, from IT to philosophy and medicine, superb professors and nice design of portal.
My favourite site of a month, highly recommended!

What stupid and not so stupid errors BASH programmers tend to make

October 3rd, 2009

On my work I have an ongoing task to rewrite a few bash scripts. Since I always was an admirer of nice & elegant bash scripting and already have some experience in it, I started to dig deeper. What I foung, is this wonderful article by someone, to whom I`m very grateful - Bash Pitfalls. I really wish I could read smth like this a while ago, it saves a lot of time, and shed light on some important aspects of BASH`ing.
Thank you!

For those of you, who`d prefer Russian - here`s and here`s the translation.

Grab yourself an cup of tea\coffee, open vim\emacs and review your own scripts, prehaps you`ll encounter something to remake :D

USB soundcard & studio monitors in OpenSolaris

September 27th, 2009

So, this is my new audio setup:

- Lexicon Alpha
alpha

- m-audio Studiophile BX8a deluxe
bx8a

In general, all I needed to make this work, is to update to build 123 of OpenSolaris 2009.06.

Then, songbird & xmms (in which i need to tune output plugin) began to work.

Also, to make USB soundcard be usable by firefox, scummvm & VBox, I changed symlink in /dev


cd /dev
pfexec rm audio audioctl
pfexec ln -s sound/1 audio
pfexec ln -s sound/1ctl audioctl

Then all abovementioned started to work, even Ableton Live in VBoxed winxp began to work just ok, with 20ms latency, which is ok I think for such kind of setup :)

Update to specific OpenSolaris version

September 26th, 2009

To update to specific version, use next scheme:


beadm create new_be_118 ; beadm mount new_be_118 /mnt ; \
pkg -R /mnt set-authority -P http://pkg.opensolaris.org/dev dev ; \
export PKG_CLIENT_TIMEOUT=900 ; \
pkg -R /mnt install SUNWipkg ; \
pkg -R /mnt install entire@$revision_you_want ; \
beadm umount new_be_118