mysql-operator 尝试与研究
- 安装指南
- 先下载到本地
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 尝试与研究的更多相关文章
- 一次DB故障引起的反思和MySQL Operator选型
前言 在一次数据库故障后,我们发现业务库会根据业务的等级会划分多个 MySQL 实例,许多业务库会同时属于一个 MySQL 实例,当一个库引发问题后整个实例的状态是不可控的.从而导致这个实例上的所有业 ...
- 容器化 | 在 K8s 上部署 RadonDB MySQL Operator 和集群
作者:程润科 数据库研发工程师 编辑:张莉梅 高级文档工程师 视频:钱芬 高级测试工程师 本文将演示在 Kubernetes 上部署 RadonDB MySQL Kubernetes 2.X(Oper ...
- mysql分区方案的研究
笔者觉得,分库分表确实好的.但是,动不动搞分库分表,太麻烦了.分库分表虽然是提高数据库性能的常规办法,但是太麻烦了.所以,尝试研究mysql的分区到底如何. 之前写过一篇文章,http://www.c ...
- 数据库进阶之路(五) - MySQL行锁深入研究
由于业务逻辑的需要,必须对数据表的一行或多行加入行锁,举个最简单的例子,图书借阅系统:假设id=1的这本书库存为1,但是有2个人同时来借这本书,此处的逻辑为: ; --如果restnum大于0,执行u ...
- MySQL 一致性读 深入研究
一致性读,又称为快照读.使用的是MVCC机制读取undo中的已经提交的数据.所以它的读取是非阻塞的. 相关文档:http://dev.mysql.com/doc/refman/5.6/en/innod ...
- MySQL 之 Metadata Locking 研究
MySQL5.5 中引入了 metadata lock. 顾名思义,metadata lock 不是为了保护表中的数据的,而是保护 database objects(元数据)的.包括表结构.schem ...
- MySQL行锁深入研究
原文:http://blog.csdn.net/minipeach/article/details/5325161/ 做项目时由于业务逻辑的需要,必须对数据表的一行或多行加入行锁,举个最简单的例子,图 ...
- MySQL 一致性读 深入研究 digdeep博客学习
http://www.cnblogs.com/digdeep/p/4947694.html 一致性读,又称为快照读.使用的是MVCC机制读取undo中的已经提交的数据.所以它的读取是非阻塞的. 相关文 ...
- 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 ...
随机推荐
- 【Android开发日记】之入门篇(十五)——ViewPager+自定义无限ViewPager
ViewPager 在 Android 控件中,ViewPager 一直算是使用率比较高的控件,包括首页的banner,tab页的切换都能见到ViewPager的身影. viewpager 来源自 v ...
- 使用cmd(黑窗口)敲命令使用远程数据库
C:\Users\gzz>mysql -h 10.27.104.176 -u root -p mysql
- linux命令(42):wc命令
Linux系统中的wc(Word Count)命令的功能为统计指定文件中的字节数.字数.行数,并将统计结果显示输出. 1.命令格式: wc [选项]文件... 2.命令功能: 统计指定文件中的字节数. ...
- AC自动机算法
AC自动机简介: 首先简要介绍一下AC自动机:Aho-Corasick automation,该算法在1975年产生于贝尔实验室,是著名的多模匹配算法之一.一个常见的例子就是给出n个单词,再给出一段 ...
- display:flex代替float
昨天做一个css的东西,在开始用js的时候才发现被float占位了 因为float浮动起来了,我清除了浮动,但是还是占位 然后我同事就告诉我其实可以不用float来左右浮动 在父元素上用display ...
- 《java并发编程实战》读书笔记11--构建自定义的同步工具,条件队列,Condition,AQS
第14章 构建自定义的同步工具 本章将介绍实现状态依赖性的各种选择,以及在使用平台提供的状态依赖机制时需要遵守的各项规则. 14.1 状态依赖性的管理 对于并发对象上依赖状态的方法,虽然有时候在前提条 ...
- OSError: libgfortran.so.3: cannot open shared object file: No such file or directory
运行程序遇到下面问题 OSError: libgfortran.so.3: cannot open shared object file: No such file or directory 安装yu ...
- MySQL常用的几个数据类型详解
一.字符串类型 类型 范围 说明 Char(N) [ binary] N=1~255 个字节binary :分辨大小写 固定长度 std_name cahr(32) not null VarCha ...
- python正则的中文处理(转)
匹配中文时,正则表达式规则和目标字串的编码格式必须相同 print sys.getdefaultencoding() text =u"#who#helloworld#a中文x#" ...
- Codeforces 1131 C. Birthday-暴力 (Codeforces Round #541 (Div. 2))
C. Birthday time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...