Sample Header Ad - 728x90

mysql-shell: assign the return for dba.checkInstanceConfiguration() to a javascript variable

0 votes
1 answer
151 views
I am trying to create a javascript file that is invoked by mysql-shell that can automatically 1. test, using dba.checkInstanceConfiguration("user@mysql-node:3306"), if instance is ready for cluster devlopment 2. if not invoke dba.configureInstance("user@mysql-node:3306") 3. if instance is ready for cluster development, invoke: shell.connect("user@mysql-node:3306") cdCluster = dba.createCluster("cd-cluster"); cdCluster = dba.getCluster("cd-cluster"); cdCluster.addInstance("user@mysql-node:3306"); When we invoke: dba.checkInstanceConfiguration("user@mysql-node:3306") The resulting text contain either: { "status": "ok" } or something like { "config_errors": [ { "action": "server_update", "current": "COMMIT_ORDER", "option": "binlog_transaction_dependency_tracking", "required": "WRITESET" }, { "action": "server_update+restart", "current": "OFF", "option": "enforce_gtid_consistency", "required": "ON" }, { "action": "server_update+restart", "current": "OFF", "option": "gtid_mode", "required": "ON" }, { "action": "server_update+restart", "current": "1", "option": "server_id", "required": "" } ], "status": "error" } as part of the response. Is there a way one can get the json response for use in a javascript function that can be used to dynamically react by either invoking: dba.configureInstance("root@mysql-pri:3306"); or cdCluster = dba.createCluster("cd-cluster"); The documentation for dba.checkInstanceConfiguration("user@mysql-node:3306") suggest, the return is JSON. When I do: ret = dba.checkInstanceConfiguration("user@mysql-node:3306") console.log(ret) ..nothing is retured but I can see the text output. Can someone help please?
Asked by goremo (1 rep)
Aug 31, 2022, 06:23 PM
Last activity: Jul 19, 2025, 01:06 AM