orchestrator 中的 agent

发布时间 2023-06-23 17:18:36作者: 翔云123456

Orchestrator是一个开源的MySQL高可用性解决方案,它可以自动化执行MySQL故障转移、主从切换、数据中心迁移等操作,同时提供了一个Web界面和API接口,方便运维人员进行MySQL集群管理和监控。

在Orchestrator 常用功能中,很少提及agent,实际上,Orchestrator 也有agent相关功能,并有一个独立的项目orchestrator-agent

Orchestrator 中的 agent 主要有以下功能:

  • 与 Orchestrator 服务端建立连接,接收来自服务端的指令并执行;
  • 支持通过 HTTP API 与 Orchestrator 服务端交互,如获取实例信息, 以及启动、停止 MySQL 实例等等操作;

在Orchestrator 中,通过配置项config.Config.ServeAgentsHttp 配置agent 相关功能是否开启,主要是http server。这个http server 默认监听端口3001,通过HTTP API agent 可以主动上报信息到 Orchestrator 服务端,例如,MySQL机器hostname等。

接下来,本文主要介绍 orchestrator-agent。

orchestrator-agent

orchestrator-agent是 Orchestrator 的子项目。

orchestrator-agent是一个运行在MySQL服务器上的进程,它可以通过与Orchestrator服务端的通信,将MySQL服务器的状态信息上报给Orchestrator服务端,从而实现MySQL集群的自动化管理和监控。同时,agent还可以执行一些MySQL操作,如启动、停止等操作,以及执行一些自定义的脚本。

Orchestrator和agent之间通过HTTP协议进行交互。当agent启动时,它会向Orchestrator服务器注册自己,并定期向Orchestrator发送MySQL实例的状态信息。在执行这些操作时,Orchestrator会向agent发送命令,agent会根据命令执行相应的操作,并将执行结果返回给Orchestrator。

orchestrator-agent端的http server ,默认监听3002端口。
主要http接口包括:

    m.Get("/api/hostname", this.Hostname)
    m.Get("/api/lvs", this.ListLogicalVolumes)
    m.Get("/api/lvs/:pattern", this.ListLogicalVolumes)
    m.Get("/api/lvs-snapshots", this.ListSnapshotsLogicalVolumes)
    m.Get("/api/lv", this.LogicalVolume)
    m.Get("/api/lv/:lv", this.LogicalVolume)
    m.Get("/api/mount", this.GetMount)
    m.Get("/api/mountlv", this.MountLV)
    m.Get("/api/removelv", this.RemoveLV)
    m.Get("/api/umount", this.Unmount)
    m.Get("/api/du", this.DiskUsage)
    m.Get("/api/mysql-du", this.MySQLDiskUsage)
    m.Get("/api/create-snapshot", this.CreateSnapshot)
    m.Get("/api/available-snapshots-local", this.AvailableLocalSnapshots)
    m.Get("/api/available-snapshots", this.AvailableSnapshots)
    m.Get("/api/mysql-error-log-tail", this.MySQLErrorLogTail)
    m.Get("/api/mysql-port", this.MySQLPort)
    m.Get("/api/mysql-status", this.MySQLRunning)
    m.Get("/api/mysql-stop", this.MySQLStop)
    m.Get("/api/mysql-start", this.MySQLStart)
    m.Get("/api/delete-mysql-datadir", this.DeleteMySQLDataDir)
    m.Get("/api/mysql-datadir-available-space", this.GetMySQLDataDirAvailableDiskSpace)
    m.Get("/api/post-copy", this.PostCopy)
    m.Get("/api/receive-mysql-seed-data/:seedId", this.ReceiveMySQLSeedData)
    m.Get("/api/send-mysql-seed-data/:targetHost/:seedId", this.SendMySQLSeedData)
    m.Get("/api/abort-seed/:seedId", this.AbortSeed)
    m.Get("/api/seed-command-completed/:seedId", this.SeedCommandCompleted)
    m.Get("/api/seed-command-succeeded/:seedId", this.SeedCommandSucceeded)
    m.Get("/api/mysql-relay-log-index-file", this.RelayLogIndexFile)
    m.Get("/api/mysql-relay-log-files", this.RelayLogFiles)
    m.Get("/api/mysql-relay-log-end-coordinates", this.RelayLogEndCoordinates)
    m.Get("/api/mysql-binlog-contents", this.BinlogContents)
    m.Get("/api/mysql-binlog-binary-contents", this.BinlogBinaryContents)
    m.Get("/api/mysql-relaylog-contents-tail/:relaylog/:start", this.RelaylogContentsTail)
    m.Post("/api/apply-relaylog-contents", this.ApplyRelaylogContents)
    m.Get("/api/custom-commands/:cmd", this.RunCommand)
    m.Get(config.Config.StatusEndpoint, this.Status)

从上面的http接口中可以看到,orchestrator-agent功能主要有
获取MySQL机器hostname,lvs相关操作,mount操作,mysql 启动、停止等操作,binlog、relay log 相关操作, 以及其他自定义的操作。

以上,本文介绍了 Orchestrator 中的agent的基本功能。

参考

orchestrator

orchestrator-agent