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 - http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
x86_64 - http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

3. Install GPG key:
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

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, schedule.sh, to run check_process.sh script at /home/pwong every 3 minutes within 12 hours period.


WorkDir=/home/pwong

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

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

sleep 60

cd $WorkDir

at -f schedule.sh +3 minutes

check_process.sh

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."
syscontact me@abc.com

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

Or
# 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: me@abc.com
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.

--single-transaction
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

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

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}'"