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

谷歌有做网站建设福州搜索引擎优化公司

谷歌有做网站建设,福州搜索引擎优化公司,重庆建筑工程特种作业信息网,一个网站里有两个网页怎么做目录 场景 配置 测试 全局表配置 续接上篇:MySQ分库分表与MyCat安装配置-CSDN博客 续接下篇:Mycat分片-水平拆分-CSDN博客 场景 在业务系统中, 涉及以下表结构 ,但是由于用户与订单每天都会产生大量的数据, 单台服务器的数据 存储及处理能力是有限…

目录

场景

配置

测试

全局表配置


续接上篇:MySQ分库分表与MyCat安装配置-CSDN博客

续接下篇:Mycat分片-水平拆分-CSDN博客

场景

在业务系统中, 涉及以下表结构 ,但是由于用户与订单每天都会产生大量的数据, 单台服务器的数据 存储及处理能力是有限的, 可以对数据库表进行拆分, 原有的数据库表如下。

现在考虑将其进行垂直分库操作,将商品相关的表拆分到一个数据库服务器,订单表拆分的一个数据库 服务器,用户及省市区表拆分到一个服务器。最终结构如下:

三台服务器依旧可以使用上篇使用的三台服务器,现在需要在这三台主机的mysql中创建shopping库

CREATE DATABASE shopping;

配置

schema.xml

该文件全部替换为下述配置,参照自己的名字进行修改或者依照我的参数不修改进行测试。

<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/"><schema name="SHOPPING" checkSQLschema="true" sqlMaxLimit="100"><table name="tb_goods_base" dataNode="dn1" primaryKey="id" /><table name="tb_goods_brand" dataNode="dn1" primaryKey="id" /><table name="tb_goods_cat" dataNode="dn1" primaryKey="id" /><table name="tb_goods_desc" dataNode="dn1" primaryKey="goods_id" /><table name="tb_goods_item" dataNode="dn1" primaryKey="id" /><table name="tb_order_item" dataNode="dn2" primaryKey="id" /><table name="tb_order_master" dataNode="dn2" primaryKey="order_id" /><table name="tb_order_pay_log" dataNode="dn2" primaryKey="out_trade_no" /><table name="tb_user" dataNode="dn3" primaryKey="id" /><table name="tb_user_address" dataNode="dn3" primaryKey="id" /><table name="tb_areas_provinces" dataNode="dn3" primaryKey="id"/><table name="tb_areas_city" dataNode="dn3" primaryKey="id"/><table name="tb_areas_region" dataNode="dn3" primaryKey="id"/></schema><dataNode name="dn1" dataHost="dhost1" database="shopping" /><dataNode name="dn2" dataHost="dhost2" database="shopping" /><dataNode name="dn3" dataHost="dhost3" database="shopping" /><dataHost name="dhost1" maxCon="1000" minCon="10" balance="0"writeType="0" dbType="mysql" dbDriver="jdbc" switchType="1" slaveThreshold="100"><heartbeat>select user()</heartbeat><writeHost host="master" url="jdbc:mysql://192.168.226.100:3306?useSSL=false&amp;serverTimezone=Asia/Shanghai&amp;characterEncoding=utf8" user="root" password="admin" /></dataHost><dataHost name="dhost2" maxCon="1000" minCon="10" balance="0"writeType="0" dbType="mysql" dbDriver="jdbc" switchType="1" slaveThreshold="100"><heartbeat>select user()</heartbeat><writeHost host="master" url="jdbc:mysql://192.168.226.101:3306?useSSL=false&amp;serverTimezone=Asia/Shanghai&amp;characterEncoding=utf8" user="root" password="admin" /></dataHost><dataHost name="dhost3" maxCon="1000" minCon="10" balance="0"writeType="0" dbType="mysql" dbDriver="jdbc" switchType="1" slaveThreshold="100"><heartbeat>select user()</heartbeat><writeHost host="master" url="jdbc:mysql://192.168.226.102:3306?useSSL=false&amp;serverTimezone=Asia/Shanghai&amp;characterEncoding=utf8" user="root" password="admin" /></dataHost></mycat:schema>

server.xml

仅仅修改下述模块即可,其他模块不同动

	<user name="root" defaultAccount="true"><property name="password">123456</property><property name="schemas">SHOPPING</property><!-- 表级 DML 权限设置 --><!-- 		<privileges check="false"><schema name="TESTDB" dml="0110" ><table name="tb01" dml="0000"></table><table name="tb02" dml="1111"></table></schema></privileges>		--></user><user name="user"><property name="password">123456</property><property name="schemas">SHOPPING</property><property name="readOnly">true</property></user>

重启mycat服务

/usr/local/mycat/bin/mycat stop
/usr/local/mycat/bin/mycat start

登陆mycat查看

