mysql-docker-compose-examples icon indicating copy to clipboard operation
mysql-docker-compose-examples copied to clipboard

MySQL Router not working on restarting docker container

Open siddharth-chaudhery opened this issue 5 years ago • 7 comments

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

siddharth-chaudhery avatar Apr 24 '20 11:04 siddharth-chaudhery

I think the example starts a new, temporary cluster only and state does not get carried over restarts.

neumayer avatar Apr 25 '20 15:04 neumayer

Just wondering do you have idea how the state can be persisted. I tried mounting volume but still the same issue.

siddharth-chaudhery avatar Apr 25 '20 15:04 siddharth-chaudhery

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.

neumayer avatar Apr 26 '20 09:04 neumayer

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.
  

bozoweed avatar Feb 12 '23 12:02 bozoweed

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'); }

bozoweed avatar Feb 12 '23 15:02 bozoweed

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.

chenling8523 avatar Apr 24 '23 10:04 chenling8523

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.

chenling8523 avatar Apr 25 '23 07:04 chenling8523