私が管理している FreeBSD で動かしているWordPress 用のデータベース MySQL は、殆ど5.5系で動かしていて、今は5.6が動いています。
ところが、このメモを動かしているサーバーは、MySQL5.1が動いています。サーバーを立ち上げた時期が早かったため 5.0系で構築していました。MySQLサーバーを直接制御する訳じゃないし、WordPress が対応している限り特にアップデートしなくてもいいかと、MySQL 5.5系がFreeBSD標準になった後もそのまま動かしていました。一番恐れていたのが、5系から5.5系に更新してMySQLの中のデータベースが壊れる事。99%大丈夫と思うもののデータベースが壊れると、過去の統計情報が失われてしまうかもしれないと、問題なく動いているものには触るな!というトラブるを作らないシステム管理の鉄則に基づき手を触れないようにしていましたが、とうとう手を付けざるを得なくなってしまいました。(ちなみにWordPress コンテンツは、エクスポート機能でバックアップ可能。)
具体的には、「pkg version -vL=」というコマンドで、インストールされているパッケージの整合性を確認すると、いつの間にか、mysql 5.1 系は ports から消えてしまっていることに先日気がつきました。
ja-freebsd-doc-47441_1,1 < needs updating (index has 47846,1) mysql51-client-5.1.73_3 ? orphaned: databases/mysql51-client mysql51-server-5.1.73_3 ? orphaned: databases/mysql51-server
このまま使い続けても動作的には問題ないはずですけど、関連機能とかセキュリティーの心配があるので、とうとう、MySQL をメージャーバージョンアップする事にしました。
UPDATING を見ると、5.1系から5.5系へのアップデート方法を紹介する記事がないため、5.5→5.6への更新方法を参考にしました。想像ですが、多分、単純にmysql 5.1系を削除して5.6系を入れるだけでも大丈夫だろうと思いましたが、事前に呪文を唱えておく方が安心そうなので、以下UPDATINGメモの下3行を 55→51 に変更して実行。
20150204:
AFFECTS: users of databases/mysql55-(server|client)
AUTHOR: ale@FreeBSD.org
The default MySQL version has been updated from 5.5 to 5.6.
If you compile your own ports you may keep 5.5 as the default version by
adding the following lines to your /etc/make.conf file:
#
# Keep MySQL 5.5 as default version
#
DEFAULT_VERSIONS+=mysql= 5.5
If you wish to update to the new default version, you need to first stop any
running server instance. Then, you will need to follow these steps, depending
on installed packages.
# pkg set -o databases/mysql55-client:databases/mysql56-client
# pkg set -o databases/mysql55-server:databases/mysql56-server
# pkg upgrade
1月1日の深夜に作業開始。
WebサーバーとMySQLサーバーを停止した後、
# pkg set -o databases/mysql51-client:databases/mysql56-client Change origin from databases/mysql51-client to databases/mysql56-client for mysql51-client-5.1.73_3? [y/N]: y # pkg set -o databases/mysql51-server:databases/mysql56-server Change origin from databases/mysql51-server to databases/mysql56-server for mysql51-server-5.1.73_3? [y/N]: y # pkg upgrade Updating FreeBSD repository catalogue... FreeBSD repository is up-to-date. All repositories are up-to-date. Checking for upgrades (3 candidates): 100% Processing candidates (3 candidates): 100% Checking integrity... done (0 conflicting) Your packages are up to date. #
あれ? バージョンアップが起きない!
結局、手作業で、delete と install を発行することになりました。
# pkg delete mysql51-client mysql51-server Checking integrity... done (0 conflicting) Deinstallation has been requested for the following 2 packages (of 0 packages in the universe): Installed packages to be REMOVED: mysql51-client-5.1.73_3 mysql51-server-5.1.73_3 The operation will free 52 MiB. Proceed with deinstalling packages? [y/N]: y [1/2] Deinstalling mysql51-server-5.1.73_3... ==> You should manually remove the "mysql" user. [1/2] Deleting files for mysql51-server-5.1.73_3: 100% [2/2] Deinstalling mysql51-client-5.1.73_3... [2/2] Deleting files for mysql51-client-5.1.73_3: 100% # pkg install mysql56-server mysql56-client Updating FreeBSD repository catalogue... FreeBSD repository is up-to-date. All repositories are up-to-date. The following 2 package(s) will be affected (of 0 checked): New packages to be INSTALLED: mysql56-server: 5.6.27 mysql56-client: 5.6.27 The process will require 122 MiB more space. 10 MiB to be downloaded. Proceed with this action? [y/N]: y Fetching mysql56-server-5.6.27.txz: 100% 8 MiB 434.1kB/s 00:20 Fetching mysql56-client-5.6.27.txz: 100% 1 MiB 316.4kB/s 00:06 Checking integrity... done (0 conflicting) [1/2] Installing mysql56-client-5.6.27... [1/2] Extracting mysql56-client-5.6.27: 100% [2/2] Installing mysql56-server-5.6.27... ===> Creating users and/or groups. Using existing group 'mysql'. Using existing user 'mysql'. [2/2] Extracting mysql56-server-5.6.27: 100% 中略 Message from mysql56-server-5.6.27: ************************************************************************ Remember to run mysql_upgrade the first time you start the MySQL server after an upgrade from an earlier version. ************************************************************************ #
これで、MySQLのアップグレードが完了したかと、MySQL5..6を起動してみたところ、、、
# /usr/local/etc/rc.d/mysql-server start Starting mysql. # ps ax|grep mysql # ps aux|grep mysql #
MySQLが走ってな〜い。お〜い!
/var/db/mysql 以下のエラーログを開いてみると、エラーが残っていました。
2016-01-02 01:10:17 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-01-02 01:10:17 0 [Note] /usr/local/libexec/mysqld (mysqld 5.6.27-log) starting as process 81554 ... 2016-01-02 01:10:17 81554 [Note] Plugin 'FEDERATED' is disabled. 2016-01-02 01:10:17 81554 [Note] InnoDB: Using atomics to ref count buffer pool pages 2016-01-02 01:10:17 81554 [Note] InnoDB: The InnoDB memory heap is disabled 2016-01-02 01:10:17 81554 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2016-01-02 01:10:17 81554 [Note] InnoDB: Memory barrier is not used 2016-01-02 01:10:17 81554 [Note] InnoDB: Compressed tables use zlib 1.2.3 2016-01-02 01:10:17 81554 [Note] InnoDB: Not using CPU crc32 instructions 2016-01-02 01:10:17 81554 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2016-01-02 01:10:17 81554 [Note] InnoDB: Completed initialization of buffer pool 2016-01-02 01:10:17 81554 [Note] InnoDB: Highest supported file format is Barracuda. 2016-01-02 01:10:18 81554 [Warning] InnoDB: Resizing redo log from 2*320 to 2*3072 pages, LSN=3311324 2016-01-02 01:10:18 81554 [Warning] InnoDB: Starting to delete and rewrite log files. 2016-01-02 01:10:18 81554 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB 2016-01-02 01:10:21 81554 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB 2016-01-02 01:10:24 81554 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 2016-01-02 01:10:24 81554 [Warning] InnoDB: New log files created, LSN=3311324 2016-01-02 01:10:24 81554 [Note] InnoDB: 128 rollback segment(s) are active. 2016-01-02 01:10:25 81554 [Note] InnoDB: Creating tablespace and datafile system tables. 2016-01-02 01:10:25 81554 [Note] InnoDB: Tablespace and datafile system tables created. 2016-01-02 01:10:25 81554 [Note] InnoDB: Waiting for purge to start 2016-01-02 01:10:25 81554 [Note] InnoDB: 5.6.27 started; log sequence number 3311324 2016-01-02 01:10:25 81554 [ERROR] /usr/local/libexec/mysqld: unknown option '--skip-locking' 2016-01-02 01:10:25 81554 [ERROR] Aborting
–skip-locking 機能って何?そんなの設定した記憶はないんだけど・・・
起動スクリプトの /usr/local/etc/rc.d/mysql-server の中身をチェックしてみましたが、記述無し。
そういえば、mysql 5.1の場合は、/etcの下に my.cnf をおいていたことを思い出しました。5.5系の場合は、/etc の下には my.cnf を置いていなかったような。
my.cnf を my.cnf.o にファイル名変更して mysql-server スクリプトを発行したところ、mysql が起動しました。
Apache も起動して、Webサーバーをアクセスしてみると、無事にWordPress ページが表示されました。
全ドキュメントを開いてみたわけではありませんが、特に目に付く障害もないので無事にmysqlデータベースの更新も行われたようです。作業時間にして約30分間。MySQLが起動しなかった時は、どうしたものかと思いましたけど、無事にMySQLのバージョンアップが出来てほっとしました。