Skip to content

Commit

Permalink
feat: support mysql mgr with proxysql (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuriwuyun authored Feb 14, 2025
1 parent 6a24979 commit 1e222a8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions addons-cluster/mysql/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"semisync",
"semisync-proxysql",
"mgr",
"mgr-proxysql",
"orc",
"orc-proxysql"
]
Expand Down
2 changes: 1 addition & 1 deletion addons/mysql/config/proxysql.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ admin_variables=
cluster_mysql_users_diffs_before_sync="3"
cluster_proxysql_servers_diffs_before_sync="3"
admin_credentials="admin:${PROXYSQL_ADMIN_PASSWORD};cluster:${PROXYSQL_CLUSTER_PASSWORD}"
admin-hash_passwords="true"
hash_passwords="false"
cluster_check_interval_ms="200"
cluster_mysql_servers_save_to_disk="true"
cluster_mysql_users_save_to_disk="true"
Expand Down
4 changes: 0 additions & 4 deletions addons/mysql/scripts/configure-proxysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ mysql_version=$(mysql_exec $MYSQL_ROOT_USER $MYSQL_ROOT_PASSWORD $BACKEND_SERVER
log "connecting to mysql $MYSQL_ROOT_USER $MYSQL_ROOT_PASSWORD $BACKEND_SERVER $MYSQL_PORT"
mysql_exec $MYSQL_ROOT_USER $MYSQL_ROOT_PASSWORD $BACKEND_SERVER $MYSQL_PORT "$additional_sys_query" $opt

mysql_exec $MYSQL_ROOT_USER $MYSQL_ROOT_PASSWORD $BACKEND_SERVER $MYSQL_PORT << EOF
CREATE USER 'monitor'@'%' IDENTIFIED BY 'monitor';
GRANT USAGE, REPLICATION CLIENT ON *.* TO 'monitor'@'%';
EOF
# wait for proxysql process to run
wait_for_mysql admin ${PROXYSQL_ADMIN_PASSWORD} 127.0.0.1 6032

Expand Down
10 changes: 8 additions & 2 deletions addons/mysql/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ systemAccounts:
passwordGenerationPolicy: *defaultPasswordGenerationPolicy
- name: proxysql
statement:
create: CREATE USER IF NOT EXISTS '${KB_ACCOUNT_NAME}' IDENTIFIED BY '${KB_ACCOUNT_PASSWORD}'; GRANT SELECT ON performance_schema.* TO '${KB_ACCOUNT_NAME}'; GRANT SELECT ON sys.* TO '${KB_ACCOUNT_NAME}';
create: CREATE USER ${KB_ACCOUNT_NAME} IDENTIFIED BY '${KB_ACCOUNT_PASSWORD}'; GRANT REPLICATION CLIENT, USAGE ON ${ALL_DB} TO ${KB_ACCOUNT_NAME};
passwordGenerationPolicy: *defaultPasswordGenerationPolicy
vars:
- name: CLUSTER_NAME
valueFrom:
Expand Down Expand Up @@ -317,7 +318,12 @@ systemAccounts:
letterCase: MixedCases
- name: proxysql
statement:
create: CREATE USER IF NOT EXISTS '${KB_ACCOUNT_NAME}' IDENTIFIED BY '${KB_ACCOUNT_PASSWORD}'; GRANT SELECT ON performance_schema.* TO '${KB_ACCOUNT_NAME}'; GRANT SELECT ON sys.* TO '${KB_ACCOUNT_NAME}';
create: CREATE USER ${KB_ACCOUNT_NAME} IDENTIFIED BY '${KB_ACCOUNT_PASSWORD}'; GRANT USAGE, REPLICATION CLIENT ON *.* TO ${KB_ACCOUNT_NAME};
passwordGenerationPolicy:
length: 16
numDigits: 8
numSymbols: 0
letterCase: MixedCases
tls:
volumeName: tls
mountPath: /etc/pki/tls
Expand Down
16 changes: 16 additions & 0 deletions addons/mysql/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ spec:
update: # When there are multiple component update operations, follow the order specified here.
- mysql
- proxysql
- name: mgr-proxysql
components:
- name: mysql
compDef: {{ include "mysql.cmpdMGRNamePrefix" . }}
- name: proxysql
compDef: {{ include "proxysql.componentDefName" . }}
orders:
provision: # The server will start before the proxy is created.
- mysql
- proxysql
terminate: # The proxy will be shut down (destroyed) before the server.
- proxysql
- mysql
update: # When there are multiple component update operations, follow the order specified here.
- mysql
- proxysql
- name: semisync-proxysql
components:
- name: mysql
Expand Down

0 comments on commit 1e222a8

Please sign in to comment.