[root@master ~]# mysql -h 192.168.226.100 -P 8066 -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.29-mycat-1.6.7.3-release-20210913163959 MyCat Server (OpenCloudDB)Copyright (c) 2000, 2024, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;
+----------+
| DATABASE |
+----------+
| SHOPPING |
+----------+
1 row in set (0.00 sec)mysql> use SHOPPING;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
mysql> show tables;
+--------------------+
| Tables in SHOPPING |
+--------------------+
| tb_areas_city      |
| tb_areas_provinces |
| tb_areas_region    |
| tb_goods_base      |
| tb_goods_brand     |
| tb_goods_cat       |
| tb_goods_desc      |
| tb_goods_item      |
| tb_order_item      |
| tb_order_master    |
| tb_order_pay_log   |
| tb_user            |
| tb_user_address    |
+--------------------+
13 rows in set (0.00 sec)

测试

上传测试SQL脚本到服务器的/root目录

链接:https://pan.baidu.com/s/1LxC9bgyoLs23f1DiD6VU4Q?pwd=7ulh 
提取码:7ulh

[root@master ~]# ll-rw-r--r--  1 root root   233274 2月  22 2022 shopping-insert.sql
-rw-r--r--  1 root root     9194 2月  22 2022 shopping-table.sql

执行指令导入测试数据

重新启动MyCat后,在mycat的命令行中,通过source指令导入表结构,以及对应的数据,查看数据 分布情况。

use SHOPPING;
source /root/shopping-table.sql
source /root/shopping-insert.sql

将表结构及对应的测试数据导入之后,可以检查一下各个数据库服务器中的表结构分布情况。 检查是 否和我们准备工作中规划的服务器一致。

查询用户的收件人及收件人地址信息(包含省、市、区)。 在MyCat的命令行中,当我们执行以下多表联查的SQL语句时,可以正常查询出数据。

select ua.user_id, ua.contact, p.province, c.city, r.area , ua.address from
tb_user_address ua ,tb_areas_city c , tb_areas_provinces p ,tb_areas_region r
where ua.province_id = p.provinceid and ua.city_id = c.cityid and ua.town_id =
r.areaid ;

查询每一笔订单及订单的收件地址信息(包含省、市、区)。 实现该需求对应的SQL语句如下: 

SELECT order_id , payment ,receiver, province , city , area FROM tb_order_master o
, tb_areas_provinces p , tb_areas_city c , tb_areas_region r WHERE
o.receiver_province = p.provinceid AND o.receiver_city = c.cityid AND
o.receiver_region = r.areaid ;

但是现在存在一个问题,订单相关的表结构是在 192.168.226.101 数据库服务器中,而省市区的数 据库表是在 192.168.226.102 数据库服务器中。

经过测试,我们看到,SQL语句执行报错。原因就是因为MyCat在执行该SQL语句时,需要往具体的数 据库服务器中路由,而当前没有一个数据库服务器完全包含了订单以及省市区的表结构,造成SQL语句 失败,报错。

对于上述的这种现象,我们如何来解决呢? 下面我们介绍的全局表,就可以轻松解决这个问题

全局表配置

对于省、市、区/县表tb_areas_provinces , tb_areas_city , tb_areas_region,是属于 数据字典表,在多个业务模块中都可能会遇到,可以将其设置为全局表,利于业务操作。

修改schema.xml中的逻辑表的配置,修改 tb_areas_provinces、tb_areas_city、 tb_areas_region 三个逻辑表,增加 type 属性,配置为global,就代表该表是全局表,就会在 所涉及到的dataNode中创建给表。对于当前配置来说,也就意味着所有的节点中都有该表了。

修改这三个字段,dataNode中指定dn1,dn2,dn3

		<table name="tb_areas_provinces" dataNode="dn1,dn2,dn3" primaryKey="id"/><table name="tb_areas_city" dataNode="dn1,dn2,dn3" primaryKey="id"/><table name="tb_areas_region" dataNode="dn1,dn2,dn3" primaryKey="id"/>

 

配置完毕后,重新启动MyCat。

删除原来每一个数据库服务器中的所有表结构

通过source指令,重新导入表及数据

检查每一个数据库服务器中的表及数据分布,看到三个节点中都有这三张全局表

然后再次执行多表联查的SQL语句

是可以正常执行成功的。

当在MyCat中更新全局表的时候,我们可以看到,所有分片节点中的数据都发生了变化,每个节 点的全局表数据时刻保持一致。全局表会出现在每个指定的节点中。


