Archive

Archive for June, 2011

How to check BerkeleyDB version info

June 22nd, 2011 No comments

How to check BerkeleyDB version info? Just run this command:

#grep DB_VERSION_STRING /usr/include/db4/db.h

#define DB_VERSION_STRING       "Sleepycat Software: Berkeley DB 4.3.29: (September 19, 2009)"

Then your BerkeleyDB version is 4.3.29.

If there's no /usr/include/db4 directory, you may check to see whether there's /usr/include/db3 or even /usr/include/db2 directory in your server. And run the respective command with db4 substituted by db3 or db2.

mkfile/dd to create a file with specific size

June 21st, 2011 3 comments

Now assume you want to create a file with 10M space:
Under Solaris:
root@beisoltest02 / # mkfile 10m disk1.img
root@beisoltest02 / # ls -lh disk1.img -rw------T   1 root     root         10M Jun 22 00:41 disk1.img

Under Linux:
[root@beivcs02 downloads]#  dd if=/dev/zero of=disk1.img bs=1024k count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.01096 seconds, 957 MB/s
[root@beivcs02 downloads]# ls -lh disk1.img
-rw-r--r-- 1 root root 10M Jun 22 00:37 disk1.img

PS:

There are many other options you can use to control dd behavior, such as cache. You can refer to here and here.

Categories: IT Architecture, Linux, Systems Tags:

Nagios Check_nrpe/check_disk with error message DISK CRITICAL – /apps/yourxxx is not accessible: Permission denied

June 21st, 2011 1 comment

This was sometimes because the user under which nagios runs by had no read permission to the file systems check_disk is going to check.

For example, if you received alert:

DISK CRITICAL - /apps/vcc/logs/way is not accessible: Permission denied

You then can log on your server, under root, run:

/usr/local/nagios/libexec/check_disk -p /apps/vcc/logs/way, you may see:

DISK OK - free space: /apps/vcc/logs/way 823 MB (21% inode=90%);| /=2938MB;;3966;0;3966

But when you run this under user nagios, you may see DISK CRITICAL again.

Resolution:

Grant read permission to the filesystem/directory that had problem.

 

DNS flush on linux/windows/mac

June 17th, 2011 No comments
  • Mac:
  • sudo dscacheutil -flushcache
  • Linux:
  • Here're ways to flush dns cache on linux/windows/mac:
    On linux:
    rndc flush
    or
    /etc/init.d/nscd restart
    On Windows:
    ipconfig /flushdns

    On Mac:

    sudo dscacheutil -flushcache

    You can install DNS cache plug-in to automatically flush DNS cache for you if you have Firefox installed.

     

    Categories: IT Architecture, Linux, Systems Tags:

    How to resize/shrink lvm home/root partition/filesystem dynamically

    June 8th, 2011 2 comments

    When you're trying to extend root file system under lvm environment, here are the steps:

    1.Extend the root volume:

    #lvextend -L500G /dev/VolGroup00/apps-yourapp

    2.Grow file system:

    #resize2fs /dev/VolGroup00/apps-yourapp 500G

    Shrinking can’t be done that easily and requires an umount. To shrink the FS, do the following:

    umount <logical-volume-device>
    e2fsck -f <logical-volume-device>
    resize2fs <logical-volume-device> <new-size-minus-50MB>
    lvreduce -L <new-size> <logical-volume-device>

    This procedure is for normal(not root) file systems. But what should we do when we want to shrink root/home partition/file system?

    You need go to linux rescue mode using a bootable device(Such as the first cd of your linux distro), type linux rescue, and when there jumps out an alert says whether to mount system to /mnt/sysimage, select skip.

    When you're in the shell of rescue mode, do the following steps:

    1.lvm vgchange -a y

    2.e2fsck -f /dev/VolGroup00/LogVol00

    3.resize2fs -f /dev/VolGroup00/LogVol00 500G

    4.lvm lvreduce -L500G /dev/VolGroup00/LogVol00

    Then reboot your system, and after it starts up, running df -h to check the result. And using vgs to see VSize and VFree.

    Enjoy.

     

     

    Interesting tty/pty/pts experiment

    June 8th, 2011 No comments

    Now, open two tabs on the same server using xshell, on each tab(session), run tty:

    root@testserver# tty

    /dev/pts/7

    root@testserver# tty

    /dev/pts/25

    First experiment - echo an string between ttys

    From /dev/pts/7, run:

    root@testserver# echo hi>/dev/pts/25

    Then, from the other tab(session), you're sure to see:

    root@testserve# hi

    To be continued...

    Grow/shrink vxfs file system(or volume) dynamically using vxresize

    June 5th, 2011 No comments

    I've already use vxassist creating disk group, making file system,  and mounting it to the OS and that partition is now in use. How can I grou/shrink  the size of vxvm filesystem dynamically ?

    Three steps:

    1.Which disk group does the file system use?

    In my scenario, I've /user which is the mount point of volume user_vol, and that volume belongs to andy_li disk group. As I created them, I've a clear mind about it. Then, how can I know which disk group does a file system/volume belongs to?

    #df -h /user

    /dev/vx/dsk/andy_li/user_vol                      1.0G   18M  944M   2% /user

    Now you can see, /user file system belongs to andy_li disk group.

    2. Now let's check how many space left in the disk group that we can use for growing /user:

    #vxdg -g andy_li free

    GROUP        DISK         DEVICE       TAG          OFFSET    LENGTH    FLAGS

    andy_li      andy_li01    sdb          sdb          3121152   999168 -

    999168 blocks, that's about 500MB.

    3. The last and most important thing is to grow the file system:

    /etc/vx/bin/vxresize -b -g andy_li user_vol +999168 alloc=andy_li01

    Ok, after this operation, let's check the file system's size again:

    #df -h /user/

    Filesystem            Size  Used Avail Use% Mounted on

    /dev/vx/dsk/andy_li/user_vol                      1.5G 18M  1.4G   2% /user

    That's all. And vice versa, You can use minus(-) instead of plus(+) to shrink the file system.

    Categories: Hardware, Storage Tags: