申请试用
HOT
登录
注册
 
Deploying PXC in Kubernetes/Openshift
无羡
/
发布于
/
1905
人观看

在本次网络研讨会中,Alex将讨论如何在kubernetes/openshift上使用percona xtradb cluster(pxc)和mysql proxy部署高可用的mysql数据库环境来实现读/写拆分。
如果您从未使用过kubernetes和openshift,或者从未使用过pxc/mysql代理,那么alex将快速介绍这些技术。还有一个演示,亚历克斯在openshift-origin中用proxysql建立了一个pxc集群,并试图破坏它。
本次网络研讨会结束后,您将更好地了解:
如何使用proxysql for ha解决方案部署percona xtradb集群
如何在您的环境中利用kubernetes/openshift
如何解决性能问题

展开查看详情

1 .Deploying PXC in Kubernetes / Openshift Alexander Rubin, Percona

2 .About me ● Working with MySQL for 10-15 years ○ Started at MySQL AB, Sun Microsystems, Oracle (MySQL Consulting) ○ Joined Percona in 2013

3 . What is Kubernetes? Kubernetes is an open source system for managing containerized applications across multiple hosts

4 .What is Percona XtraDB Cluster (PXC)?

5 .Why PXC? Auto provisioning...

6 .PXC: Data transfer

7 .What is ProxySQL?

8 .ProxySQL read/write split Query routing is one of the core features of ProxySQL. Read/write split is perhaps one of the most common query routing use

9 .ProxySQL read-write split

10 .PXC + ProxySQL on Kubernetes / Openshift

11 .OpenShift Percona Labs https://github.com/Percona-Lab/percona-openshift $ git clone git@github.com:Percona-Lab/percona-openshift.git

12 .Demo / Howto $ ./deploy_all.sh ● secret "mysql-passwords" created ● configmap "mysql" created ● service "pxccluster1" created ● statefulset "pxcnode" created ● statefulset "proxysql" created ● service "sql" created

13 .● secret "mysql-passwords" created $ cat secret.yaml apiVersion: v1 kind: Secret metadata: name: mysql-passwords type: Opaque data: root: cm9vdF9wYXNzd29yZA== xtrabackup: YmFja3VwX3Bhc3N3b3Jk

14 .● secret "mysql-passwords" created Use base64 to encode a password for secret.yaml : ● echo -n 'securepassword' | base64 Used base64 -d to decode a password from secret.yaml : ● echo YmFja3VwX3Bhc3N3b3Jk | base64 -d

15 .● configmap "mysql" created a way to pass custom config to MySQL (each PXC node) $ cat mysql-configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: mysql labels: app: mysql data: extra.cnf: | [mysqld] innodb-buffer-pool-size=512M

16 .Demo / Howto $ oc get all NAME DESIRED CURRENT AGE statefulsets/proxysql 1 1 2m statefulsets/pxcnode 3 3 2m NAME READY STATUS RESTARTS AGE po/proxysql-0 1/1 Running 0 2m po/pxcnode-0 1/1 Running 0 2m po/pxcnode-1 1/1 Running 0 1m po/pxcnode-2 1/1 Running 0 1m ...

17 .Demo / Howto $ oc get all ... NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE svc/pxccluster1 ClusterIP None <none> 3306/TCP 6m svc/sql ClusterIP 172.30.96.210 <none> 3306/TCP,6032/TCP 6m

18 .Demo / Howto $ oc get all ... NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE svc/pxccluster1 ClusterIP None <none> 3306/TCP 6m svc/sql ClusterIP 172.30.96.210 <none> 3306/TCP,6032/TCP 6m

19 .Demo / Howto - pods $ oc get pods NAME READY STATUS RESTARTS proxysql-0 1/1 Running 0 pxcnode-0 1/1 Running 0 pxcnode-1 1/1 Running 0 pxcnode-2 1/1 Running 0

20 . Demo / Howto $ oc get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) pxccluster1 ClusterIP None <none> 3306/TCP sql ClusterIP 172.30.96.210 <none> 3306/TCP,6032/TCP MySQL Port (for app) Proxy Admin Port

21 .Demo / Howto $ mysql -h 172.30.96.210 -e 'select @@hostname' +------------+ | @@hostname | +------------+ | pxcnode-1 | +------------+ mysql -h 172.30.96.210 -e 'select @@hostname' +------------+ | @@hostname | +------------+ | pxcnode-2 | +------------+

22 .Demo / Howto $ mysql -h 172.30.96.210 -e 'select @@hostname for update' +------------+ | @@hostname | +------------+ | pxcnode-0 | +------------+ mysql -h 172.30.96.210 -e 'select @@hostname for update' +------------+ | @@hostname | +------------+ | pxcnode-0 | +------------+

23 .Demo / Howto - test $ for i in {1..600}; do mysql -h `oc get svc/sql -o=yaml|grep clusterIP|cut -d':' -f 2` -s -Nbe 'select concat("reader: ", @@hostname); select concat("-- writer: ", @@hostname) for update'; sleep 1; done reader: pxcnode-1 -- writer: pxcnode-0 reader: pxcnode-2 -- writer: pxcnode-0 reader: pxcnode-1 -- writer: pxcnode-0 reader: pxcnode-1 -- writer: pxcnode-0

24 .Demo / Howto - test $ docker ps ... 79e2918d072c perconalab/pxc-openshift mysql_pxcnode-0 ... $ docker kill 79e2918d072c

25 .Demo / Howto - test ... reader: pxcnode-1 -- writer: pxcnode-0 reader: pxcnode-2 -- writer: pxcnode-0 reader: pxcnode-1 -- writer: pxcnode-0 reader: pxcnode-1 -- writer: pxcnode-0

26 .Failover - demo

27 .Backup ● Openshift/Kubernetes is a different mindset ○ No cronjob inside container ○ Provides its own cronjob $ cat xtrabackup-job.yaml apiVersion: batch/v1 kind: Job metadata: name: xtrabackup-job spec:

28 .Monitoring Percona Monitoring and Management platform intergration https://pmmdemo.percona.com/

29 .Next Steps - helm $ helm install --name cluster1 . -f values.yaml By default will deploy proxysql in from of nodes and pmm-client on each node Install Helm in OpenShift For the details see https://blog.openshift.com/getting-started-helm-openshift/

0 点赞
0 收藏
0下载
相关文档