MySQL Router not working on restarting docker container
Everything runs fine when tried for the first time. Cluster got created and router working fine. Then I stop the containers and when I tried restarting them I get following issue mysql-router | Error: The provided server contains an unsupported InnoDB cluster metadata
I think the example starts a new, temporary cluster only and state does not get carried over restarts.
Just wondering do you have idea how the state can be persisted. I tried mounting volume but still the same issue.
I'm not an expert on mysql cluster myself. But if I recall correctly (it's been a while I was looking into this), removing all the nodes from the cluster (which happens when it is stopped with docker-compose, is too much for it to handle. Maybe (I'm almost guessing myself), some kind of staggered rollout can work, I mean only stop one at a time. Basically it's a question of mysql cluster recovery and how to apply the docker building blocks to it (restart, ordering, volume mounts).
If you discover anything that impacts the format of the docker images themselves, please let me know.
by adding this u can save the router config
but after that we got an other error
mysql-router:
env_file:
- mysql-router.env
image: mysql/mysql-router:8.0.13
volumes:
- /root/docker/mysql-router/tmp:/tmp <-- path for saving the router cfg
Error: The provided server is currently not an ONLINE member of a InnoDB cluster.
finaly found the trouble ,
you also need to to that in the setupScript.js
shell.connect('root@mysql-server-1:3306', dbPass) try { print('Setting up InnoDB cluster...\n'); var cluster = dba.createCluster(clusterName); print('Adding instances to the cluster.'); cluster.addInstance({user: "root", host: "mysql-server-2", password: dbPass}) print('.'); cluster.addInstance({user: "root", host: "mysql-server-3", password: dbPass}) print('.'); cluster.addInstance({user: "root", host: "mysql-server-4", password: dbPass}) print('.'); cluster.addInstance({user: "root", host: "mysql-server-5", password: dbPass}) print('.\nInstances successfully added to the cluster.'); print('\nInnoDB cluster deployed successfully.\n'); } catch(e) { setTimeout(()=>{ <<---- this is important thing print('Try to rebooting cluster\n'); <<---- this is important thing dba.rebootClusterFromCompleteOutage(); <<---- this is important thing print('\nInnoDB cluster deployed successfully.\n'); <<---- this is important thing
},10000) <<---- this is important thing print('\nThe InnoDB cluster could not be created.\n\nError: ' + e.message + '\n'); }
hello, when restart the mysql-router, the logs show that "Error: No result returned for metadata query"
while running mysql shell in a mysql5.7 server, I run "dba.getCluster()" and got this error:
No cluster change operations can be executed because the installed metadata version 1.0.1 is lower than the version required by Shell which is version 2.1.0.
i think it's because the version of the mysql-shell is too old, i will try create a cluster using the newer mysql shell, and check the result then.
after create cluster and add instance, connect to each mysql server container, and call "dba.configureLocalInstance()" to apply the newest config about group_replication_local_address and group_replication_group_seeds to my.cnf. then this problem was solved.