Wednesday, November 20, 2013

Starting MYSQL in innodb recovery mode

Recently my SQL server has crashed and was unable to start, I have tried to fix the issue but could not, by seeing the log file I could only understand that there is a problem with the innodb database and the only way to work around with the issue is to recover innodb. But I cannot loose the database since it was very critical for my project.

So after little R&D I was able to start the server using the innodb recovery mode, here is how to do it

Open the mysql config file i.e. my.ini and add the following line under the [mysqld] line

innodb_force_recovery = 4

this will start the mysql server in innodb recovery mode and gives you the chance to repair the database.

For your information the mysql logfile

131121  1:18:48  InnoDB: Page checksum 4132264320, prior-to-4.0.14-form checksum 47764882
InnoDB: stored checksum 4132264320, prior-to-4.0.14-form stored checksum 1792345140
InnoDB: Page lsn 0 58314446, low 4 bytes of lsn at page end 58279508
InnoDB: Page number (if stored to page already) 590,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 0
InnoDB: Page may be an update undo log page
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 590.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: See also
InnoDB: about forcing recovery.
InnoDB: Ending processing because of a corrupt database page.
131121  1:18:48  InnoDB: Assertion failure in thread 2996 in file buf0buf.c line 3602
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: about forcing recovery.

Tuesday, November 19, 2013

Convert Time stamp from UNIX to Human readable format in SQUID Proxy Log

I work with an IT organization and my Security team as a part of their routine audits asked me to provide the SQUID proxy server log. I have provided them the logs but they were not happy about it since the time stamp in the log is in UNIX format. So they have assigned me the task to change the time stamp to human readable format.

I have started to do the R&D on how this can be achieved, after I googling for a long time I have found the solutions for it which I am explaining now since I have found many administrators searching for this configuration on the internet.

The configuration is pretty simple, we just need to add the following configuration line at the end of squid configuration file located at /etc/squid/squid.conf

The configuration is

### Custom Log Format ###
logformat squid %tl.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt

after adding the above configuration, restart the SQUID proxy server for the changes to take effect.

That's it now the time stamp in SQUID log would be in Human Readable Format.