How can I enable MySQL binary logging using the official Docker image? -
what best way enable binary logging using official mysql image?
i have tried using mysql:5.7 image, overriding command when running pass through startup options enable binary logging mysqld (see below). problem approach mysql user not have permission write /var/log/mysql
directory.
the run command:
docker run -d \ --name mysql \ -v /var/lib/mysql:/var/lib/mysql \ mysql:5.7 \ mysqld \ --datadir=/var/lib/mysql \ --user=mysql \ --server-id=1 \ --log-bin=/var/log/mysql/mysql-bin.log \ --binlog_do_db=test
the output:
mysqld: file '/var/log/mysql/mysql-bin.index' not found (errcode: 2 - no such file or directory)
should fork repository , add together volume /var/log/mysql
mysql user can write , create custom image, or there improve way it? possible using official mysql image?
the problem approach mysql user not have permission write /var/log/mysql directory
the problem directory /var/log/mysql
not exists on mysql:5.7
docker image. can create sure of running next container:
$ docker run --rm mysql:5.7 ls /var/log/ alternatives.log apt bootstrap.log btmp dmesg dpkg.log faillog fsck lastlog wtmp
furthermore, mysql binary logs aren't logs meant next mysql server activity or errors ; logs meant give mysql server chance recover info in case of server crash.
as consequence, want binary logs:
to remain close info to written on fast file systemin cases, docker container file scheme slow , that's why mysql info folder container declared volume.
so want binary logs written on docker info volume , not docker container file system.
long story short, start container with:
docker run -d \ --name mysql \ -v /var/lib/mysql:/var/lib/mysql \ mysql:5.7 \ mysqld \ --datadir=/var/lib/mysql \ --user=mysql \ --server-id=1 \ --log-bin=/var/lib/mysql/mysql-bin.log \ --binlog_do_db=test
mysql docker
Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. logging charts
ReplyDelete