当前位置: 首页 > news >正文

数据库服务分布架构(MyCAT)

1.18.1数据库服务分布架构概述介绍
分布式架构理念:(基于业务逻辑分布式/基于程序逻辑分布式)
●架构演变过程早期,为了满足主要业务功能需求,可以将所有程序部署在一个服务器节点上;
·架构演变过程发展,为了满足主要业务压力增长,可以将所有程序拆分部署在不同服务器上;
●架构演变过程发展,为了满足主要业务安全稳定,可以将数据库设计成主从架构或读写分离;
●架构演变过程发展,为了满足多个业务数量增加,可以将架构环境根据业务的情况独立拆分;
●架构演变过程发展,为了满足单独业务数量激增I可以将多个数据表进行拆分到多个节点上;(垂直拆分-MyCAT进行数据表信息整合)
●架构演变过程发展,为了满足单独业务数量激增,可以将单个数据表进行拆分到多个节点上;(水平拆分-MyCAT进行数据表信息整合)
●架构演变过程发展,为了满足业务的数据搜索业务需求、缓存业务需求、大数据业务分析需求,还要引入NOSQL或NewSQL数据库;

 

传统网站架构的发展变化历程

1674788427009

数据库存储架构发展变化历程

1674788468176

1674788511223

1674788559115

 

架构规划

需要连个虚拟主机,每个虚拟主机中需要有4个实例

1674789847654

1674800966208

基础环境操作命令

