00:00
那么我们打开resources下面的application properties。这是一个读写分离的配置的配置文件,垂直分片的配置呢,和它还不是特别一样,有一些区别,所以呢,我们把这个配置文件呢,做一个备份。叫做读写分离配置。那这个呢,就是我们的一个备份文件了,相当于我们把最新的配置呢,写在application里面。接下来呢,我们把读写分离,相关的配置呢,给它删掉好,数据源这块呢,我们留两个数据源就可以了。然后呢,这两个数据源呢,我们分别给它们进行一个命名,首先第一个数据源呢。可以叫server order。第二个数据源呢,可以叫server user。那么我们的数据源呢,我们可以配置在前面这个位置,我们来看一下啊。
01:05
Serve user是301是3302,那我们把3301在前面吧。3301是user。好,3302是order。那这是我们的这两个数据源的配置。数据源配置的过程当中呢,我们要把数据员的名字呢给他过来。好,这面user的数据源的名字呢,我们要把它复制过来。好,到这为止呢,我们就完整的配置了两个数据源。接下来呢,我们来看一下垂直分片怎么去具体的配置,那么我们打开Ding fair的官方网站,还是找到五用户手册Ding fair jdbc。
02:00
然后呢,下面的规则配置数据分片这一,那么在数据分片这一节当中呢,前面这第一部分呢,也是让我们先配置数据源,然后接下来呢,我们做一个标准的分片的配置。我们把这个直接复制过来哈。把它粘贴到我们的配置文件当中。然后后面有很多说明,我们先把这个说明呢,给它剪切到前面这个位置。那我们来看一下。那后面的这个叫做actual呢,就是真实的数据节点,什么真实的数据节点呢?那在我们的应用程序当中呢,一般情况下呢,它会有很多个数据库服务器。啊,那一个数据库服务器呢,我们现在呢,是把它作为一个数据源了,然后呢,一个数据库服务器当中有可能有多张表。好,现在我们有两台数据库服务器,两台数据库服务器当中呢,每个数据库服务器当中呢,有两张表,那么假设说我们这台据库服务器的名字叫A,这台叫B,那这个表叫一,这个表叫二,好,这个是B服务器上的一表,这个是B服务器上的二表,真实的数据节点呢,就是A1,这是一个真实的数据节点。
03:21
AR。这是一个真实的数据节点。那么。上面的一,这是一个真实的数据节点,那么B上的二,这也是真实的数据节点,所以这个就叫actual data啊,然后table是什么意思呢?Table就是刚才我们所说的逻辑表明好,那么我们一个表呢,它可能会对应一个或多个。真实的数据节点,所以接下来呢,我们就对这个逻辑表明和真实的数据节点之间的关系呢进行一个配置。那么首先呢,我们来看一下逻辑表,我们现在有两张,一个呢,就是前面我们提到的。
04:07
还有一个呢,就是。最始我们创建的个置table。另外一个。那这块呢,我们叫t order。配的是这个名字。好,那么tu user它所对应的真实的数据节点的名字是由数据源这呢,数据原名加表明组成的,并且呢,以小数点分割。那所以呢,我们的。数据原名是server user。那这个数据源当中。也就是这个数据源当中,它所对应的真实的呢。
05:02
这配置。这个数据源呢,它对应DB这个数据库,而DB这个数据库当中,它所对应的真实的表呢,叫。所以呢,这个地方呢,我们就配T的,那这样的话呢,我们就把。我们的逻辑表和真实的数据节点呢,就映射起来了,那我们在我们的应用程序当中,只要是针对这个数据库表进行增删改查,那么SPADDBC呢,就会自动的把针对这个表的所有的操作路由到这个数据节点上,同样如果我们在应用程序当中对t order这个逻辑表进行增删改查,那么she spare JD bc呢,就会自动的把相关的操作由到这个节点上,这个呢就是业务分库当中的垂直分片的一个配置。
我来说两句