Monday, October 10, 2011

ssh tunneling to access remote mysql on ec2

to acess remote mysql on ec2 as local on port 3307 using ssh tunneling we can use following command(assuming port is close on remote machine),

ssh -i -L 3307:localhost:3306 username@server

This command can be used to acces any other kind of service by changing port number

login as another using sudo

use

sudo -u bash

to login into bash as another user

Sunday, July 3, 2011

Redirecting the request on openx login page

If you are not able to open openx login page due to redirecting request. Then that may be because cookie in your browser for that openx domain is creating some problem.

To solve this problem delete all cookie for that openx domain. Now Try to open login page, you should be able to open openx login page

Tuesday, May 24, 2011

How to copy multiple file from remote host using scp

To copy complete folder then -r swich can be used,

scp -r user@host:folder_path source_path_of_current_machine

To copy selected file from folder, then specify path1 and path2 of file separated by space

scp user@host:"path1 path2" source_path_of_current_machine

And if file is in the same folder then bash file expansion enclosed in double quote can be used,

scp user@host:"foder_path/{file1,file2}" source_path_of_current_machine




Thursday, May 19, 2011

How to run latest or multiple firefox release on linux

I want to run firefox 5 and firefox 6 on my ubuntu lucid while running firefox3.
Use follwing step,

  1. Download firefox 5 and firefox 6 build from mozzila site.
  2. then extract tar file and start the firefox using command 
  3. start firefox5 using,
    #ff5_dir/firefox -P "ff5" -no-remote
  4.  start firefox5 using,
    #ff6_dir/firefox -P "ff6" -no-remote
  5. firefox will prompt you to create new profile give name ff5 for firfox5 and ff6 for firfox 6, after creating profile uncheck option "Don't ask at starup",
  6. Now use the same step 2 command to start firfox 5 and firefox 6 or you can create shortcut with above step 2 command

 


Tuesday, May 17, 2011

How to delete firefox cookie from command line in ubuntu linux

just delete sqlite db file using following command
change home_dir and firefox_profile_name(some random   generated name) accordingly in command

rm home_dir/.mozilla/firefox/firefox_profile_name/cookies.sqlite

How to setup filezilla or Krusader for ec2 on ubuntu linux

add follwing entry int your ssh config file (ex. your_home_dir/.ssh/config)


Host server_address
 IdentityFile ssh_private_key_location
(change server_address and ssh_private_key_location accordingly)
you get ec2 ssh_private_key, when you create keypair in aws_console->keypairs section. They key you need to specify when you boot new instance.also change ssh private key security mode to 600.

Then add site into filezilla->site manager as shown in the above screenshot.

  1. host should be server address
  2. select servertype as sftp
  3. select username on linux instance accordingly
  4. then connect to ec2 instance


and for Krusader you need to specify same thing as shown in the above screenshot


How to use ec2 as proxy using SSH tunnel for geo related web testing on linux

create ssh tunnel using follwing command (change port number,key file address,username and ec2 instance ip address accordingly),
ssh -D 9999 -i key_file_location username@ec2_instance_address
then set SOCKS HOST proxy setting for the firefox (prefernce->network tab) or other browser as shown in the figure


















Close the ssh tunnel once you are done with testing.

how to enable mysql general logging using query without restarting server on ubuntu lucid 10.4.2

to see what's going on inside mysql without restarting server, logging can be enabled using following query

SET GLOBAL general_log_file = '/var/log/mysql/mysql.log';
SET GLOBAL general_log = 'ON'

and logging can be disabled using following query

SET GLOBAL general_log = 'OFF'

Tuesday, May 3, 2011

How to enable openx for geotargeting

install openx  after that download free geoip city database from maximind site and uncompress it.

#wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
#gunzip -d GeoLiteCity.dat.gz

enable geotargeting in configuration section of openx administration account

copy GeoLiteCity.data to <openx_home>/plugins/geoTargeting/oxMaxMindGeoIP/data
sudo chown www-data:www-data GeoLiteCity.dat
sudo chmod 777 GeoLiteCity.dat

change geoTargeting plugin setting, add "GeoLiteCity.dat" for city data file

in <openx_home>/plugins/etc/oxMaxMindGeoIP/oxMaxMindGeoIP.xml change line as shown below for GeoLiteCity.dat

            <file path="{MODULEPATH}geoTargeting/oxMaxMindGeoIP/">oxMaxMindGeoIP.class.php</file>
            <file path="{MODULEPATH}geoTargeting/oxMaxMindGeoIP/">oxMaxMindGeoIP.delivery.php</file>
            <file path="{MODULEPATH}geoTargeting/oxMaxMindGeoIP/data/">GeoLiteCity.dat</file>

in <openx_home>/plugins/geoTargeting/oxMaxMindGeoIP/oxMaxMindGeoIP.delivery.php change following line
        //$geo = oxMaxMind_getGeo($ip, dirname(__FILE__) . '/data/FreeGeoIPCountry.dat');
        $geo = oxMaxMind_getGeo($ip, dirname(__FILE__) . '/data/GeoLiteCity.dat');

Friday, April 29, 2011

Backup ec2 mysql server on S3 using mysqldump and s3

Below is script to take backup of complete database on S3, also remove 10 day old backup file from S3

You need install s3cmd, and configure it before using this script, also need to create S3 bucket on aws
also change mysql username and password accordingly.



 #!/bin/bash
#below is path of variable to put dump of mysql
DATA=/data
#filename of today
file_name=db_`date +'%d-%m-%Y'`.sql.gz
#filename of today
file_name_10_day_old=db_`date --date='10 days ago' +'%d-%m-%Y'`.sql.gz
#take dump of mysql
mysqldump -u mysql_unsername -p mysql_password --all-databases | gzip > $DATA/$file_name
#push to s3
s3cmd put $DATA/$file_name s3://backup_bucket
#cleanup of file
rm $DATA/$file_name
s3cmd del s3://backup_bucket/$file_name_10_day_old