# 删除历史数据库环境
pkill mysqld
rm -rf /data/330*
mv /etc/my.cnf /etc/my.cnf.bak# 创建相关目录初始化数据
mkdir /data/33{07..10}/data -p && chown -R mysql.mysql /data/*
初始化命令。。。

 

image

 systemctl文件

image

MyCAT分布式存储主从环境架构(进行多实例主从与双主架构)

实现双主关系建立

# 实现双主关系建立(10.0.0.51:3307 <--> 10.0.0.52:3307)
mysql -S /data/3307/mysql.sock -e "create user repl@'10.0.0.%'" identified with 
\mysql_native_password by '123';grant replication slave on *.* to repl@10.0.0.%;" db02上进行 mysql -S /data/3307/mysql.sock -e "create user root@'10.0.0.%'" identified with
\mysql_native_password by 'root';grant all on *.* to repl@10.0.0.%;" db02上进行

在db01数据库上进行操作
mysql -S /data/3307/mysql.sock -e "change master to master_host='10.0.0.52',master_port=3307\
,master_auto_position=1,master_user='repl',master_password='123';"
mysql -S /data/3307/mysql.sock -e "start slave;"
mysql -S /data/3307/mysql.sock -e "show slave status\G;" |grep Running;

在db02数据库上进行操作
mysql -S /data/3307/mysql.sock -e "change master to master_host='10.0.0.51',master_port=3307\
,master_auto_position=1,master_user='repl',master_password='123';"
mysql -S /data/3307/mysql.sock -e "start slave;"
mysql -S /data/3307/mysql.sock -e "show slave status\G;" |grep Running;
# 实现主从建立(10.0.0.51:3307 --> 10.0.0.51:3309)
mysql -S /data/3309/mysql.sock -e "change master to master_host='10.0.0.51',master_port=3307\
,master_auto_position=1,master_user='repl',master_password='123';"
mysql -S /data/3309/mysql.sock -e "start slave;"
mysql -S /data/3309/mysql.sock -e "show slave status\G;" |grep Running;
# 实现主从建立(10.0.0.52:3307 --> 10.0.0.52:3309)
mysql -S /data/3309/mysql.sock -e "change master to master_host='10.0.0.51',master_port=3307\
,master_auto_position=1,master_user='repl',master_password='123';"
mysql -S /data/3309/mysql.sock -e "start slave;"
mysql -S /data/3309/mysql.sock -e "show slave status\G;" |grep Running;

 

 

# 实现双主关系建立(10.0.0.51:3308 <--> 10.0.0.52:3308)
mysql -S /data/3308/mysql.sock -e "create user repl@'10.0.0.%'" identified with 
\mysql_native_password by '123';grant replication slave on *.* to repl@10.0.0.%;"  db01上进行
mysql -S /data/3308/mysql.sock -e "create user root@'10.0.0.%'" identified with 
\mysql_native_password by 'root';grant all on *.* to repl@10.0.0.%;"  db01上进行

在db02数据库上进行操作
mysql -S /data/3308/mysql.sock -e "change master to master_host='10.0.0.52',master_port=3307\
,master_auto_position=1,master_user='repl',master_password='123';"
mysql -S /data/3308/mysql.sock -e "start slave;"
mysql -S /data/3308 /mysql.sock -e "show slave status\G;" |grep Running;在db02数据库上进行操作
mysql -S /data/3307/mysql.sock -e "change master to master_host='10.0.0.51',master_port=3307\
,master_auto_position=1,master_user='repl',master_password='123';"
mysql -S /data/3307/mysql.sock -e "start slave;"
mysql -S /data/3307/mysql.sock -e "show slave status\G;" |grep Running;
# 实现主从建立(10.0.0.51:3307 --> 10.0.0.51:3309)
mysql -S /data/3309/mysql.sock -e "change master to master_host='10.0.0.51',master_port=3307\
,master_auto_position=1,master_user='repl',master_password='123';"
mysql -S /data/3309/mysql.sock -e "start slave;"
mysql -S /data/3309/mysql.sock -e "show slave status\G;" |grep Running;
# 实现主从建立(10.0.0.52:3307 --> 10.0.0.52:3309)
mysql -S /data/3309/mysql.sock -e "change master to master_host='10.0.0.51',master_port=3307\
,master_auto_position=1,master_user='repl',master_password='123';"
mysql -S /data/3309/mysql.sock -e "start slave;"
mysql -S /data/3309/mysql.sock -e "show slave status\G;" |grep Running;

 

异常同步错误充值方法

mysql -S /data/3307/mysql.sock -e "stop;reset slave all;"

mysql -S /data/3308/mysql.sock -e "stop;reset slave all;"

mysql -S /data/3309/mysql.sock -e "stop;reset slave all;"

mysql -S /data/3310/mysql.sock -e "stop;reset slave all;"

安装MYCAT软件层序

 

http://www.rkmt.cn/news/14161.html

相关文章:

  • 题解:P14038 [PAIO 2025] Adventure Plan
  • 20231414_王仕琪_密码技术密码杂凑算法学习笔记
  • 堆设置了8G,java进程却占用了12G内存
  • IntelliJ IDEA 中 Shared Build Process Heap Size 的重要性与配置
  • 企业数字化转型战略规划:从愿景到落地的完整路径
  • Java 与智慧港口:航运调度与物流枢纽数字化
  • 千亿芯片公司被股东“抛弃” ,AI芯片第一股前景几何?
  • DeepSeek-V3.2-Exp 发布,训练推理提效,API 同步降价
  • 9.29 闲话
  • US$16 Yanhua BMW F/G Chassis Odometer Wiring Harness
  • US$980 Xhorse VVDI2 BMW OBD + CAS4 +FEM/BDC Functions Full BMW License
  • 2025年9月29日
  • 最高人民法院新劳动争议司法解释一 理解与适用
  • 逆元 组合数问题
  • 一、驱动基础知识速览(迅为RK3568)
  • MonoDETR(2)
  • 记录---window.close()失效 + Chrome浏览器调试线上代码
  • 启发式合并 [USACO22DEC] Making Friends P
  • 加密的病例单
  • 【多线程】什么是原子操作(Atomic Operation)? - 详解
  • 复刻江协旋钮控制模块
  • c语言switch和if语句
  • Qt(制作一个方便的文本编辑器)
  • tldr的安装与利用
  • 题解:P7126 [Ynoi2008] rdCcot
  • 实用指南:汽车地带AutoZone EDI需求分析及对接指南
  • 航司网站url后缀参数FECU分析
  • 优化 if/else 的四种设计模式
  • 多corner综合
  • Day11-C:\Users\Lenovo\Desktop\note\code\JavaSE\Basic\src\com\oop\demo06