Finally, after months of doubts, I decided to upgrade my only production server from very very very old OpenSolaris build 111b to newest stable OpenIndiana system.
Following how-tos (wikis) http://wiki.openindiana.org/oi/2.+Installing+or+Upgrading and blog http://blogs.oracle.com/observatory/entry/upgrading_from_opensolaris_2009_06 and probably many more I started to prepare my server for the worst.
Removing "Problematic" and Custom built packages
vega@james ~ $ pkg list -s | grep '(webstack)'
phpmyadmin (webstack) phpMyAdmin is a web application written in PHP used for administering a MySQL database. See project website at http://www.phpmyadmin.net/
vega@james ~ $ pfexec pkg uninstall phpmyadmin
I also built one custom package to add lzma command for my installation. For sure, I removed it:
vega@james ~ $ pfexec pkgrm SFElzma
Removing repositories
vega@james ~ $ pfexec pkg unset-publisher webstack
vega@james ~ $ pfexec pkg unset-publisher localhost
Create a New Boot Environment
vega@james ~ $ pfexec beadm create opensolaris-2011-05-14
Update the OpenSolaris Image
According to OpenIndiana Wiki:
"In order to upgrade, you should be running OpenSolaris build 134 (snv_134) or 134b (snv_134b), the last releases published by Oracle (Sun). Upgrading from later builds including 145 and 146 may work, but is unsupported."
Well, let's do that.
vega@james ~ $ pfexec pkg install SUNWipkg SUNWipkg-um SUNWipkg-gui
vega@james ~ $ pfexec pkg set-publisher -O http://pkg.openindiana.org/legacy opensolaris.org
vega@james ~ $ pfexec pkg image-update -v --be-name=opensolaris-b134
MySQL 5.0 to 5.1 migration
Looks like MySQL version 5.0 was removed from build 134. Mine 5.0 was located in zone0, so we need to move old data and migrate them.
First copy the manifest>
james ~ # mkdir /export/zones/zone0/root/var/svc/manifest/application/database/
james ~ # cp /var/svc/manifest/application/database/mysql_51.xml /export/zones/zone0/root/var/svc/manifest/application/database/
Login to zone0 and import the manifest:
zone0 ~ # svccfg import /var/svc/manifest/application/database/mysql_51.xml
Start the database:
zone0 ~ # svcadm enable svc:/application/database/mysql:version_51
Check the log if it works correctly:
zone0 ~ # tail -f /var/svc/log/application-database-mysql\:version_51.log
I want to use 64bit version of MySQL:
zone0 ~ # svccfg -s svc:/application/database/mysql:version_51
svc:/application/database/mysql:version_51> setprop mysql/enable_64bit = boolean: true
Delete all sample data from 5.1 and copy old 5.0 data:
zone0 ~ # rm -rf /var/mysql/5.1/data/ && cp -r /var/mysql/5.0/data/ /var/mysql/5.1/
Okay, now the configs. Sample fonfigs will not work (at least not with InnoDB engine), because they are from the Maria Theresa ages (MySQL 4.x). If you need to use InnoDB (like I do), copy e.g. my-huge.cnf or my.innodb-heavy-4G.cnf to my.cnf:
zone0 5.1 # cp my-huge.cnf my.cnf
Now find lines:
# Uncomment the following if you are using InnoDB tables
and uncomment them. This is the most important step - make sure you delete / comment / wipe and forget the following line:
innodb_log_arch_dir = /var/mysql/5.1/data/
because this is a reason why MySQL will keep restarting and fail into maintenence. And another reason why InnoDB plugin will refuse to start is its logs. This is what helped me - comment / remove / whatever the following lines in my.cnf:
innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
innodb_log_file_size = 100M
innodb_log_buffer_size = 8M
and then delete the logfiles in /var/mysql/5.1/data/:
zone0 5.1 # rm /var/mysql/5.1/data/ib_logfile*
Optionally add MySQL error log and disable binlog if you don't need it:
Error log - add this line to the [mysqld] section of my.cnf:
log-error = /var/svc/log/application-database-mysql:version_51.err
and make sure it is writable for mysql.
To disable binlog delete / comment out the following lines in my.cnf:
log-bin=mysql-bin
binlog_format=mixed
Finally run the upgrade process:
zone0 ~ # /usr/mysql/5.1/bin/mysql_upgrade -u root -p
Try to run the database and check logs for messages:
zone0 ~ # svcadm enable svc:/application/database/mysql:version_51
Update all zones
for z in zone0 zone1 zone2 zone3 zone4
do
zoneadm -z ${z} detach
zoneadm -z ${z} attach -u
done
Once one of my zones just failed to upgrade during the process. If so, follow http://voyager-eng.livejournal.com/2446.html, it solved the problem.
Check your zones
As Maverck's blog says:
"You may want to boot your zones and check, if they run properly, before going for the final upgrade."
Mine worked as a charm :)
Update OpenSolaris build 134 to OpenIndiana
Simply follow the steps described at OpenIndiana wiki http://wiki.openindiana.org/oi/Upgrading+from+OpenSolaris.
Update all zones in OpenIndiana - not "The Standard Way"
Okay, this is the tricky part. Simple zone upgrade like described a few steps above will fail with message:
ERROR: Could not update attaching zone Result: Attach Failed.
Solution to this problem is described at blog o' less:
If you are lazy to read, you can just use this fragment of code:
zoneadm -z zonename halt
pkg -R /zones/zonename/root image-update -v