Dockerless Services (with Nix)
So you want an “isolated” MySQL “service” but don’t want to (or are not able to) run Docker/rkt/LXC/whatever?
Here are the tl;dr steps:
|
|
Why?
My motivation for this was running a database on a machine with a specially tuned kernel that did not support containers.
How it works?
Create a new folder to host all data for your service
|
|
Get the binary somewehere. I use Nix due to its pure stateless nature - it allows me to have different conlicting versions on my system without any container magic.
|
|
Initialize the data structure. Mind the --datadir
|
|
Launch the server. If you want to run multiple instances you also need to
specify a port number with --port
here. Socket is also placed in the datadir
so the init does not try to pullute in /run
|
|
Finish configuration and use. Need to provide the IP here since UNIX socket is on a non-standard place.
|
|
You can now stop with
|
|
Going faster
You can mount tmpfs
for your datadir to make MySQL go really fast. Note
your data is not persisted to your harddrive anymore - use with caution.
|
|
Creating an in-memory filesystem is slightly more involved for MacOS users but still not too bad.
Automate all the things
With the assumption that we want to store data under /tmp
and that /tmp
is
already tmpfs
we can fully automate the script above:
|
|
Or even make it self-contained and pull in the right MySQL as well
|
|
Last modified on 2017-08-30
Previous TDD-ing a toy sized projectNext Implementing apply on tuples in Scala