<p>I want to start two maria-db pod with same persistent storage and any point of time I should be able to access both the instance and data should be in sync between them. </p>

<p>I am trying to start two mariadb instance using same volume persistent storage in kubernetes. I am able to start both the instance. I am performing the below steps.</p>

<ol>
<li>Creating a persistent volume</li>
<li>Creating a persistent volume claim</li>
<li>Using the same claim name starting mariadb-instance-1.</li>
<li>Starting mariadb-instance-2 using same storage claim name.</li>
<li>Creating two services for both the instance to access from outside.</li>
</ol>

<p>I am able to access instance-1 but when I am trying to access instance-2 its giving me error. MySQL Error: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’.</p>

<p>Please find the attached dockerfiles.</p>

<p>Any help will be appreciated.</p>

<p>Please find the below git repo for db and storage yaml file which I used to create the deployment.</p>

<p><a href="https://github.com/chandan493/db-as-docker" rel="nofollow noreferrer">https://github.com/chandan493/db-as-docker</a></p>

<p>You can not run two MariaDB engines on the same storage, and if I understood you right this is what you expected. Even if you'd mount an RWX volume on two pods, if you put /var/lib/mysql of containers in two separate MaraiaDB pods in the same place, it will result in a conflict between database engines. For MariaDB clustering lookup <code>MariaDB Galera</code> - an almoust-fully-synchronous replication for MariaDB. But you'll need three db engines running for it to make sense.</p>
