Closed kostajh closed 5 years ago
@kostajh i think you want
databasereplica:
type: mysql:5.7
portforward: true
overrides:
environment:
MYSQL_REPLICATION_MODE: slave
MYSQL_REPLICATION_USER: replicator
MYSQL_REPLICATION_PASSWORD: replicator
MYSQL_DATABASE: lamp
MYSQL_MASTER_HOST: database
ALLOW_EMPTY_PASSWORD: yes
note the overrides key
gah, I just discovered this myself :) thanks @pirog it's working now!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.
This is great and exactly what I've been looking for. However, I haven't been able to get it to work.
.lando.yml:
services:
primary:
type: mariadb:10.1
portforward: 32789
overrides:
environment:
MYSQL_REPLICATION_MODE: master
MYSQL_REPLICATION_USER: replicator
MYSQL_REPLICATION_PASSWORD: replicator
MYSQL_DATABASE: qadb
MYSQL_USER: database
MYSQL_PASSWORD: database
ALLOW_EMPTY_PASSWORD: yes
primary_replica:
type: mariadb:10.1
portforward: 32794
overrides:
environment:
MYSQL_REPLICATION_MODE: slave
MYSQL_REPLICATION_USER: replicator
MYSQL_REPLICATION_PASSWORD: replicator
MYSQL_DATABASE: qadb
MYSQL_MASTER_HOST: primary
ALLOW_EMPTY_PASSWORD: yes
tooling:
mysql:
service: masterdb
cmd: mysql -uroot
replicator
, with all the permissions. Expectation: When I create a record in the master database, it is replicated into the slave database.
Am I missing a step, or config?
Here's what I ended up with under services:
database:
overrides:
environment:
MYSQL_REPLICATION_MODE: master
MYSQL_REPLICATION_USER: replicator
MYSQL_REPLICATION_PASSWORD: replicator
type: mysql:5.7
portforward: true
databasereplica:
name: replica
type: mysql:5.7
portforward: true
overrides:
environment:
MYSQL_REPLICATION_MODE: slave
MYSQL_REPLICATION_USER: replicator
MYSQL_REPLICATION_PASSWORD: replicator
MYSQL_MASTER_HOST: database
You should be able to look at the MySQL container logs to see what's going wrong.
Hm. This looks similar to my setup; I copied it directly and it still doesn't work.
As for following the container logs, I get no action on the lando logs -f
command. Adding rows, deleting, whatever, doesn't get logged in that view.
In the tooling
section, is the masterdb
service something that's documented anywhere? I've read some about master/slave database, and it seems more complicated, but maybe that complexity is hidden in the service?
I guess the big question is do you have a cusotm my.cnf file for the databases
I struggled with this for a bit but managed to get it working with a Drupal recipe by specifying the credentials for the replica db, it didn't work if I left them blank.
name: drupal9
recipe: drupal9
config:
webroot: web
services:
database:
overrides:
environment:
MYSQL_REPLICATION_MODE: master
MYSQL_REPLICATION_USER: replicator
MYSQL_REPLICATION_PASSWORD: replicator
replica:
type: mysql:5.7
portforward: true
creds:
user: drupal9
password: drupal9
database: drupal9
overrides:
environment:
MYSQL_REPLICATION_MODE: slave
MYSQL_REPLICATION_USER: replicator
MYSQL_REPLICATION_PASSWORD: replicator
MYSQL_MASTER_HOST: database
I work on MediaWiki, and having database replication in my local development environment is very useful for reproducing production issue.
Here's my
.lando.yml
file:A couple of notes/observations:
replicator
userReplication isn't happening. Maybe I need custom .cnf files? Although the Bitnami docker-compose file says using these variables should just work...