Skip to content

daemontools

socat permitting MySQL migration

Fast idea using socat (loosed as draft since 2013-02-01) to quickly migrate a tcp and/or unix socket MySQL installation. (socat-1.7.2.0 used for the test).

If the need is temporary, this avoid a MySQL Proxy setup.

Launch that as a daemontools service (for example):

1. /service/socat-mysql-tcp/run

#!/bin/bash
bind_port=3306
bind_addr=127.0.0.1
forward_port=3304
forward_host=sql.dedicated
exec setuidgid mysql socat -d TCP4-LISTEN:${bind_port},bind=${bind_addr},fork TCP4:${forward_host}:${forward_port}

2. /service/socat-mysql-unixsocket/run

#!/bin/bash
sock=/tmp/mysql.sock
forward_port=3304
forward_host=sql.dedicated
exec setuidgid mysql socat UNIX-LISTEN:${sock},fork TCP4:${forward_host}:${forward_port}