openark / orchestrator

MySQL replication topology management and HA
Apache License 2.0
5.64k stars 933 forks source link

different info from API and web interface #556

Closed unix196 closed 6 years ago

unix196 commented 6 years ago

Good day!

Debian GNU/Linux 8.6 (jessie)
dpkg -l | grep orch
ii  orchestrator                 1:3.0.11          amd64        MySQL replication topology management and HA
ii  orchestrator-cli             1:3.0.11          amd64        MySQL replication topology management and HA: binary only
cat /etc/orchestrator.conf.json 
{
  "Debug": false,
  "EnableSyslog": false,
  "ListenAddress": "127.0.0.1:3001",
  "MySQLOrchestratorHost": "127.0.0.1",
  "MySQLOrchestratorPort": 3306,
  "MySQLOrchestratorDatabase": "orchestrator",
  "MySQLOrchestratorUser": "orchestrator",
  "MySQLOrchestratorPassword": "passw3",
  "MySQLTopologyUser": "orchestrator",
  "MySQLTopologyPassword": "passw4",
  "HostnameResolveMethod": "none",
  "MySQLHostnameResolveMethod": "@@report_host"
}

In web interface I discover three hosts and orchestrator draw dashboard with this three host - one master, two slave, all good. But if I try use API - it return wrong information about slave ports

