Mariadb

MariaDB Maxscale REST API 無法顯示結果

  • May 15, 2021

嗨,我已經在 maxscale 上設置了 maxadmin 可以從 rest api 訪問這是我的配置

   .....
[CLI_Service]
type=service
router=cli

[CLI_Listener]
type=listener
service=CLI_Service
protocol=maxscaled
address=192.168.101.107
socket=default

[MaxAdmin_Inet]
type=listener
service=CLI_Service
protocol=HTTPD
address=192.168.101.107
port=8010

但是當我像這樣測試網址時

curl --include --basic --user "admin:mariadb" http://192.168.101.107:8010/v1/servers

結果是這樣的

HTTP/1.1 200 OK
Date: Wed, 13 May 2020 11:33:15 GMT
Server: MaxScale(c) v.1.0.0
Connection: close
WWW-Authenticate: Basic realm="MaxInfo"
Content-Type: application/json

Commands must consist of at least two words. Type help for a list of commands

我是否想念配置?

當您需要啟用 rest api maxscale 時已經獲得預設配置

標籤必須是[maxscale],這是您需要為 maxscale 啟用 rest api 的一部分

[maxscale]
...
admin_host=192.168.101.107
admin_port=8989
admin_auth=1
admin_enabled=1

admin_host作為您的物理 IP 伺服器

然後在您重新啟動 maxscale 服務後,命令maxctrl list servers或其他任何東西都無法正常執行,他們需要像這樣的執行命令maxctrl -h 192.168.101.107:8989 list servers

然後你需要測試rest api

curl --include --basic --user "admin:mariadb" http://192.168.101.107:8010/v1/servers

這就是結果

HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 13156
Last-Modified: Wed, 13 May 2020 05:56:59 GMT
ETag: "0"
Date: Wed, 13 May 20 08:42:51 GMT
Content-Type: application/json

{
   "links": {
       "self": "http://192.168.101.107:8989/v1/servers/"
   },
   "data": [
       {
           "id": "server67",
           "type": "servers",
           "relationships": {
               "services": {
                   "links": {
                       "self": "http://192.168.101.107:8989/v1/services/"
                   },
                   "data": [
                       {
                           "id": "Read-Write-Service",
                           "type": "services"
                       }
                   ]
               },
               "monitors": {
                   "links": {
                       "self": "http://192.168.101.107:8989/v1/monitors/"
                   },
                   "data": [
                       {
                           "id": "MariaDB-Monitor",
                           "type": "monitors"
                       }
                   ]
               }
           },
           "attributes": {
               "parameters": {
                   "address": "192.168.101.67",
                   "socket": null,
                   "protocol": "MySQLBackend",
                   "port": 3306,
                   "extra_port": 0,
                   "authenticator": null,
                   "monitoruser": null,
                   "monitorpw": null,
                   "persistpoolmax": 0,
                   "persistmaxtime": 0,
                   "proxy_protocol": false,
                   "ssl": "false",
                   "ssl_cert": null,
                   "ssl_key": null,
                   "ssl_ca_cert": null,
                   "ssl_version": "MAX",
                   "ssl_cert_verify_depth": 9,
                   "ssl_verify_peer_certificate": false,
                   "disk_space_threshold": null,
                   "rank": "primary",
                   "serv_weight": "1"
               },
.......................

引用自:https://dba.stackexchange.com/questions/267059