我有一个k8s集群,我想在这个集群上部署MariaDB集群。我有主舱和奴隶舱,想用最大比例监视它们。pod以其默认配置运行,没有任何问题,但是当我在configmap类型中挂载卷并运行maxctrl list servers
时,会得到以下错误:
Error: Could not connect to MaxScale
吊舱的原木:
部署文件:
---
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时,它不起作用,所以我认为问题与读取配置文件有关。
发布于 2022-08-29 07:51:03
确保在运行maxscale
进程的同一个容器中运行命令:默认情况下,它只侦听端口8989上的本地连接。如果希望MaxScale侦听所有接口,而不仅仅是循环接口,请使用admin_host=0.0.0.0
。
如果您公开容器的REST端口并希望从外部连接到它,请使用maxctrl -h address:port
。address
是网络地址(admin_host
in maxscale.cnf
),port
是它侦听的网络端口(admin_port
in maxctrl.cnf
)。
例如,在MaxScale上连接到mxshost
容器
maxctrl -h mxshost:8989 list servers
发布于 2022-09-03 11:22:43
我找到了答案。它是关于maxscale配置中的冲突。我在maxscale.cnf中添加了一个新的配置,并将其挂载到/etc/maxscale.cnf.d/。但是,我认为这个配置被追加到/etc/maxscale.cnf,所以当我在/etc/maxScale.cnf中再次包含以下部分时,它会产生冲突:
[maxscale]
threads=auto
admin_enabled=false
所以我从我的configmap中删除了这个部分,它起了作用。
https://stackoverflow.com/questions/73373555
复制相似问题