Sunday, April 24, 2011

Mount NTFS disk to CentOS 5.5

1. Find out the hardware platform:
uname -i

2. Download the rpmforge-release package.

i386 -
x86_64 -

3. Install GPG key:
rpm --import

4. Install the package.
rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm

5. Install fuse-ntfs-3g packages.
yum install fuse fuse-ntfs-3g

6. Check the NTFS partition.
fdisk -l

7. Create the mount point.
mkdir /mnt/windows

8. Mount the NTFS disk.
mount /dev/sdb1 /mnt/windows

Saturday, April 16, 2011

Use At to run repeated task

Following is an example,, to run script at /home/pwong every 3 minutes within 12 hours period.


if [ ! -f off_time ]; then
date --date="+12 hours" +"%k" > off_time

if [ `date +%k` -eq `cat off_time` ]; then
rm off_time
exit 1

sleep 60

cd $WorkDir

at -f +3 minutes

exit 0

Install and Test SNMP on CentOS 5.5

1. Install net-net-snmp and net-snmp-utils
# yum install net-snmp-utils

2. Create /etc/snmp/snmpd.conf. Following is a very simple example for the testing.

rocommunity public
syslocation "ABC, ABC Inc."

3. Startup snmpd server
# /etc/init.c/snmpd start

4. Ues snmpwalk to test SNMP setup.
# snmpwalk -v 1 -c public -O e 127.0.0

# snmpwalk -v 1 -c public localhost system

If something similar to the following show up on the screen, the SNMP is working.

SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (977) 0:00:09.77
SNMPv2-MIB::sysContact.0 = STRING:
SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain
SNMPv2-MIB::sysLocation.0 = STRING: "ABC, ABC Inc."

5. If someting is wrong, check /etc/snmpd/snmpd.conf for error. Following commands can be used for troubleshooting as well. If everything is fine, then firewall settings should be checked.
# /etc/init.d/snmpd status
# snmpd -f -Le

6. Enable the snmpd starts up when the system reboot.
# chkconfig snmpd on

Friday, April 15, 2011

Mysqldump Performance Issue

When dumping really big tables, mysqldump was using up large amounts of memory, so it may cause no-response problem. To overcome this, --quick and --single-transaction options can used. Following are the sections for these options in the mysqldump man page.

--quick, -q
This option is useful for dumping large tables. It forces mysqldump to retrieve rows for a table from the server a row at a time rather than retrieving the entire row set and buffering it in memory before writing it out.

To dump big tables, you should combine this option with --quick.

Sunday, April 3, 2011

Use Remote Variables with Rsh or Ssh

Followng are the difference between local and remote variables. $PWD is the local variable passed to remote system, but \$PWD is the variable defined in the remote system.

/home/patrickw/tools $ sudo ssh host "echo $PWD"

/home/patrickw/tools $ sudo ssh host "echo \$PWD"

Therefore, backslashes in the following example is necessary. Without the backslashes, awk will complain syntax error since the variables are blank.

sudo ssh host "top -b -n 1 | egrep sudo\|ssh\|xinet | awk '{print \$1, \$9, \$10, \$12}'"