Redirect port 80 to 9000 in linux
Posted by Prem on February 8th, 2014 filed in General, LinuxComment now »
/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp –dport 80 -j REDIRECT –to-port 9000
/sbin/iptables -t nat -A OUTPUT -o lo -p tcp –dport 80 -j REDIRECT –to-port 9000
Mysql and replication
Posted by Prem on February 8th, 2014 filed in General, mysqlComment now »
Last week, we ran into an issue of mysql getting stuck in a replication. Â Turned out, one of the transaction that failed in the master, failed in the slave with a different error. Â That had halted the replication.
This is how we fixed it.
mysql -p
STOP SLAVE;
SET
GLOBAL
SQL_SLAVE_SKIP_COUNTER = 1;
START SLAVE;
Subversion filter
Posted by Prem on April 21st, 2010 filed in Linux, Tech topicsComment now »
As developers, we use some versioning system. We also come under situation, where we dont want to keep every files in the repo. Especially those that are created at runtime, as logs. We can create filters in the repo, so that we can ensure that these files are not saved in the repository. Here is how we do it in subversion:
svn propset svn:ignore "*.log" log
What this means is, we are telling subversion to ignore all the *.log files inside the log directory that is situated in the current folder. You run this command from within the repo.
You can run the following command to see what all properties are set in the current folder.
svn proplist
How to iterate through list of filenames in linux
Posted by Prem on April 19th, 2010 filed in Linux, Tech topicsComment now »
Today, somebody asked me how to iterate through a list of filenames given in a text file, and do something with it. So, I did, and then thought i would put it here, so it might help somebody else.
So, the script goes like this:
for f in `cat x` ; do if ! test -e $f then echo $f fi done
How to set timezone in linux – Ubuntu Hardy
Posted by Prem on January 12th, 2010 filed in LinuxComment now »
Now with the proliferation of Cloud computing, we often come across the necessity to configure the linux server to run in a particular timezone other than where it is running. I had to do this in some of our servers, so I thought, I would share this information with others.
The server’s current timezone is defined by the file /etc/timezone. The timezone files for other zones are located in the folder /usr/share/zoneinfo.
First save your current timezone file. Rename this file as a backup. You can also delete the same.
mv /etc/timezone /etc/timezone.backup
Now lets take a look at the collection of timezone files.
cd /usr/share/zoneinfo
Take a look at the files. Each file pertains to a particular timezone. The filename’s are quite explanatory. For countries with multiple timezone, like US, Canada etc,  you will see a folder named by the country. Inside this folder you will see these files. Choose the timezone file you want to use. For eg. lets say, I want to set the timezone to US – PST. The timezone file for this is /usr/share/zoneinfo/US/Pacific
Just run,
cp /usr/share/zoneinfo/US/Pacific /etc/timezone
All set. Run the date command to see the server’s timezone is now set to PST.
Have fun.
PGError: Server closed connection unexpectedly
Posted by Prem on January 4th, 2010 filed in PostgreSQLComment now »
I’ve been struggling with this error for sometime lately. Â The issue goes like this:
I have a web based application developed using Ruby on Rails, that uses PostgreSQL as database.   It works perfectly fine for functions, which retrieves less data.  But for others which has more data, the client (RoR) fails with this error.  And the server log says, Client disconnected prematurely.  But if I keep hitting F5 (Browser Refresh), sometimes the page loads successfully.  Isn’t that awesome?
Google didn’t have any answer for this either.  I could see a lot of people posting this error in many blogs, but I didn’t see any solution that pertains to my problem.
If you have any solution for this, please let me know.
mysqldump and stored procedures
Posted by Prem on January 4th, 2010 filed in mysqlComment now »
Today I found out something interesting. Â Well, probably its only for me. Â Mysqldump does not dump the stored procedures by default. Â Default option for mysql dump is to exclude stored procedures. Â Where as triggers are include by default.
So, in order to include stored procedures, you have to use option –routines. So, the command goes like:
mysqldump [other options of mysql dump] –routines > out_filename
How to change root password in mysql
Posted by Prem on July 14th, 2009 filed in mysql, Tech topicsComment now »
You can use the mysqladmin tool to change the root password like this:
mysqladmin -u root -p'OLDPASSWORD' password NEWPASSWORD
How to set root password for mysql
Posted by Prem on July 14th, 2009 filed in mysql, Tech topicsComment now »
mysql root password can be set by using the mysqladmin tool.
mysqladmin -u root password NEWPASSWORD
How to configure nginx to serve the images
Posted by Prem on February 6th, 2009 filed in nginxComments Off on How to configure nginx to serve the images
Add this to your server configuration to configure nginx to serve the static contents like images, css etc.
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$
{
root /path/to/static/assets;
}