ZFS Boot environments

If I'm correct /var/db/mysql is by default part of default boot enviroments as used by tool beadm ?
Nothing wrong with the tool, but when your Database is part of boot system ...
 
You could create a file system for MySQL to reside on separate from the root file system. It might even be a good idea for database optimization to use non-default ZFS settings.
 
By default, yes. If you do a zfs list you see the datasets and any associated mountpoint. If there is not a specific dataset with distinct mountpoint, then yes it winds up effectively "off /" (poke around looking at zfs/zpool property canmount).
/usr is a dataset, has property canmount=no, so anything with a mountpoint of /usr/whatever is in the root dataset UNLESS you have a distinct dataset. /usr/home has it's own, so it's not part of root dataset. /usr/local does not by default, so it is part of the root dataset.

As for /var/db/mysql? The easiest thing to do would be create a dataset mounted at /var/db before installing mysql. But you sometimes need to be aware of any startup scripts.

Michael W Lucas & Allan Jude, "FreeBSD Mastery: Advanced ZFS" has a lot of good information about boot environments and specifically talks about MySQL and other databases.
 
In a default setup, anything that resides on the zroot/ROOT/default filesystem will be included in boot environments. Some directories are excluded by default with their own ZFS datsets, such as /var/log, /var/mail, /usr/ports and of course /usr/home – basically, anything you see outside of zroot/ROOT in a zfs list.

Since the default setup can't possibly take every application and its data storage locations into account, it is bound to miss some of them, and this is the case for MySQL databases.

To exclude such locations from boot environments, just create a separate dataset for them :)
 
basically, anything you see outside of zroot/ROOT in a zfs list.
Well, the mounted things; for example, zroot/usr and zroot/var are by default not mounted, so only the explicit subtrees that have their own mounted filesystem are excluded from the BE:
Code:
$ zfs list -ro mounted,canmount,name,mountpoint
MOUNTED  CANMOUNT  NAME                               MOUNTPOINT
no       off       zroot                              /zroot
no       on        zroot/ROOT                         none
no       noauto    zroot/ROOT/13.0-RC5                /
yes      noauto    zroot/ROOT/13.0-RELEASE            /
no       off       zroot/empty                        /zroot/empty
yes      on        zroot/tmp                          /tmp
no       off       zroot/usr                          /usr
yes      on        zroot/usr/home                     /usr/home
yes      on        zroot/usr/obj                      /usr/obj
yes      on        zroot/usr/obj-ccache               /usr/obj-ccache
yes      on        zroot/usr/ports                    /usr/ports
yes      on        zroot/usr/ports/distfiles          /usr/ports/distfiles
yes      on        zroot/usr/src                      /usr/src
no       off       zroot/var                          /var
yes      on        zroot/var/audit                    /var/audit
yes      on        zroot/var/crash                    /var/crash
yes      on        zroot/var/log                      /var/log
yes      on        zroot/var/mail                     /var/mail
yes      on        zroot/var/synth                    /var/synth
yes      on        zroot/var/tmp                      /var/tmp

You can shutdown mysql and move the appropriate tree into its own dataset; something like:

Code:
service mysql-server stop
mv /var/db/mysql{,.orig}
zfs create -o canmount=off zroot/var/db  # for hierarchy, not a mounted filesystem
zfs create zroot/var/db/mysql
rsync -av /var/db/mysql{.orig,}/
service mysql-server start

With this, mysql's DB will be independent of BEs. I do this (not on the system above) with Samba, for example. (Otherwise AD membership stuff gets confused if I revert to an old dataset.) You can tune some of the properties for the mysql dataset(s) as mentioned by SirDice above.
 
Back
Top