Saturday, January 21. 2006
Converting ISAM to MyISAM tables in Mysql 5.X
Short Version: You can't.
But you are not totally hooped. Here is a quickie recipe if you didn't read the upgrading manual.
- Backup your tables! I did it by making a copy of the database directory. In Debian it's /var/lib/mysql. Also backup your servers my.cnf
- Get a list of your ISAM tables. Do this by issuing find /path/to/databases -name *.ISM >brokenTableList.txt.
- Convert your broken table list into a series of ALTER TABLE sql commands. I used awk because only one database was left un-upgraded. Basically you want to turn every directory in the find to use dirname and every line into ALTER TABLE filename-without-.ISM ENGINE=MYISAM. Save this new file to fixTables.sql
- Stop the mysql server.
- Copy the mysql database to something like mysql5, this is important because we have to reset the permissions table.
- uninstall MySQL 5
- Insall MySQL 4
- run the mysql_install_db script. This rebuilds your permissions table so you can fix your table
- Start Mysql 4. If you have problems, your my.cnf is probably the issue. check your syslog and try and fix the problem.
- Make a new mysql user for upgrading your tables: /usr/bin/mysqladmin -u root password 'foo'
- Run your upgrade script: mysql -u root -p
and enter in your password. - stop the server.
- move the mysql table to something like mysql4. This is in case you need it back for whatever reason
- move mysql5 back to mysql
- Finish off by uninstalling mysql4, and going back to 5
Finished. Not easy, but not hard either. You can also use the mysql_convert_table_format script. In fact, that might be easier. I opted for this other route so I could see what was going on a little better. Upon retrospect I might have just used the script instead.
Next time, I am going to read the upgrade instructions, just in case. And maybe try to keep my table formats a little more current.
Monday, January 16. 2006
Upgrading to PHP5, droping eAccellerator, using APC (with Debian)
I used dotdeb, dispite my initial trepidtations, it was pretty painless. I had some issues because I hand-installed mod_throttle. I needed to dummy in an info file, so i just made a 500mod_throttle.info with the following contents:
LoadModule: throttle_module /usr/lib/apache/1.3/mod_throttle.so
Description: Throttle bandwidth
Next up was getting a different opcode cache, because dotdeb dropped support for eAccellerator under php5. I just did pecl install apc and everything was taken care of. It was like magic.
Thanks to Mike's sudden inspirations I had a reasonable set of configuration directives to work with, and following along with the Manual isn't too difficult either. For completeness sake, here is my config:
extension=apc.so
[apc]
apc.enabled = 1
apc.cache_by_default = 1
apc.shm_size = 32
apc.num_files_hint = 500
apc.mmap_file_mask = /tmp/apc.XXXXXX
apc.ttl = 43200
apc.file_update_protection = 4
Sunday, May 22. 2005
GAIM and Cygwin. The answer is so simple.
Gaim is a multiple IM service client, like Trillian. It however seems to be pretty good. Half the memory footprint, and free + open source. I'll post a review in about a month when the honeymoon wears off.
There is a known problem when using Gaim with Cygwin (a linux environment for windows) if you have your system path set to the Cygwin bin dirs. The documentation for gaim actually hints at the fix:
If you have a Cygwin installation (with tcl 8.4), and have added its bin directory to your PATH, then WinGaim will crash on startup. The solution is to remove cygwin's bin directory from your path. Introducing Cygwin dlls into the native win32 environment is a very bad idea, and is likely to cause problems with other programs.
The fix is simple, instead of having the Cygwin paths on your global environment table, you just want it for your shell windows. Write up a simple little batch script to modify the path like so:
@echo off set path=%PATH%;[Cygwin]\bin;[Cygwin]\usr\bin echo This is my shell of DOOOOOOOOOOOOOM!
After that, setup a shortcut to: %windir%\system32\cmd.exe /K [your batch file]. The /K switch tells cmd to keep the shell window open. Bam. Cygwin and GAIM goodness.
Update: Sometimes Gaim will half-crash on startup. It won't actually die, but it won't do anything else either. This can happen if you install something like WinAVR which uses CygWin, and it adds itself to your path. If you find Gaim crashing all of the sudden, then check out each entry in your PATH environment variable and make sure there are no cygwin dlls.Thursday, April 14. 2005
Installing php eAccelerator on Debian
- Aptitude install yourself a copy of php4-dev. This should get all the needed dependencies.
- Download and decompress the source page of eAccelerator. I put it in /usr/local/src .
- Just like the docs say, do this:
export PHP_PREFIX="/usr"
$PHP_PREFIX/bin/phpize - Now its time to configure, and build. Just like the docs:
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
If you get a message like "configure: error: no acceptable C compiler found in $PATH" that means you need to get a compiler. Duh. aptitude install build-essential your way to heaven. - Again, like the docs do a make and a make install.
- Finally add this to your php.ini:
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9" - If you want to enable the web interface, you probably want to set up an admin username and password for it. You can do that by running php -q eaccelerator_password.php. Copy the file eaccelerator.php somewhere web accessible (and while you're at it, rename the file) and finally, modify your httpd config to ensure that your local IP is the only one that can see it.
- To test it, either check a PHP info page, or try out the web interface. Tada!
Just a few notes. Unless you are using the Zend Encoder, you should disable the Zend Optimizer, this is a suggestion from the eAccelerator dev team.
Tuesday, April 12. 2005
Splitting Large Mailboxes
- Stop your MTA
- Copy the mailbox to a differnet location (so you have the original if you screw up..)
- Find out how many messages are in the damn thing, do this with grep -c "^From " [mailboxFile]
- split the mailbox with formail, you can do it like this:
cat [mailboxFile] | formail +[offset] -[lmit] -s > [newFragmentFile]
I did it in fragments of 10 messages per file, like this:
cat shell.mbox | formail -10 -s >mbox.1
cat shell.mbox | formail +10 -10 -s >mbox.2
cat shell.mbox | formail +20 -10 -s >mbox.3 - if its one big message that is causing the problem, you should be able to figure out which message it is by the size of the fragments. After that its a case of finding out the exact number (use a pager on the individual file) and using formmail to split the mailbox before and after, and merge the 2 parts into a new mail box without the offending message. If it is a case of too many messages, you probalby need more help then what I can give. I suggest looking at the fragements and see if there is a pattern of message that you can filter on. Maybe you are the victim of a mail loop?
- copy your new mailbox back to the original spool file
- restart your MTA
Tada!
Once you've split everything this way, you can probably manipulate the files directly with Thunderbird, it uses the mbox format.