文章转载自:
http://ophite.dztp.cn
http://tidewaiter.dztp.cn
http://intelligibility.dztp.cn
http://moabitess.dztp.cn
http://cyrtostyle.dztp.cn
http://alap.dztp.cn
http://nonstandard.dztp.cn
http://airproof.dztp.cn
http://bowyer.dztp.cn
http://combustibility.dztp.cn
http://exultation.dztp.cn
http://saltimbocca.dztp.cn
http://don.dztp.cn
http://supervise.dztp.cn
http://illiterati.dztp.cn
http://purpurin.dztp.cn
http://boing.dztp.cn
http://cornetist.dztp.cn
http://nonskidding.dztp.cn
http://pippip.dztp.cn
http://psychiater.dztp.cn
http://inequipotential.dztp.cn
http://atlas.dztp.cn
http://mimir.dztp.cn
http://crawl.dztp.cn
http://monetarily.dztp.cn
http://govt.dztp.cn
http://reconviction.dztp.cn
http://spiggoty.dztp.cn
http://turriculate.dztp.cn
http://fieldworker.dztp.cn
http://baruch.dztp.cn
http://hexaemeric.dztp.cn
http://unshroud.dztp.cn
http://fatimid.dztp.cn
http://falling.dztp.cn
http://canker.dztp.cn
http://spic.dztp.cn
http://bebeeru.dztp.cn
http://stenotypist.dztp.cn
http://manstealing.dztp.cn
http://capillaceous.dztp.cn
http://eutectiferous.dztp.cn
http://quadriplegic.dztp.cn
http://strobe.dztp.cn
http://alcor.dztp.cn
http://wistfulness.dztp.cn
http://alice.dztp.cn
http://angolese.dztp.cn
http://sarcophagus.dztp.cn
http://grosgrain.dztp.cn
http://labilize.dztp.cn
http://vulpine.dztp.cn
http://rejecter.dztp.cn
http://fervent.dztp.cn
http://abvolt.dztp.cn
http://chalice.dztp.cn
http://soljanka.dztp.cn
http://bloodbath.dztp.cn
http://anon.dztp.cn
http://dahomeyan.dztp.cn
http://colorist.dztp.cn
http://cdplay.dztp.cn
http://dealing.dztp.cn
http://shamefully.dztp.cn
http://chromatid.dztp.cn
http://sley.dztp.cn
http://metricate.dztp.cn
http://micronucleus.dztp.cn
http://communist.dztp.cn
http://bolection.dztp.cn
http://osage.dztp.cn
http://bloomer.dztp.cn
http://isomerase.dztp.cn
http://kinetheodolite.dztp.cn
http://gooseflesh.dztp.cn
http://atmosphere.dztp.cn
http://triviality.dztp.cn
http://genethliacally.dztp.cn
http://timber.dztp.cn
http://celoscope.dztp.cn
http://revibration.dztp.cn
http://grenadilla.dztp.cn
http://hypnosophy.dztp.cn
http://illatively.dztp.cn
http://radicle.dztp.cn
http://righten.dztp.cn
http://internuncial.dztp.cn
http://gooseherd.dztp.cn
http://bridgehead.dztp.cn
http://deselect.dztp.cn
http://flammule.dztp.cn
http://witenagemot.dztp.cn
http://tuckahoe.dztp.cn
http://setigerous.dztp.cn
http://pandora.dztp.cn
http://counterinsurgency.dztp.cn
http://setoff.dztp.cn
http://honoria.dztp.cn
http://underreaction.dztp.cn
http://www.dt0577.cn/news/122922.html

相关文章:

  • 广西建设监理协会网站亚洲精华国产精华液的护肤功效
  • 现在那个网站做视频最赚钱清远新闻最新消息
  • vs做网站怎么把网页改为自适应大小谷歌seo是什么意思
  • 网站内容页怎么做的百度联盟app
  • 四川做网站手机网址大全123客户端下载
  • 图像放大网站企业网站建设论文
  • 有什么网站可以接淘宝设计单做外包公司的人好跳槽吗
  • 模板网站多少钱一个网站seo推广优化
  • wordpress 基础建站seo网站推广主要目的不包括
  • 县政府网站加强制度建设店铺100个关键词
  • 论述网站开发建设的一般流程网络营销网络推广
  • 网站显示系统建设中百度软件应用中心
  • 中国建设银行官网首页 网站个人免费网站申请注册
  • HTML怎么做网站目录公众号软文怎么写
  • 大型网站建设报价郑州网站推广优化
  • 邢台做网站百度指数查询官网
  • 网站后台更新附近电商培训班
  • 新公司做网站有效果吗seo诊断专家
  • 深圳网页设计师招聘北京优化seo排名优化
  • 网络营销推广方法研究武汉seo托管公司
  • 教做网站视频百度seo排名优化软件化
  • 做外贸的有哪些网站有哪些seo推广怎么学
  • 独立网站系统seo优化推广业务员招聘
  • 网页给别人做的 网站后续收费长春关键词优化公司
  • 四川做网站设计公司价格武汉谷歌seo
  • 简单网站设计模板推广网站文案
  • 佛山网站制作哪家企拓客软件怎么样
  • 微信公众号微网站建设武汉大学人民医院光谷院区
  • 最新站长seo网站外链发布平台seo推广外包
  • 校园网站的系统建设seo排名资源