I am running a MariaDB server and an OpenVPN server (SoftEther in this case) on an Ubuntu 20.04 LTS machine.
On my Raspberry Pi, I am running a MariaDB server aswell.

My goal is to enable a Master-Slave-Replication of the MariaDB, whereby the Raspi acts as master and the Ubuntu server as slave (as described in this well-done article https://www.linuxbabe.com/mariadb/master-slave-replication-ubuntu-18-04-18-10).

Therefore, I need the Raspi to have a static or at least known IP address so that the slave DB-server knows where to get the data from (IP address needs to be hardcoded in config file). The tricky part is that due to the desired application of the Raspi it will be plugged in into multiple networks from time to time so that a "normal" procedure with DynDNS at a single router etc. will obviously not work sufficiently.

Hence, my idea is to configure the Raspi as a VPN client, which automatically connects to the VPN server (which runs on the same machine as the MariaDB-slave) on startup. This way I can read the IP address of the Raspi in the VPN from the server log and use it for the SQL replication config.

Connecting the Raspi as client to the VPN server works sufficiently, BUT if I try to connect the MariaDB slave (server) to the MariaDB master (Raspi) by using the Raspi's IP address in the VPN (adapter tun0), the slave cannot reach the master.
How is that possible, given that the Raspi is successfully connected to the VPN server running on the same machine as the MariaDB slave server? Is there a need to "connect" the MariaDB application (on the server) into the same VPN as the MariaDB master (Raspi)?

Every help is greatly appreciated.

  • Please edit your question and add more details: How exactly do you try to connect the MariaDB slave to the MariaDB master and what error do you get? Copy&paste the exact command or configuration file you use and the exact error message or log messages and format this as code blocks, e.g. by using the {} tool of the editor field.
    – Bodo
    Mar 31, 2022 at 16:25
  • 1
    That's entirely a network configuration problem and has nothing to do with database administration. You should probably ask it on serverfault.com and post detailed VPN configuration info.
    – mustaccio
    Mar 31, 2022 at 19:48
  • Given the VPN IP address of the Raspi master is the only constant, the "server" replia needs to be on the VPN too. Then CHANGE MASTER TO MASTER_HOST='ip of Master VPN IP'. CHANGE MASTER also has replication re-connection options.
    – danblack
    Apr 1, 2022 at 3:06


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.