1.QingCloud RadonDB 是基于 MySQL 研发的新一代分布式关系型数据库,可无限水平扩展,支持分布式事务,具备金融级数据强一致性,满足企业级核心数据库对大容量、高并发、高可靠及高可用的极致要求。
2.RadonDB MySQL 是一款基于 MySQL 的开源、高可用的云原生集群解决方案。
RadonDB MySQL采用一主多从高可用架构,并具备安全、自动备份、监控告警、自动扩容等全套管理功能。目前已经在生产环境中大规模的使用,用户包含银行、保险、传统大企业等。
数据强一致性保证,满足金融级可靠性要求。
包含全套备份、恢复和监控等运维方案,满足网站类的业务需求。
1.无中心化自动选主
2.主从秒级切换
3.集群切换的数据强一致性
[root@k8s-master ~]# kubectl get nodes -owide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-master Ready control-plane,master 97d v1.23.1 192.168.3.201 <none> CentOS Linux 7 (Core) 3.10.0-957.el7.x86_64 containerd://1.6.6
k8s-node01 Ready <none> 97d v1.23.1 192.168.3.202 <none> CentOS Linux 7 (Core) 3.10.0-957.el7.x86_64 containerd://1.6.6
k8s-node02 Ready <none> 97d v1.23.1 192.168.3.203 <none> CentOS Linux 7 (Core) 3.10.0-957.el7.x86_64 containerd://1.6.6
[root@k8s-master ~]# helm version
version.BuildInfo{Version:"v3.9.0", GitCommit:"7ceeda6c585217a19a1131663d8cd1f7d641b2a7", GitTreeState:"clean", GoVersion:"go1.17.5"}
[root@k8s-master ~]# helm repo add radondb https://radondb.github.io/radondb-mysql-kubernetes/
"radondb" has been added to your repositories
[root@k8s-master ~]# helm repo list
NAME URL
bitnami https://charts.bitnami.com/bitnami
radondb https://radondb.github.io/radondb-mysql-kubernetes/
[root@k8s-master ~]# helm search repo radondb/mysql-operator
NAME CHART VERSION APP VERSION DESCRIPTION
radondb/mysql-operator 2.2.1 v2.2.1 Open Source,High Availability Cluster,based o...
[root@k8s-master radondb]# helm pull radondb/mysql-operator
[root@k8s-master radondb]# ls
mysql-operator-2.2.1.tgz
[root@k8s-master radondb]# helm install demo radondb/mysql-operator
NAME: demo
LAST DEPLOYED: Sat Oct 8 16:48:37 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
You can create a new mysqlcluster by issuing:
cat <<EOF | kubectl apply -f-
apiVersion: mysql.radondb.com/v1alpha1
kind: MysqlCluster
metadata:
name: sample
spec:
replicas: 3
EOF
[root@k8s-master radondb]# kubectl get pods
NAME READY STATUS RESTARTS AGE
app-agent-spmrv 2/2 Running 27 (38m ago) 10d
app-agent-zdjst 2/2 Running 42 (39m ago) 10d
demo-mysql-operator-969575-d8n9z 1/2 Running 0 105s
mysql001-8db95c95-g2nps 1/1 Running 3 (38m ago) 3d15h
nfs-client-provisioner-779b7f4dfd-448qg 1/1 Running 4 (30h ago) 3d15h
quick-start-5ctw-dn-0-single-0 2/3 Running 9 (39m ago) 3d5h
quick-start-5ctw-gms-single-0 2/3 Running 9 (38m ago) 3d5h
webserver01 1/1 Running 2 (39m ago) 2d
apiVersion: mysql.radondb.com/v1alpha1
kind: MysqlCluster
metadata:
name: sample
spec:
replicas: 3
mysqlVersion: "5.7"
# the backupSecretName specify the secret file name which store S3 information,
# if you want S3 backup or restore, please create backup_secret.yaml, uncomment below and fill secret name:
# backupSecretName:
# if you want create mysqlcluster from S3, uncomment and fill the directory in S3 bucket below:
# such as restoreFrom: "backup_202241423817"
# restoreFrom:
# Restore from NFS, uncomment below and set the ip of NFS server
# such as nfsServerAddress: "10.233.55.172"
# nfsServerAddress:
mysqlOpts:
user: radondb_usr
password: RadonDB@123
database: radondb
initTokuDB: false
# A simple map between string and string.
# Such as:
# mysqlConf:
# expire_logs_days: "7"
mysqlConf: {}
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 500m
memory: 1Gi
xenonOpts:
image: radondb/xenon:v2.2.1
admitDefeatHearbeatCount: 5
electionTimeout: 10000
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
cpu: 100m
memory: 256Mi
metricsOpts:
enabled: false
image: prom/mysqld-exporter:v0.12.1
resources:
requests:
cpu: 10m
memory: 32Mi
limits:
cpu: 100m
memory: 128Mi
podPolicy:
imagePullPolicy: IfNotPresent
sidecarImage: radondb/mysql57-sidecar:v2.2.1
busyboxImage: busybox:1.32
slowLogTail: false
auditLogTail: false
labels: {}
annotations: {}
affinity: {}
priorityClassName: ""
tolerations: []
schedulerName: ""
# extraResources defines quotas for containers other than mysql or xenon.
extraResources:
requests:
cpu: 10m
memory: 32Mi
persistence:
enabled: true
accessModes:
- ReadWriteOnce
#storageClass: ""
size: 20Gi
[root@k8s-master radondb]# kubectl apply -f mysql_v1alpha1_mysqlcluster.yaml
mysqlcluster.mysql.radondb.com/sample created
[root@k8s-master radondb]# kubectl get pods
NAME READY STATUS RESTARTS AGE
demo-mysql-operator-969575-d8n9z 2/2 Running 0 28m
mysql001-8db95c95-g2nps 1/1 Running 3 (65m ago) 3d15h
nfs-client-provisioner-779b7f4dfd-448qg 1/1 Running 4 (30h ago) 3d15h
sample-mysql-0 3/3 Running 0 22m
sample-mysql-1 3/3 Running 0 16m
sample-mysql-2 3/3 Running 0 11m
sample-mysql 的三节点 RadonDB MySQL 集群及用于访问节点的服务。
[root@k8s-master radondb]# kubectl get statefulset,svc
NAME READY AGE
statefulset.apps/sample-mysql 3/3 24m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 97d
service/mysql-operator-metrics ClusterIP 10.111.23.64 <none> 8443/TCP 30m
service/radondb-mysql-webhook ClusterIP 10.109.92.96 <none> 443/TCP 30m
service/sample-follower ClusterIP 10.103.39.101 <none> 3306/TCP,8082/TCP 24m
service/sample-leader ClusterIP 10.100.160.84 <none> 3306/TCP,8082/TCP 24m
service/sample-mysql ClusterIP None <none> 3306/TCP,8082/TCP 24m
[root@k8s-master radondb]# kubectl get crd | grep mysql.radondb.com
backups.mysql.radondb.com 2022-10-08T08:48:36Z
mysqlclusters.mysql.radondb.com 2022-10-08T08:48:36Z
mysqlusers.mysql.radondb.com 2022-10-08T08:48:36Z
[root@k8s-master radondb]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 97d
mysql-operator-metrics ClusterIP 10.111.23.64 <none> 8443/TCP 35m
radondb-mysql-webhook ClusterIP 10.109.92.96 <none> 443/TCP 35m
sample-follower ClusterIP 10.103.39.101 <none> 3306/TCP,8082/TCP 29m
sample-leader ClusterIP 10.100.160.84 <none> 3306/TCP,8082/TCP 29m
sample-mysql ClusterIP None <none> 3306/TCP,8082/TCP 29m
[root@k8s-node01 ~]# mysql -h 10.100.160.84 -P 3306 -u radondb_usr -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 480
Server version: 5.7.34-37-log Percona Server (GPL), Release 37, Revision 7c516e9
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| radondb |
+--------------------+
2 rows in set (1.10 sec)
MySQL [(none)]>
[root@k8s-node01 ~]# mysql -h 10.103.39.101 -P 3306 -u radondb_usr -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 750
Server version: 5.7.34-37-log Percona Server (GPL), Release 37, Revision 7c516e9
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| radondb |
+--------------------+
2 rows in set (0.93 sec)
MySQL [(none)]>
[root@k8s-master radondb]# cat Secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: sample-user-password
data:
pwdForSample: UmFkb25EQkAxMjM=
# pwdForSample2:
# # pwdForSample3:
[root@k8s-master radondb]# cat MysqlUser.yaml
apiVersion: mysql.radondb.com/v1alpha1
kind: MysqlUser
metadata:
name: sample-user-cr # 用户 CR 名称,建议使用一个用户 CR 管理一个用户。
spec:
user: admin
hosts:
- "%"
permissions:
- database: "*"
tables:
- "*"
privileges:
- "ALL"
userOwner:
clusterName: sample
nameSpace: default
secretSelector:
secretName: sample-user-password 。
secretKey: pwdForSample
[root@k8s-master radondb]# kubectl apply -f Secret.yaml ^C
[root@k8s-master radondb]# kubectl apply -f MysqlUser.yaml
[root@k8s-master radondb]# kubectl get MysqlUser
NAME USERNAME SUPERUSER HOSTS TLSTYPE CLUSTER NAMESPACE AVAILABLE
sample-user-cr admin false ["%"] NONE sample default True
[root@k8s-master radondb]# kubectl get secrets sample-secret
NAME TYPE DATA AGE
sample-secret Opaque 13 75m
[root@k8s-node01 ~]# mysql -h 10.100.160.84 -P 3306 -uadmin -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 1210
Server version: 5.7.34-37-log Percona Server (GPL), Release 37, Revision 7c516e9
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show master status;
+------------------+----------+--------------+------------------+-------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------------------------------+
| mysql-bin.000002 | 23296 | | | 0e62556e-46e8-11ed-85ff-b66837dd89be:1-94 |
+------------------+----------+--------------+------------------+-------------------------------------------+
1 row in set (0.00 sec)
MySQL [(none)]> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000002
Position: 23296
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: 0e62556e-46e8-11ed-85ff-b66837dd89be:1-94
1 row in set (0.00 sec)
MySQL [(none)]>
MySQL [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: sample-mysql-1.sample-mysql.default
Master_User: radondb_repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 25384
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 25597
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 25384
Relay_Log_Space: 25804
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 101
Master_UUID: 0e62556e-46e8-11ed-85ff-b66837dd89be
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 0e62556e-46e8-11ed-85ff-b66837dd89be:1-103
Executed_Gtid_Set: 0e62556e-46e8-11ed-85ff-b66837dd89be:1-103
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
MySQL [(none)]>
helm delete demo
kubectl delete mysqlclusters.mysql.radondb.com sample
kubectl delete customresourcedefinitions.apiextensions.k8s.io mysqlclusters.mysql.radondb.com
kubectl delete customresourcedefinitions.apiextensions.k8s.io mysqlusers.mysql.radondb.com
kubectl delete customresourcedefinitions.apiextensions.k8s.io backups.mysql.radondb.com