Sunday, January 31, 2010

Export and Import Mysql database as CSV

Export in to CSV
  
SELECT A,B,C
INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM X;


Import in to database

  
LOAD DATA INFILE '/tmp/result.txt'
INTO TABLE X
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';

Sunday, January 17, 2010

Connect SVN with LDAP

If you are trying to authenticate the SVN (Subversion) system with LDAP, Following is the Apache configuration file

Install following plugin

apt-get install libapache2-svn

Then create the following vhost conf file while loading following modules.

#-------------------Start Conf file---------------------------------------

LoadModule ldap_module /usr/lib/apache2/modules/mod_ldap.so
LoadModule authnz_ldap_module /usr/lib/apache2/modules/mod_authnz_ldap_module.so
LoadModule dav_svn_module /usr/lib/apache2/modules/mod_dav_svn.so
LoadModule authz_svn_module /usr/lib/apache2/modules/mod_authz_svn.so

< Location /repo>
DAV svn
SVNParentPath /var/repo1/
SVNListParentPath On
SVNAutoversioning On
SVNReposName "Your Subversion Repository"
AuthzLDAPAuthoritative on
AuthType Basic
AuthName "Repo1 Subversion Repository"
AuthLDAPBindDN "CN=admin,DC=test,DC=com"
AuthLDAPBindPassword password
AuthLDAPURL "ldap://ldapserver.test.com:389/DC=test,DC=com?sAMAccountName?sub?(objectClass=*)"
Require valid-user
< /Location>

#------------------------End------------------------------------


#------------------------sampe 2 -------------------------------
< Location /repo>
DAV svn
SSLRequireSSL
SVNParentPath /var/repo/
SVNListParentPath On
SVNAutoversioning On
SVNReposName "Repository"
SVNPathAuthz off

AuthBasicProvider ldap
AuthBasicAuthoritative on
AuthzLDAPAuthoritative off

AuthType Basic

AuthName "Repository"
AuthLDAPBindDN "cn=admin,dc=test,dc=com"
AuthLDAPBindPassword password
AuthLDAPURL "ldap://ldapserver.com:389/ou=people,dc=test,dc=com?uid"
Require valid-user

#---------------------------------------------------------------
If you need any detail information, follow-up following blogs.

http://blogs.open.collab.net/svn/2009/03/subversion-with-apache-and-ldap-updated.html
http://blog.acmelab.org/2007/09/02/ubuntu-server-setup-lampldapsvntracmoinmoin/

Thursday, January 14, 2010

How to check the Hard Disk performance and health on Debian Systems

 
Proberbility of faliurs are high on the HDD is the highest because of the highest active part of a computer.Therefore it is better to keep a eye on that. Following are some of the ways we can check the HDD performance.


sudo apt-get install smartmontools

Get HDD info
smartctl -i /dev/sda

=== START OF INFORMATION SECTION ===
Model Family: Hitachi Travelstar 7K100
Device Model: Hitachi HTS721060G9SA00
Serial Number: MPCC12Y3GUPARE
Firmware Version: MC3OC10H
User Capacity: 60,011,642,880 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: ATA/ATAPI-7 T13 1532D revision 1
Local Time is: Thu Jan 14 19:54:34 2010 MVT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Note ATA Verstion 8 is SATA HDD and 7 is IDE



General overall HDD health

smartctl -H /dev/sda

smartctl version 5.38 [i686-pc-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED


If its not "PASSED" there is a problem with the HDD and take the nessery actions ASAP.



If you want to take a detail out put use following command to see short-selftest and long self-test
time taken

smartctl -c /dev/sda


Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 35) minutes.

Then run the short or extended self tests as follows

smartctl -t short /dev/sda
smartctl -l selftest /dev/sda



then check the self tests results

smartctl -t long /dev/sda


Check the disk temprature

smartctl -A /dev/sda | grep Temp

194 Temperature_Celsius 0x0002 103 103 000 Old_age Always - 53 (Lifetime Min/Max 19/66)

or use following tool

apt-get install hddtemp
hddtemp /dev/sda

If the temprature goes above 60 you may want to change the HDD soon.


Check HDD Speed

hdparm -tT /dev/sda