Wednesday, October 1, 2008

Windows and maatkit

There are some great tools out there for MySQl. Many of them can be very Linux specific. Maatkit, which was originally written by Baron Schwartz and now maintained by the company he works for Percona, generally works on Windows too. It does have some specific tools like mk-audit that are Linux specific.

This article will be about getting Maatkit installed on your server and future articles will talk about functionality.

You are going to need a couple things to get this going. You will need Maatkit, Perl, DBI, DBD-mysql and some core packages to get yourself going.

First, you will need maatkit. Unzip the package to a directory of your choice. Something like c:\maatkit-2325
http://www.maatkit.org/

Second, you will need Perl. I would recommend getting Activeperl from http://www.activestate.com/. The current version is Activeperl 10. If you are using an x64 version of Windows like you should be, you will still want to get the x86 package of Activeperl to get this working. Download and Install.

Open a command prompt and navigate to the install directory. Most likely: C:\Perl\

C:\> cd Perl
C:\Perl>cd bin
C:\Perl\bin>

Third, we will want to make sure DBI is installed and then install DBD-mysql. This version of DBD-mysql will be specific to Activeperl 10.

C:\Perl\bin>ppm install DBI
C:\Perl\bin>ppm install http://cpan.uwinnipeg.ca/PPMPackages/10xx/DBD-mysql.ppd

As long as you didn't run into any snags you should be set. You can now run Perl scripts and maatkit.

To test:
C:\maatkit-2325>C:\Perl\bin\perl.exe mk-table-checksum --databases db1,db2 h=localhost,u=root,p=password

This will run a checksum on your specified databases, in this case db1 and db2.

Hint: You will also be able to run things in the MySQL/scripts folder like mysqldumpslow.

Monday, September 29, 2008

PHP with fastcgi (IIS 6)

This isn't MySQL related but since I also run PHP on some Windows 2003 servers (IIS 6) I thought I would make a post as I switched from isapi to fastcgi.

The process went fairly smooth following the good instructions at iis.net on my dev server. Here is the link to their article:
http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/

When I deployed to one of my production servers I was having issues with a specific application. I was getting this error:
FastCGI Error

The FastCGI Handler was unable to process the request.

Error Details:

* Error Number: 5 (0x80070005).
* Error Description: Access denied.

HTTP Error 500 - Server Error.
Internet Information Services (IIS)


All of my applications work on their own application pool. Since all the other applications were working properly I knew it was not permission issues to php-cgi.exe like others have posted about. My issue was application pool specific. The difference this application pool had vs the others was in the properties > performance for the pool. Enable CPU monitoring was checked. Once I unchecked this everything started working properly.

Issue solved. I just want to read up now on why this doesnt work and what other issues are related in iis 6

Thursday, September 25, 2008

Flushing the log-slow-queries log file

One of the things that I have seen a lot of questions on is how to "flush" the slow query log. I think most people expect when you perform a mysql>Flush Logs that it will create a new log file. This is true for the Binary logs but not the slow query and general logs.

The action that mysql takes when the mysql>Flush Logs command is given closes and then reopens the slow query and general logs.

To start a new log you will want to rename the current log file then perform a mysql>Flush Logs. MySQL will create a new log file with whatever you have set as the log-slow-queries= slow_queries
On windows you would roughly perform:
c:\>cd mysql-data-directory
d:\db\data>ren slow_queries slow-queries-old
d:\db\data>mysql -u user -pPassword
mysql>flush logs;
mysql>exit;
The same goes for the general log file. The only assumption made in this article is that you are actually already logging slow queries via your my.ini config option of log-slow-queries= slow_queries