10.Mysql Router
1.Mysql Router 是 Innodb cluster 集群的一部分,是轻量级中间件,为应用程序和后端Mysql服务器之前提供透明路由,下面就是它的一个架构设计。
2.现在Mysql routerer二进制安装包:https://dev.mysql.com/downloads/router/
3.安装并初始化并启动
3.1 Bootstrapping MySQL Router
mysqlrouter --bootstrap root@db01:3306 --directory /tmp/myrouter --conf-use-sockets --account routerfriend --account-create always
结果输出:
[mysql@db04 ~]$ mysqlrouter --bootstrap root@db01:3306 --directory /tmp/myrouter --conf-use-sockets --account routerfriend --account-create always Please enter MySQL password for root: # Bootstrapping MySQL Router instance at '/tmp/myrouter'... Please enter MySQL password for routerfriend: - Creating account(s) - Verifying account (using it to run SQL queries that would be run by Router) - Storing account in keyring - Adjusting permissions of generated files - Creating configuration /tmp/myrouter/mysqlrouter.conf # MySQL Router configured for the InnoDB Cluster 'ClusterTest' ##这里是mysqlrouter识别出的innodb cluster 集群名称 After this MySQL Router has been started with the generated configuration $ mysqlrouter -c /tmp/myrouter/mysqlrouter.conf ##这里是mysqlrouter配置文件 the cluster 'ClusterTest' can be reached by connecting to: ## MySQL Classic protocol - Read/Write Connections: localhost:6446, /tmp/myrouter/mysql.sock ##端口号 - Read/Only Connections: localhost:6447, /tmp/myrouter/mysqlro.sock ## MySQL X protocol - Read/Write Connections: localhost:6448, /tmp/myrouter/mysqlx.sock - Read/Only Connections: localhost:6449, /tmp/myrouter/mysqlxro.sock
命令说明:
mysqlrouter --bootstrap root@db01:3306 --directory /tmp/myrouter --conf-use-sockets --account routerfriend --account-create always
--bootstrap: 通过在提供的URI上连接到InnoDB集群元数据服务器来执行MySQL路由器引导的主要选项。MySQL Router根据从InnoDB集群元数据服务器检索到的信息进行配置,后面跟上集群中某一个数据库节点
--directory:指定mysqlrouter安装位置
--conf-use-sockets: 通过socket方式连接
--account:自定义路由器的mysql用户名
--account-create:当设置为always时仅在不存在时引导,并创建它。
3.2 启动MysqlRouter
cd /tmp/myrouter
./start.sh
4.连接测试
[root@db04 myrouter]# mysql -u root -h 127.0.0.1 -P 6446 -p123 #6446是RW节点 [root@db04 myrouter]# mysql -u root -h 127.0.0.1 -P 6447 -p123 #6447是RO节点
参考:https://dev.mysql.com/doc/mysql-router/8.0/en/mysql-router-preface.html
关于配置文件文件中的说明可以参考: https://dev.mysql.com/doc/mysql-router/8.0/en/mysql-router-conf-options.html
[DEFAULT]
master_total_connections:路由器允许的客户端连接的最大总数,默认是512,这个参数主要是防止文件描述符耗尽
thread_stack_size: 分配给每个线程堆栈的内存大小(以KB为单位),默认是64k
分类:
Mysql之高可用
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
2021-07-08 31.Explain(执行计划)浅谈