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 ...
随机推荐
- leetcode 之Valid Palindrome(26)
现在开始进入字符串系列. 判断回文串的.首尾各定义一个指针,然后相比较.难点在于如何提出非字母数字的字符. bool isValidPalind(string s) { //转为小写,注意这个函数的用 ...
- LeetCode Linked List Cyle
Problem Description Given a linked list, determine if it has a cycle in it. Follow up:Can you solve ...
- win10更换登陆背景和关闭锁屏
更换登陆背景图 用国外一个hacker写的工具,可在github上下载,或者下载我上传到百度网盘的备份.win10默认的登陆背景太难看了. 去掉锁屏图片 登陆界面其实本身就是一种锁屏,为什么还要单独搞 ...
- AC日记——【模板】Link Cut Tree 洛谷 P3690
[模板]Link Cut Tree 思路: LCT模板: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 30 ...
- private是自己私有的,protected是可以让孩子知道的,public是公开的
三种访问权限 public:可以被任意实体访问,数据成员和函数成员可在成员函数,友元,继承类中直接使用.亦可以作为接口,供类的用户使用 protected:只允许子类及本类的成员函数访问,在基类中用法 ...
- Windows服务器学习篇:服务器连接与退出
此文是我早期在公司内部发布的一篇给予新入职程序员基础技术培训的文章,非常基础简单,现拿出来给大家分享.当然,已工作人士可直接忽略... 一.Windows服务器连接 1. 在桌面菜单中的“运行”里,输 ...
- NET应用——你的数据安全有必要升级
最近又被[现场破解共享单车系统]刷了一脸,不得不开始后怕:如何防止类似的情况发生? 想来想去,始终觉得将程序加密是最简单的做法.但是摩拜.ofo也有加密,为什么仍然被破解?那是因为请求在传输过程中被篡 ...
- 处理form表单提交后返回值的处理办法【html5】
同事朋友ajax,最近在弄公司业务电话机,自主搭建,买的设备. 其中最主要功能是前端发起呼叫,通过浏览器触发设备进行呼叫功能,走后台呼叫还不行. 需求是这样的: 前端给设备ip发送特定的一段xml信息 ...
- 转:python cgi编程
转:http://www.runoob.com/Python/python-cgi.html 什么是CGI CGI 目前由NCSA维护,NCSA定义CGI如下: CGI(Common Gateway ...
- LCA算法笔记
LCA,最近公共祖先,实现有多种不同的方法,在树上的问题中有着广泛的应用,比如说树上的最短路之类. LCA的实现方法有很多,比如RMQ.树链剖分等. 今天来讲其中实现较为简单的三种算法: RMQ+时间 ...