以下のようなエラーが出て、mysqlのdockerが立ち上がらなくなっていた。
Log file ./ib_logfile0 size 18833408 is not a multiple of innodb_page_size
Log file ./ib_logfile1 is of different size 0 bytes than other log files 18923520 bytes!
innodb_page_size を 16kB から 8kB に変更してみても、2つ目のエラーが出て停止した。
mysqlが確保したと思っている容量と、ファイルシステムから返ってくる容量が違っている容量が違うようだった。
同様の現象が報告されていて、修正のPRは上がっているが、確認した時点ではまだリリースされていないようである。2.1.5 で修正がリリースされる見込みと書かれていた。
その場しのぎの対策として、zfs からブロックデバイスを切り出し、ext4 でフォーマットしてマウントして使うというテクニックが紹介されており、私もこれで凌ぐことができた。
以下、手順を記載する。
zfs からブロックデバイスを切り出す
sudo zfs create -s -V 50g rpool/MYSQL
ブロックデバイスができていることを確認する
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
...
zd0 230:0 0 50G 0 disk
ブロックデバイスにパーティションを作成する
sudo gdisk /dev/zd0
Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y
Command (? for help): p
Disk /dev/zd0: 104857600 sectors, 50.0 GiB
Sector size (logical/physical): 512/8192 bytes
Disk identifier (GUID): 98B290DB-F56C-420D-85BA-EBACCA1657D8
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 104857566
Partitions will be aligned on 2048-sector boundaries
Total free space is 104857533 sectors (50.0 GiB)
Number Start (sector) End (sector) Size Code Name
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-104857566, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-104857566, default = 104857566) or {+-}size{KMGTP}:
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/zd0.
The operation has completed successfully.
ブロックデバイスができていることを確認する
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
...
zd0 230:0 0 50G 0 disk
└─zd0p1 230:1 0 50G 0 part
ext4 でフォーマットする
sudo mkfs.ext4 /dev/zd0p1
/etc/fstab に書いてマウントする
sudo mkdir /var/lib/mysql
sudo vi /etc/fstab
/etc/fstab
/dev/zd0p1 /var/lib/mysql ext4 nofail 0 0
そしてmysqlを起動する。私の場合はdocker-composeで動かしていたため、volume mount でこのパスを指定しました。
version: "3.7"
services:
mysql:
image: mysql/mysql-server:8.0.27
environment:
- MYSQL_USER=xxx
- MYSQL_PASSWORD=xxx
- MYSQL_ROOT_PASSWORD=xxx
- MYSQL_ROOT_HOST=%
- MYSQL_DATABASE=xxx
ports:
- 3306:3306
volumes:
- /var/lib/mysql:/var/lib/mysql