Tuesday, December 13, 2011

Using vim editor to find and replace effectively

Taken from this excellent article Vi and Vim Editor: 12 Powerful Find and Replace Examples

Here is a few examples that I love to use. You can see that this entry is a notepad for me.

Scenario 1: Replace all occurrences of a text with another text in the whole file
:%s/old-text/new-text/g
%s - specifies all lines. Specifying the range as ‘%’ means do substitution in the entire file.
g flag– specifies all occurrences in the line. With the ‘g’ flag , you can make the whole line to be substituted. If this ‘g’ flag is not used then only first occurrence in the line only will be substituted.

 Scenario 2: Replace of a text with another text within a range of lines
:1,10s/old-text/new-text/gi
1-10 - Do substitution from line 1 to 10
i flag - Make the substitute search text to be case insensitive.


Scenario 3:  Replacing of a text with another text for a the 1st X number of lines
From the current position of the cursor, the command will replace according to the number of count. For example, do substitution in 10 lines from the current line.
:s/old-text/new-text/g 10

Scenario 4: Substitute only the whole word and not partial match
If you wish to change the whole word "text" to "new-text"
Original Text: old to text
:s/\<text\>/new-text/
Translated Text: old to new-text


Sunday, December 11, 2011

How to associate compute nodes with a queue name with Torque

If you wish to use a queue that is locked to a selected group of nodes and wish to allow certain users to run, you may want to take a look at one of the contributor to a Rock-Discussion
[Rocks-Discuss] [Torque roll] How to associate 10 compute nodeswith a queue name ?

In his write-up

========
qmgr -c "create queue vision queue_type=execution"
qmgr -c "set queue vision resources_default.neednodes = vision"
qmgr -c "set queue vision acl_hosts=c2-0-20+c2-0-21+c2-0-22+c2-0-27+c2-0-28+c2-0-29"
qmgr -c "set queue vision acl_host_enable = false"
qmgr -c "set queue vision acl_users=user1"
qmgr -c "set queue vision acl_users+=user2"
qmgr -c "set queue vision acl_users+=user3"
qmgr -c "set queue vision acl_user_enable=true"
qmgr -c "set queue vision enabled = True"
qmgr -c "set queue vision started = True"

qmgr -c "set queue default resources_default.neednodes = general"

for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 23 24 25 26 30 31 32 33; 
do 
        /opt/torque/bin/qmgr -c "set node c2-0-${i} properties = general"; 
done

for i in 20 21 22 27 28 29 ; 
do 
        /opt/torque/bin/qmgr -c "set node c2-0-${i} properties = vision"; 
done
========
 
For more information, do also read up on
  1. 4.1 Queue Configuration (From Cluster Resources)
  2. Cluster Node-Locking with Torque and Maui (Wednesday, October 22, 2008)

Thursday, December 8, 2011

Configuration error when compiling octave with BLAS and LAPACK libraries

Do take a look at the Compiling Octave from Source on CentOS 5. However you make face an error such as
" configure: error: You are required to have BLAS and LAPACK libraries ".

This is due to the missing link. For more information on this error, you may want to take some hints from 
Cannot find -llapack when doing /usr/bin/ld on CentOS 5

In other words, just go to /usr/lib64 and do a softlink for the lapack library
ln -s /usr/lib64/liblapack.so.3 /usr/lib64/liblapack.so
 

Friday, December 2, 2011

Encountering eth0 NIC SerDES Link is Down

I was noticing this error on my HS22 Blade log files occasionally and on one occasion the NFS which was relying on the ethernet connection got disconnected and hang when the load is exceedingly high. The problem is that it is very hard to reproduce the problem as it is quite random

My Server is using the Broadcom chipset bnx2 and my version of my CentOS is 5.4 or kernel  version is 2.6.18-164.el5

After a bit of searching, this particular Red Hat Bugzilla (https://bugzilla.redhat.com/show_bug.cgi?id=520888) reflects the problem and workaround very well. I encourage you to take a closer look. If you are not planning to upgrade your RHEL or CentOS to 5.6 ( http://rhn.redhat.com/errata/RHSA-2011-0017.html ) and above yet, you may want to consider the workaround as mentioned in the bugzilla



 From Comments 14

"Configuring IRQ SMP affinity has no effect on some devices that use message signalled interrupts (MSI) with no MSI per-vector masking capability. Examples of such devices include Broadcom NetXtreme Ethernet devices that use the bnx2 driver. 

If you need to configure IRQ affinity for such a device, disable MSI by creating a file in /etc/modprobe.d/ containing the following line: 

options bnx2 disable_msi=1 

Alternatively, you can disable MSI completely using the kernel boot parameter pci=nomsi. (BZ#432451)

" http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Technical_Notes/Known_Issues-kernel.html

To Check whether you are still having issues, you can use the command
# dmesg |grep bnx2
I guess the best way is to update your broadcom drivers. For latest update on this "NIC SerDES Link is Down", see my writeup on Upgrading of Broadcom Drivers to resolve eth0 NIC SerDES Link is Down

Thursday, December 1, 2011

Using stunnel to generate to create a self-signed certificate for SL 6 and CentOS 6

 The stunnel Program allows administrator to create self-signed certification using external OpenSSL Libraries included with RHEL and its clone to provide strong cryptography and protect connection. For more information on the installation and setup, see Using stunnel to generate to create a self-signed certificate for SL 6 and CentOS 6