• 安装指南
  • 先下载到本地
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. scrapy再学习与第二个实例

    这周对于Scrapy进一步学习,知识比较零散,需要爬取的网站因为封禁策略账号还被封了/(ㄒoㄒ)/~~ 一.信息存储 1.log存储命令:scrapy crawl Test --logfile=tes ...

  2. mybatis 一级缓存和二级缓存

    1.默认是会话期内 一级session缓存 2.二级缓存: 引入二级缓存的jar, 配置 ehcache.xml, mapper.xml引入缓存<cache type="org.myb ...

  3. [USACO06NOV]路障---严格次短路

    Description 贝茜把家搬到了一个小农场,但她常常回到FJ的农场去拜访她的朋友.贝茜很喜欢路边的风景,不想那么快地结束她的旅途,于是她每次回农场,都会选择第二短的路径,而不象我们所习惯的那样, ...

  4. Simplify Path——简单经典的预处理

    Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", ...

  5. CentOS安装指定版本GCC

    系统是CentOS 7, 自带的gcc是4.8.4 准备工作: 下载GCC源码包 gcc-5.5.0.tar.gz,地址(清华大学开源软件镜像站ipv6)(备选地址->gnu->gcc) ...

  6. CentOS7英文环境下使用中文输入法

    一般我们使用英文环境是没有办法使用中文的,这是因为我们没有设置在英文环境下的中文配置,下面我们在英文环境下配置中文输入法ibus使得我们可以输入中文. 首先,安装ibus(centos6以后已经默认安 ...

  7. Qt精简编译方法总结

    原文请看:http://blog.csdn.net/loaden/article/details/6061702 Qt如果采取默认编译安装,一般都要占用上G的空间.当初自己不想涉及Qt的一个原因,就是 ...

  8. 51nod 1295 XOR key-区间异或最大值-可持久化01Trie树(模板)

    1295 XOR key 2 秒 262,144 KB 160 分 6 级题   给出一个长度为N的正整数数组A,再给出Q个查询,每个查询包括3个数,L, R, X (L <= R).求A[L] ...

  9. Tyvj1933绿豆蛙的归宿

    给出一个有向无环图,起点为1终点为N,每条边都有一个长度,并且从起点出发能够到达所有的点,所有的点也都能够到达终点.绿豆蛙从起点出发,走向终点. 到达每一个顶点时,如果有K条离开该点的道路,绿豆蛙可以 ...

  10. Codeforces Round #407 (Div. 2) D. Weird journey(欧拉路)

    D. Weird journey time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...