curl -s http://orchestrator.local/api/instance/master_host/3306 | json_pp
   "SlaveHosts" : [
      {
         "Port" : 3306,
         "Hostname" : "slave1"
      },
      {
         "Hostname" : "slave2",
         "Port" : 3306
      }

On master_hosts:

mysql> show slave hosts;
+------------+------------------------+------+-----------+
| Server_id  | Host                   | Port | Master_id |
+------------+------------------------+------+-----------+
|        221 | slave1                  | 3307   |       220 |
|        203 | slave2                   | 3307 |       220 |
+------------+------------------------+------+-----------+

Slaves servers works on port 3307, but API return that they connected to master_host from 3306 port. In general, API works fine, for example: it returns true information for mysql binary log file and LogPosition. In GUI slave hosts depict that they connected to master from 3307 ports. Why this can be happen?

shlomi-noach commented 6 years ago
  1. Which port is the master running on?
  2. Are you using "DiscoverByShowSlaveHosts": true, ?
  3. What does select @@report_host, @@report_port return on each of the two replicas?
unix196 commented 6 years ago
  1. master run on 3306 port
  2. now I add this option to config, destroy dashboard and re-discover hosts - nothing change (API and web return different info about slave ports)
  3. run mysql command on the two slaves
    
    mysql> select @@report_host;
    +------------------------+
    | @@report_host          |
    +------------------------+
    | DNS NAME SLAVE1 |
    +------------------------+
    mysql> select @@report_port;

+---------------+ | @@report_port | +---------------+ | 3307 |

mysql> select @@report_host; +------------------------+ | @@report_host | +------------------------+ | DNS NAME SLAVE2 | +------------------------+ mysql> select @@report_port; +---------------+ | @@report_port | +---------------+ | 3307 | +---------------+



P.S. API return IP addresses of the slaves insted dns name, "show slave hosts"  return dns name of the slave  (may be it important)
unix196 commented 6 years ago

API call

curl -s http://orchestrator.local/api/instance/master_host/3306 | json_pp
{
   "LastSeenTimestamp" : "2018-07-10 15:51:42",
   "DowntimeEndTimestamp" : "",
   "VersionComment" : "Percona Server (GPL), Release 38.5, Revision 71794d3",
   "InstanceAlias" : "",
   "CountMySQLSnapshots" : 0,
   "SupportsOracleGTID" : false,
   "Uptime" : 2207219,
   "LastIOError" : "",
   "Version" : "5.5.53-38.5-log",
   "Slave_SQL_Running" : false,
   "MasterKey" : {
      "Port" : 0,
      "Hostname" : ""
   },
   "PromotionRule" : "neutral",
   "LastDiscoveryLatency" : 5682377,
   "AllowTLS" : false,
   "ServerID" : 220,
   "ServerUUID" : "",
   "ElapsedDowntime" : 0,
   "IsLastCheckValid" : true,
   "IsCandidate" : false,
   "SecondsBehindMaster" : {
      "Int64" : 0,
      "Valid" : false
   },
   "SemiSyncEnforced" : false,
   "DowntimeOwner" : "",
   "FlavorName" : "Percona",
   "DataCenter" : "",
   "PhysicalEnvironment" : "",
   "Binlog_format" : "ROW",
   "SQLDelay" : 0,
   "IsDowntimed" : false,
   "LogBinEnabled" : true,
   "SuggestedClusterAlias" : "",
   "IsRecentlyChecked" : true,
   "ReadOnly" : false,
   "IsCoMaster" : false,
   "IsDetachedMaster" : false,
   "LastSQLError" : "",
   "SlaveLagSeconds" : {
      "Valid" : false,
      "Int64" : 0
   },
   "SemiSyncMasterEnabled" : false,
   "DowntimeReason" : "",
   "RelaylogCoordinates" : {
      "LogFile" : "",
      "Type" : 1,
      "LogPos" : 0
   },
   "ReadBinlogCoordinates" : {
      "LogFile" : "",
      "LogPos" : 0,
      "Type" : 0
   },
   "ClusterName" : "master_host:3306",
   "HasReplicationCredentials" : false,
   "Key" : {
      "Port" : 3306,
      "Hostname" : "master_host"
   },
   "ReplicationDepth" : 0,
   "GtidPurged" : "",
   "UnresolvedHostname" : "",
   "UsingMariaDBGTID" : false,
   "Slave_IO_Running" : false,
   "GTIDMode" : "",
   "IsDetached" : false,
   "ExecBinlogCoordinates" : {
      "LogFile" : "",
      "LogPos" : 0,
      "Type" : 0
   },
   "SecondsSinceLastSeen" : {
      "Int64" : 0,
      "Valid" : true
   },
   "UsingOracleGTID" : false,
   "IsUpToDate" : true,
   "ReplicationCredentialsAvailable" : false,
   "ExecutedGtidSet" : "",
   "UsingPseudoGTID" : false,
   "SemiSyncReplicaEnabled" : false,
   "BinlogRowImage" : "",
   "SelfBinlogCoordinates" : {
      "Type" : 0,
      "LogPos" : 517006612,
      "LogFile" : "dbmaster-bin.041196"
   },
   "SlaveHosts" : [
      {
         "Port" : 3306,
         "Hostname" : "IP1"
      },
      {
         "Hostname" : "IP2",
         "Port" : 3306
      },
           ],
   "HasReplicationFilters" : false,
   "LogSlaveUpdatesEnabled" : false
}
shlomi-noach commented 6 years ago

OK. Since you have master and replicas on different ports you'll need to keep using "DiscoverByShowSlaveHosts": true,, otherwise orchestrator cannot guess the ports. Also continue to have @@report_host and @@report_port available on all servers.

Also use

I need to look into the information presented in []SlaveHosts.

unix196 commented 6 years ago

Thanks! All worked great! I use this config:

cat /etc/orchestrator.conf.json 
{
  "Debug": false,
  "EnableSyslog": false,
  "ListenAddress": "127.0.0.1:3001",
  "MySQLOrchestratorHost": "127.0.0.1",
  "MySQLOrchestratorPort": 3306,
  "MySQLOrchestratorDatabase": "orchestrator",
  "MySQLOrchestratorUser": "orch_use",
  "MySQLOrchestratorPassword": "pass1",
  "MySQLTopologyUser": "orch",
  "MySQLTopologyPassword": "passw2",
  "HostnameResolveMethod": "default",
  "MySQLHostnameResolveMethod": "@@report_host",
  "DiscoverByShowSlaveHosts": true
}

i.e. use combination "DiscoverByShowSlaveHosts": true and "HostnameResolveMethod": "default". In GUI I discover only master host, then all slave depict automatically