Saturday, March 12, 2011

Fixing a Corrupt MySQL Relay Log


When there are network problems between the server, there was some issue where the master didn’t properly detect and notify the slave of the failure. This resulted in parts of queries missing, duplicated, or replaced by random bits in the relay log on the slave. When the slave tries to execute the corrupt query, it will likely generate an error that begins with:
Error You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near . .
A work-around which forces the slave to re-request the binary log from the master. Run ‘SHOW SLAVE STATUS’ and make note of the Master_Log_File and Exec_Master_Log_Pos columns. Then run ‘STOP SLAVE’ to suspend replication, and run this SQL:
CHANGE MASTER TO master_log_file='',
master_log_pos=;
After that, simply run ‘START SLAVE’ to have replication pick up from there again. That evidently has the slave re-request the rest of the master’s binary log, which it should (hopefully) get without becoming corrupt, and replication will continue as normal.

[Ref]

Thursday, September 23, 2010

How to listdown directories

ls -d */

the -d says “do not descend into sub-directories, it is the same as saying -d1.
The */ says list only items ending in / (which are directories).
If you want to see hidden directories, you could do a ls -d .*/

Friday, July 16, 2010

Creating ISO image of Installed OS

When you want to create the ISO image of Installed OS use the following command.

mkisofs -force-rr -m /proc -m /sys -o file.iso / [proc and sys are excluded intentionally]


To test this use the following

mount -o loop file.iso /mnt

Friday, July 9, 2010

log-slave-updates

Normally, a slave does not log to its own binary log any updates that are received from a master server. This option tells the slave to log the updates performed by its SQL thread to its own binary log. For this option to have any effect, the slave must also be started with the --log-bin option to enable binary logging. --log-slave-updates is used when you want to chain replication servers.

For example, you might want to set up replication servers using this arrangement:

A -> B -> C
Here, A serves as the master for the slave B, and B serves as the master for the slave C. For this to work, B must be both a master and a slave. You must start both A and B with --log-bin to enable binary logging, and B with the --log-slave-updates option so that updates received from A are logged by B to its binary log.

[ref: http://dev.mysql.com/doc/refman/5.1/en/replication-options-slave.html]

Monday, June 7, 2010

How to get an absolute value

Some times when we calculating difference we don't want to show the negative value. What we are interested in is only the difference. so here is the command.


prasad@mac:~# absolute_value=-123
prasad@mac:~# echo ${absolute_value#-}
123

You can use this in any shell script.

Tuesday, May 11, 2010

On the Fly zip unzip mysql Backup

mysqldump -u root -ppassword RECEIPTS BlockedNumbersTable | bzip2 -9 | ssh host0119 "bzip2 -d > /mnt/data1/prasad.sql"

Tuesday, March 9, 2010

Vim Syntax

Some times it is observe that vim syntax is not working by default when you install the vim. To git rid of this create the ~/.vimrc file in your home directory with following context

syntax on

thats it. you are done. next time it will automatically support syntax and follow the appropriate coloring information while you do scripting in vim.