簡體   English   中英

maxcrtl 無法連接到 maxscale

[英]maxcrtl cannot connect to maxscale

我有一個 k8s 集群,我想在其上部署 MariaDB 集群。 我有 master 和 slave pod,想用 maxscale 監控它們。 pod 使用其默認配置運行沒有任何問題,但是當我將卷掛載到一種類型的 configmap 並運行maxctrl list servers時,我收到以下錯誤:

Error: Could not connect to MaxScale

pod的日志:

最大對數

部署文件:

 --- apiVersion: apps/v1 kind: Deployment metadata: name: maxscale namespace: mariaDB-cluster spec: replicas: 2 selector: matchLabels: app: maxscale template: metadata: labels: app: maxscale spec: containers: - name: maxscale image: mariadb/maxscale:6.3.1 volumeMounts: - name: maxscale mountPath: /etc/maxscale.cnf.d/ ports: - name: mariadb containerPort: 3306 - name: restapi containerPort: 8989 volumes: - name: maxscale configMap: name: maxscale-test items: - key: "maxscale.cnf" path: "maxscale.cnf"

Configmap.yaml:

 apiVersion: v1 kind: ConfigMap metadata: name: maxscale-test namespace: mariadb-cluster labels: app: maxscale app.kubernetes.io/name: maxscale data: maxscale.cnf: | [maxscale] threads=auto admin_enabled=false # Server definitions # # Set the address of the server to the network # address of a MariaDB server. # [server1] type=server address=127.0.0.1 port=3306 protocol=MariaDBBackend # Monitor for the servers # # This will keep MaxScale aware of the state of the servers. # MariaDB Monitor documentation: # https://mariadb.com/kb/en/maxscale-6-monitors/ [MariaDB-Monitor] type=monitor module=mariadbmon servers=server1 user=myuser password=mypwd monitor_interval=2000 # Service definitions # # Service Definition for a read-only service and # a read/write splitting service. # # ReadConnRoute documentation: # https://mariadb.com/kb/en/mariadb-maxscale-6-readconnroute/ [Read-Only-Service] type=service router=readconnroute servers=server1 user=myuser password=mypwd router_options=slave # ReadWriteSplit documentation: # https://mariadb.com/kb/en/mariadb-maxscale-6-readwritesplit/ [Read-Write-Service] type=service router=readwritesplit servers=server1 user=myuser password=mypwd # Listener definitions for the services # # These listeners represent the ports the # services will listen on. # [Read-Only-Listener] type=listener service=Read-Only-Service protocol=MariaDBClient port=4008 [Read-Write-Listener] type=listener service=Read-Write-Service protocol=MariaDBClient port=4006

我使用的是maxscale默認配置,但是當我將它掛載到/etc/maxscale.cnf.d時它不起作用,所以我認為問題與讀取配置文件有關。

確保在運行maxscale進程的同一容器內運行命令:默認情況下,它僅偵聽端口 8989 上的本地連接。如果您希望 MaxScale 偵聽所有接口,而不僅僅是環回接口,請使用admin_host=0.0.0.0 .

如果你暴露了容器的 REST API 端口並想從外部連接到它,使用maxctrl -h address:port address是網絡地址( admin_host中的maxscale.cnf ), port是它監聽的網絡端口( admin_port中的maxctrl.cnf )。

例如,要連接到 mxshost 的mxshost容器:

maxctrl -h mxshost:8989 list servers

我找到了答案。 這是關於 maxscale 配置中的沖突。 我在 maxscale.cnf 中添加了一個新配置並將其掛載到 /etc/maxscale.cnf.d/。 但我認為這個配置被附加到/etc/maxscale.cnf,所以當我再次在/etc/maxscale.cnf.d/maxscale.cnf中有以下部分時,它會產生沖突:

[maxscale]
    threads=auto
    admin_enabled=false

所以我從我的 configmap 中刪除了這部分,它起作用了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM