• 安装指南
  • 先下载到本地
git clone https://github.com/kubernetes/charts.git
  • 安装helm

参考:

http://www.cnblogs.com/ericnie/p/8463127.html

  • 下载mysql-operator镜像
docker pull  iad.ocir.io/oracle/mysql-operator:0.1.

同时下载mysqlserver和agent,启动mysql实例需要

docker pull mysql/mysql-server:5.7.-1.1.

docker pull wcr.io/oracle/mysql-agent:0.1.
  • 建立命名空间
kubectl create namespace mysql-operator
  • 创建mysql-operator

[root@k8s-master mysql-operator]# helm install --name my-release mysql-operator --set rbac.enabled=true
NAME: my-release
LAST DEPLOYED: Tue May 22 14:53:39 2018
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/ServiceAccount
NAME SECRETS AGE
mysql-operator 1 14m
mysql-agent 1 14m

==> v1beta1/ClusterRole
NAME AGE
mysql-operator 14m

==> v1beta1/ClusterRoleBinding
NAME AGE
mysql-operator 14m
mysql-agent 14m

==> v1beta1/Deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
mysql-operator 1 1 1 1 14m

==> v1beta1/CustomResourceDefinition
NAME KIND
mysqlclusters.mysql.oracle.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io
mysqlbackups.mysql.oracle.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io
mysqlrestores.mysql.oracle.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io
mysqlbackupschedules.mysql.oracle.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io

NOTES:
Thanks for installing the MySQL Operator.

Check if the operator is running with

kubectl -n mysql-operator get po

验证下结果

[root@k8s-master mysql-operator]# kubectl get pods -n mysql-operator
NAME READY STATUS RESTARTS AGE
mysql-operator--7937r / Running 52s

获取crd

[root@k8s-master cluster]# kubectl get crd
NAME KIND
domains.weblogic.oracle CustomResourceDefinition.v1beta1.apiextensions.k8s.io
mysqlbackups.mysql.oracle.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io
mysqlbackupschedules.mysql.oracle.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io
mysqlclusters.mysql.oracle.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io
mysqlrestores.mysql.oracle.com CustomResourceDefinition.v1beta1.apiextensions.k8s.io
  • 集群建立

各种集群建立,详细可以参考

https://github.com/oracle/mysql-operator/blob/master/docs/user/clusters.md

这里列一个最简单的。

[root@k8s-master cluster]# cat cluster.yaml
apiVersion: "mysql.oracle.com/v1"
kind: MySQLCluster
metadata:
name: mysql
[root@k8s-master cluster]# kubectl create -f cluster.yaml
mysqlcluster "mysql" created
[root@k8s-master cluster]# kubectl get mysqlclusters
NAME KIND
mysql MySQLCluster.v1.mysql.oracle.com

发现在当前的命名空间下生成了实例

[root@k8s-master cluster]# kubectl get pods
NAME READY STATUS RESTARTS AGE
busybox / Running 8d
mysql- / Running 14m
tomcat / Running 7d
[root@k8s-master cluster]# kubectl logs mysql-  -c mysql-agent
Starting mysql-agent version 0.1.
ERROR: logging before flag.Parse: I0523 ::46.287788 flags.go:] FLAG: --address="0.0.0.0"
ERROR: logging before flag.Parse: I0523 ::46.287883 flags.go:] FLAG: --alsologtostderr="false"
ERROR: logging before flag.Parse: I0523 ::46.287893 flags.go:] FLAG: --healthcheck-port=""
ERROR: logging before flag.Parse: I0523 ::46.287903 flags.go:] FLAG: --hostname="mysql-0"
ERROR: logging before flag.Parse: I0523 ::46.287910 flags.go:] FLAG: --log-backtrace-at=":0"
ERROR: logging before flag.Parse: I0523 ::46.287920 flags.go:] FLAG: --log-dir=""
ERROR: logging before flag.Parse: I0523 ::46.287927 flags.go:] FLAG: --log-flush-frequency="5s"
ERROR: logging before flag.Parse: I0523 ::46.287936 flags.go:] FLAG: --logtostderr="true"
ERROR: logging before flag.Parse: I0523 ::46.287943 flags.go:] FLAG: --min-resync-period="12h0m0s"
ERROR: logging before flag.Parse: I0523 ::46.287950 flags.go:] FLAG: --mysql-cluster-name="mysql"
ERROR: logging before flag.Parse: I0523 ::46.287956 flags.go:] FLAG: --namespace="default"
ERROR: logging before flag.Parse: I0523 ::46.287962 flags.go:] FLAG: --stderrthreshold=""
ERROR: logging before flag.Parse: I0523 ::46.287969 flags.go:] FLAG: --v=""
ERROR: logging before flag.Parse: I0523 ::46.287976 flags.go:] FLAG: --vmodule=""
ERROR: logging before flag.Parse: I0523 ::46.817877 cluster_manager.go:] Database not yet running. Waiting...
ERROR: logging before flag.Parse: I0523 ::56.941725 cluster_manager.go:] Database not yet running. Waiting...
ERROR: logging before flag.Parse: I0523 ::06.993075 cluster_manager.go:] Database not yet running. Waiting...
ERROR: logging before flag.Parse: I0523 ::17.415974 innodb_cluster.go:] Clearing the MySQL binary logs
ERROR: logging before flag.Parse: I0523 ::18.086997 cluster_manager.go:] Creating the cluster on the primary instance
ERROR: logging before flag.Parse: I0523 ::23.170507 cluster_manager.go:] {
"clusterName": "MySQLCluster",
"defaultReplicaSet": {
"name": "default",
"primary": "mysql-0:3306",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"mysql-0:3306": {
"address": "mysql-0:3306",
"mode": "R/W",
"role": "HA",
"status": "ONLINE"
}
}
}
}
ERROR: logging before flag.Parse: I0523 ::23.170595 cluster_manager.go:] MySQL instance is online
ERROR: logging before flag.Parse: I0523 ::23.345615 agent_controller.go:] Creating event broadcaster
ERROR: logging before flag.Parse: I0523 ::23.532123 reflector.go:] Starting reflector *v1.Pod (19h15m21.324440719s) from github.com/oracle/mysql-operator/vendor/k8s.io/client-go/informers/factory.go:
ERROR: logging before flag.Parse: I0523 ::23.532225 reflector.go:] Listing and watching *v1.Pod from github.com/oracle/mysql-operator/vendor/k8s.io/client-go/informers/factory.go:
ERROR: logging before flag.Parse: I0523 ::23.553086 agent_controller.go:] Creating event broadcaster
ERROR: logging before flag.Parse: I0523 ::23.553397 cluster_labeler.go:] Starting the ClusterLabelerController
ERROR: logging before flag.Parse: I0523 ::23.553412 cluster_labeler.go:] Waiting for ClusterLabelerController informer caches to sync
ERROR: logging before flag.Parse: I0523 ::23.553426 cache.go:] Waiting for caches to sync for innodb-cluster-labeler controller
ERROR: logging before flag.Parse: I0523 ::23.555114 agent_controller.go:] Starting AgentController
ERROR: logging before flag.Parse: I0523 ::23.555151 agent_controller.go:] Waiting for caches to sync
ERROR: logging before flag.Parse: I0523 ::23.555171 cache.go:] Waiting for caches to sync for operator-backup-controller controller
ERROR: logging before flag.Parse: I0523 ::23.555407 agent_controller.go:] Starting AgentController
ERROR: logging before flag.Parse: I0523 ::23.555419 agent_controller.go:] Waiting for caches to sync
ERROR: logging before flag.Parse: I0523 ::23.555427 cache.go:] Waiting for caches to sync for operator-restore-controller controller
ERROR: logging before flag.Parse: I0523 ::23.556287 reflector.go:] Starting reflector *v1.MySQLBackup (0s) from github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/factory.go:
ERROR: logging before flag.Parse: I0523 ::23.556320 reflector.go:] Listing and watching *v1.MySQLBackup from github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/factory.go:
ERROR: logging before flag.Parse: I0523 ::23.557559 reflector.go:] Starting reflector *v1.MySQLRestore (0s) from github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/factory.go:
ERROR: logging before flag.Parse: I0523 ::23.562579 reflector.go:] Listing and watching *v1.MySQLRestore from github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/factory.go:
ERROR: logging before flag.Parse: I0523 ::23.564784 reflector.go:] Starting reflector *v1.MySQLCluster (0s) from github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/factory.go:
ERROR: logging before flag.Parse: I0523 ::23.564827 reflector.go:] Listing and watching *v1.MySQLCluster from github.com/oracle/mysql-operator/pkg/generated/informers/externalversions/factory.go:
ERROR: logging before flag.Parse: I0523 ::24.135073 cluster_manager.go:] MySQL instance is online
ERROR: logging before flag.Parse: I0523 ::24.153865 shared_informer.go:] caches populated
ERROR: logging before flag.Parse: I0523 ::24.153925 cache.go:] Caches are synced for innodb-cluster-labeler controller
ERROR: logging before flag.Parse: I0523 ::24.153946 cluster_labeler.go:] Starting ClusterLabelerController controller worker
ERROR: logging before flag.Parse: I0523 ::24.153965 cluster_labeler.go:] Started ClusterLabelerController controller worker
ERROR: logging before flag.Parse: I0523 ::24.154389 cluster_labeler.go:] Labeling default/mysql- as primary
ERROR: logging before flag.Parse: I0523 ::24.173303 shared_informer.go:] caches populated
ERROR: logging before flag.Parse: I0523 ::24.173358 cache.go:] Caches are synced for operator-restore-controller controller
ERROR: logging before flag.Parse: I0523 ::24.173386 agent_controller.go:] Caches are synced
ERROR: logging before flag.Parse: I0523 ::24.174961 patch.go:] Patching Pod mysql-/default: {"metadata":{"labels":{"v1.mysql.oracle.com/role":"primary"}}}
ERROR: logging before flag.Parse: I0523 ::24.177780 shared_informer.go:] caches populated
ERROR: logging before flag.Parse: I0523 ::24.177837 cache.go:] Caches are synced for operator-backup-controller controller
ERROR: logging before flag.Parse: I0523 ::24.177859 agent_controller.go:] Caches are synced
ERROR: logging before flag.Parse: I0523 ::39.439539 cluster_manager.go:] MySQL instance is online
ERROR: logging before flag.Parse: I0523 ::54.769749 cluster_manager.go:] MySQL instance is online
ERROR: logging before flag.Parse: I0523 ::10.081533 cluster_manager.go:] MySQL instance is online
ERROR: logging before flag.Parse: I0523 ::25.442784 cluster_manager.go:] MySQL instance is online
[root@k8s-master cluster]# kubectl logs mysql- -c mysql
++ grep '^search' /etc/resolv.conf
+ search='search default.svc.cluster.local. svc.cluster.local. cluster.local.'
+ echo 'search default.svc.cluster.local. svc.cluster.local. cluster.local. mysql.default.svc.cluster.local'
++ cat /etc/hostname
++ grep -o '[^-]*$'
+ index=
++ expr +
+ /entrypoint.sh --server_id= --user=mysql --datadir=/var/lib/mysql --log-error=/var/lib/mysql/mysqld.err --default-storage-engine=innodb --default-tmp-storage-engine=innodb --internal-tmp-disk-storage-engine=innodb --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_520_ci --core-file --default-password-lifetime= --default-time-zone=SYSTEM --explicit-defaults-for-timestamp=ON --performance-schema-consumer-events-transactions-current=ON --performance-schema-consumer-events-transactions-history=ON --innodb-buffer-pool-size=128M --innodb-buffer-pool-instances= --innodb-autoinc-lock-mode= --innodb-flush-method=O_DIRECT_NO_FSYNC --innodb-open-files= --innodb-log-buffer-size=4M --innodb-monitor-enable=% --innodb-print-all-deadlocks=ON --innodb-undo-log-truncate=ON --innodb-undo-tablespaces= --innodb-undo-logs= --binlog_checksum=NONE --gtid_mode=ON --enforce_gtid_consistency=ON --log_bin --binlog-format=ROW --log-slave-updates=ON --master-info-repository=TABLE --relay-log-info-repository=TABLE --slave-preserve-commit-order=ON --disabled_storage_engines=MyISAM,BLACKHOLE,FEDERATED,ARCHIVE --transaction-isolation=READ-COMMITTED --transaction-write-set-extraction=XXHASH64 --loose-group-replication-ip-whitelist=0.0.0.0/
[Entrypoint] MySQL Docker Image 5.7.-1.1.
[Entrypoint] Initializing database
[Entrypoint] Database initialized
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it. [Entrypoint] ignoring /docker-entrypoint-initdb.d/* [Entrypoint] Server shut down [Entrypoint] MySQL init process done. Ready for start up. [Entrypoint] Starting MySQL 5.7.20-1.1.2

describe下新建的集群

[root@k8s-master cluster]# kubectl describe mysqlclusters mysql
Name: mysql
Namespace: default
Labels: v1.mysql.oracle.com/cluster=mysql
v1.mysql.oracle.com/version=0.1.
Annotations: <none>
API Version: mysql.oracle.com/v1
Kind: MySQLCluster
Metadata:
Cluster Name:
Creation Timestamp: --22T06::42Z
Generation:
Resource Version:
Self Link: /apis/mysql.oracle.com/v1/namespaces/default/mysqlclusters/mysql
UID: 71c8a94e-5d8c-11e8-aaa7-080027e2ae0a
Spec:
Replicas:
Version: 5.7.-1.1.
Status:
Errors: <nil>
Metadata:
Creation Timestamp: <nil>
Phase:
Events: <none>

研究继续中....

mysql-operator 尝试与研究的更多相关文章

  1. 一次DB故障引起的反思和MySQL Operator选型

    前言 在一次数据库故障后,我们发现业务库会根据业务的等级会划分多个 MySQL 实例,许多业务库会同时属于一个 MySQL 实例,当一个库引发问题后整个实例的状态是不可控的.从而导致这个实例上的所有业 ...

  2. 容器化 | 在 K8s 上部署 RadonDB MySQL Operator 和集群

    作者:程润科 数据库研发工程师 编辑:张莉梅 高级文档工程师 视频:钱芬 高级测试工程师 本文将演示在 Kubernetes 上部署 RadonDB MySQL Kubernetes 2.X(Oper ...

  3. mysql分区方案的研究

    笔者觉得,分库分表确实好的.但是,动不动搞分库分表,太麻烦了.分库分表虽然是提高数据库性能的常规办法,但是太麻烦了.所以,尝试研究mysql的分区到底如何. 之前写过一篇文章,http://www.c ...

  4. 数据库进阶之路(五) - MySQL行锁深入研究

    由于业务逻辑的需要,必须对数据表的一行或多行加入行锁,举个最简单的例子,图书借阅系统:假设id=1的这本书库存为1,但是有2个人同时来借这本书,此处的逻辑为: ; --如果restnum大于0,执行u ...

  5. MySQL 一致性读 深入研究

    一致性读,又称为快照读.使用的是MVCC机制读取undo中的已经提交的数据.所以它的读取是非阻塞的. 相关文档:http://dev.mysql.com/doc/refman/5.6/en/innod ...

  6. MySQL 之 Metadata Locking 研究

    MySQL5.5 中引入了 metadata lock. 顾名思义,metadata lock 不是为了保护表中的数据的,而是保护 database objects(元数据)的.包括表结构.schem ...

  7. MySQL行锁深入研究

    原文:http://blog.csdn.net/minipeach/article/details/5325161/ 做项目时由于业务逻辑的需要,必须对数据表的一行或多行加入行锁,举个最简单的例子,图 ...

  8. MySQL 一致性读 深入研究 digdeep博客学习

    http://www.cnblogs.com/digdeep/p/4947694.html 一致性读,又称为快照读.使用的是MVCC机制读取undo中的已经提交的数据.所以它的读取是非阻塞的. 相关文 ...

  9. Spring boot教程mybatis访问MySQL的尝试

    Windows 10家庭中文版,Eclipse,Java 1.8,spring boot 2.1.0,mybatis-spring-boot-starter 1.3.2,com.github.page ...

随机推荐

  1. ZOJ-2753

    Min Cut (Destroy Trade Net) Time Limit: 15 Seconds      Memory Limit: 32768 KB Given an undirected g ...

  2. Windows + IDEA 手动开发MapReduce程序

    参见马士兵老师的博文:map_reduce 环境配置 Windows本地解压Hadoop压缩包,然后像配置JDK环境变量一样在系统环境变量里配置HADOOP_HOME和path环境变量.注意:hado ...

  3. maven新建web项目提示The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

    maven新建web项目提示The superclass "javax.servlet.http.HttpServlet" was not found on the Java Bu ...

  4. css文件放在头部的原因

    我在博问上发的一个这个问题 然后有人这样回复我的 我感觉很有道理的样子 所以我放上来了 这样会先加载css的样式,在渲染dom的时候已经知道了自己的样式了,所以一次渲染成功 如果css放在底部,那么需 ...

  5. react初体验

    function Guest() { return ( <h1>pls login in</h1> ); } function User() { return ( <h1 ...

  6. 182. Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  7. js正则表达大合集【转载自:http://caibaojian.com】

    [注明原文链接吧]:http://caibaojian.com 1 用户名正则 //用户名正则,4到16位(字母,数字,下划线,减号) var uPattern = /^[a-zA-Z0-9_-]{4 ...

  8. 洛谷 P3384 【模板】树链剖分-树链剖分(点权)(路径节点更新、路径求和、子树节点更新、子树求和)模板-备注结合一下以前写的题目,懒得写很详细的注释

    P3384 [模板]树链剖分 题目描述 如题,已知一棵包含N个结点的树(连通且无环),每个节点上包含一个数值,需要支持以下操作: 操作1: 格式: 1 x y z 表示将树从x到y结点最短路径上所有节 ...

  9. 洛谷——P2126 Mzc家中的男家丁

    P2126 Mzc家中的男家丁 题目背景 mzc与djn的…还没有众人皆知,所以我们要来宣传一下. 题目描述 mzc家很有钱(开玩笑),他家有n个男家丁,现在mzc要将她们全都聚集起来(干什么就不知道 ...

  10. 洛谷——P1630 求和

    P1630 求和 题目描述 求1^b+2^b+……+a^b的和除以10000的余数. 输入输出格式 输入格式: 第一行包含一个正整数N,表示共有N组测试数据: 接下来N行,每行包含两个正整数a和b. ...