接上一篇:企业实战_15_MySql主从复制到MyCat总结
https://gblfy.blog.csdn.net/article/details/118657995

文章目录

  • 一、准备工作
    • 1. Mycat全局自增实现思路
    • 2. 创建mycat数据库
    • 3. 导入初始化脚本
    • 4. 登录验证
  • 二、配置文件修改
    • 2.1. server.xml配置
    • 2.2. 添加数据节点
    • 2.3. 验证im_mycat权限
    • 2.4. 配置数据节点和逻辑表明
    • 2.5. 设置自增属性
    • 2.6. 开启自增属性
    • 2.7. 赋予权限
  • 三、测试验证
    • 3.1. 重启mycat
    • 3.2. 数据清理
    • 3.3. 批量插入数据
    • 3.4. 查看数据
    • 3.5. 得出结论
    • 3.6. 执行记录
一、准备工作
1. Mycat全局自增实现思路
  • 在任意节点创建mycat数据库
  • 将/app/mycat/conf/dbseq.sql文件中的数据导入到mycat数据库中
  • 修改schema.xml文件添加主机节点和数据节点,如果主机节点已经存在,可以不添加
  • 修改server.xml设置增增ID生成类型为数据库形式
  • 修改 sequence_db_conf.properties文件,设置那些逻辑表需要自增ID和数据节点的名称
  • 给mycat数据库中的MYCAT_SEQUENCE 表插入一条数据,设置定增属性
  • 修改schema.xml文件,设置给哪个逻辑表自用自增ID
  • 赋予mycat用户操作函数的权限
  • 重新启动mycat
  • 数据清理
  • 批量插入数据,查看order_id 是否重复
2. 创建mycat数据库

在任意节点,创建mycat数据库,这里演示在node1节点创建mycat数据库

# 登录node1节点的mysql
mysql -uroot -p123456# 查看数据库列表
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| imooc_db           |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.01 sec)# 创建数据库
create database mycat;mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| imooc_db           |
| mycat              |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

注:其他节点创建mycat数据库一样

3. 导入初始化脚本

将dbseq.sql导入MyCat数据库中

# 进入mycat的conf目录
cd /app/mycat/conf# 初始化表结构脚本
mysql -uroot -p mycat < dbseq.sql
4. 登录验证
# 登录mycat数据库
mysql -uroot -p123456# 使用mycat数据库
use mycat;# 查看初始化脚本后的数据库有哪些对象
show tables;# 查看MYCAT_SEQUENCE表中数据
select * from MYCAT_SEQUENCE;可以看出设置了全局id 1 自增1
mysql> use mycat;
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_mycat |
+-----------------+
| MYCAT_SEQUENCE  |
+-----------------+
1 row in set (0.00 sec)mysql> select * from MYCAT_SEQUENCE;
+--------+---------------+-----------+
| name   | current_value | increment |
+--------+---------------+-----------+
| GLOBAL |             1 |         1 |
+--------+---------------+-----------+
1 row in set (0.00 sec)
二、配置文件修改
2.1. server.xml配置
cd /app/mycat/conf/
vim server.xml
<!--
0-以本地文件生成序列号
1-以数据库形式
2-时间戳序列
3-以zookeeper形式生成自增序列
-->
# 将此属性修改为1 ,1代表从数据库中读取
# 告诉mycat我是石勇数据库读取的方式生成全局自增id
<property name="sequnceHandlerType">1</property>
2.2. 添加数据节点

在schema.xml文件中,添加数据主机节点

<dataHost name="mysql92101" maxCon="1000" minCon="10" balance="3" writeType="0" dbType="mysql" dbDriver="native" switchType="1"><heartbeat>select user()</heartbeat><writeHost host="192.168.92.101" url="192.168.92.101:3306" user="im_mycat" password="123456"></writeHost></dataHost>

添加数据节点

<dataNode name="mycat"    dataHost="mysql92101" database="mycat" />

注:如果mycat数据库和分片的某一个数据库节点在一个mysql中,添加dohost节点这一步可以省略

2.3. 验证im_mycat权限
# 登录mysql
mysql -uroot -p123456# 使用mysql数据库
mysql> use mysql;
Database changed
mysql> select user,host from user;
+---------------+--------------+
| user          | host         |
+---------------+--------------+
| root          | %            |
| im_mycat      | 192.168.92.% |
| im_repl       | 192.168.92.% |
| mysql.session | localhost    |
| mysql.sys     | localhost    |
+---------------+--------------+
5 rows in set (0.00 sec)# 查看im_mycat用户权限
mysql> show grants for im_mycat@'192.168.92.%';
+-----------------------------------------------------------------------------------+
| Grants for im_mycat@192.168.92.%                                                  |
+-----------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON *.* TO 'im_mycat'@'192.168.92.%' |
+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
2.4. 配置数据节点和逻辑表明

sequence_db_conf.properties

  • 数据节点
  • 自增表和mycay数据库所在数据节点名称
# 指定表、函数所在的数据节点
vim sequence_db_conf.propertiesGLOBAL=mycat
# ORDER_MASTER表所在的数据节点
ORDER_MASTER=mycat
2.5. 设置自增属性

最后在mycat数据库中,给mycat_sequence 插入一条数据,设置自增属性
insert into mycat_sequence values (‘order_key’,1,1);
#再次查看

# 登录mysql
mysql -uroot -p123456# 使用mycat数据库
use mycat;# 查询MYCAT_SEQUENCE
select *  from MYCAT_SEQUENCE;# 给MYCAT_SEQUENCE 插入一条数据,设置定增属性
insert into MYCAT_SEQUENCE VALUES ('ORDER_MASTER',1,1);# 再次查看
select *  from MYCAT_SEQUENCE;

执行记录:

mysql> use mycat
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> select *  from MYCAT_SEQUENCE;
+--------+---------------+-----------+
| name   | current_value | increment |
+--------+---------------+-----------+
| GLOBAL |             1 |         1 |
+--------+---------------+-----------+
1 row in set (0.00 sec)mysql> insert into MYCAT_SEQUENCE VALUES ('ORDER_MASTER',1,1);
Query OK, 1 row affected (0.01 sec)mysql> select *  from MYCAT_SEQUENCE;
+--------------+---------------+-----------+
| name         | current_value | increment |
+--------------+---------------+-----------+
| GLOBAL       |             1 |         1 |
| ORDER_MASTER |             1 |         1 |
+--------------+---------------+-----------+
2 rows in set (0.00 sec)mysql>
2.6. 开启自增属性

在ORDER_MASTER 的逻辑表中添加autoIncrement="true"属性
在逻辑表(ORDER_MASTER )中,添加autoIncrement="true"属性

cd /app/mycat/confvim schema.xml
<table name="order_master"          primaryKey="order_id"          dataNode="ordb01,ordb02,ordb03,ordb04" rule="order_master" autoIncrement="true"/>
2.7. 赋予权限

赋予权限im_mycat用户执行函数的权限

mysql -uroot -p123456
use mysql;
show grants for im_mycat@'192.168.92.%';#  赋予权限`im_mycat`用户执行函数的权限
grant execute on *.* to 'im_mycat'@'192.168.92.%';show grants for im_mycat@'192.168.92.%';

执行日志

mysql> use mysql;
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 grants for im_mycat@'192.168.92.%';
+-----------------------------------------------------------------------------------+
| Grants for im_mycat@192.168.92.%                                                  |
+-----------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON *.* TO 'im_mycat'@'192.168.92.%' |
+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> grant execute on *.* to 'im_mycat'@'192.168.92.%';
Query OK, 0 rows affected (0.01 sec)mysql> show grants for im_mycat@'192.168.92.%';
+-----------------------------------------------------------------------------------+
| Grants for im_mycat@192.168.92.%                                                  |
+-----------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON *.* TO 'im_mycat'@'192.168.92.%' |
+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)mysql>
三、测试验证
3.1. 重启mycat

重新启动mycat

mycat stopmycat start
3.2. 数据清理
mysql  -uapp_imooc -p123456 -h192.168.92.101 -P8066
use imooc_db;
delete from order_master;
3.3. 批量插入数据
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES (1, 1, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES (2, 2, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES (1, 3, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES (1, 4, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES (1, 5, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES (1, 6, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES (1, 7, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES (1, 8, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES (1, 9, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES ( 1,10, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
3.4. 查看数据
mysql> select customer_id,order_sn,order_id  from order_master order by order_id;
+-------------+----------+----------+
| customer_id | order_sn | order_id |
+-------------+----------+----------+
|           1 |        1 |        2 |
|           2 |        2 |        3 |
|           3 |        1 |        4 |
|           4 |        1 |        5 |
|           5 |        1 |        6 |
|           6 |        1 |        7 |
|           7 |        1 |        8 |
|           8 |        1 |        9 |
|           9 |        1 |       10 |
|          10 |        1 |       11 |
+-------------+----------+----------+
10 rows in set (0.03 sec)
3.5. 得出结论

经过配置之后,订单order_id就不会重复了

下一篇:企业实战_12_Mycat水平扩展_跨分片查询_ER分片

https://blog.csdn.net/weixin_40816738/article/details/100066013

3.6. 执行记录
[root@node1 ~]# mysql  -uapp_imooc -p123456 -h192.168.92.101 -P8066
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.5-release-20180122220033 MyCat Server (OpenCloundDB)Copyright (c) 2000, 2021, 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 |
+----------+
| imooc_db |
+----------+
1 row in set (0.00 sec)mysql> use imooc_db;
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 imooc_db    |
+-----------------------+
| customer_balance_log  |
| customer_inf          |
| customer_level_inf    |
| customer_login        |
| customer_login_log    |
| customer_point_log    |
| order_cart            |
| order_customer_addr   |
| order_detail          |
| order_master          |
| product_brand_info    |
| product_category      |
| product_comment       |
| product_info          |
| product_pic_info      |
| product_supplier_info |
| region_info           |
| shipping_info         |
| warehouse_info        |
| warehouse_proudct     |
+-----------------------+
20 rows in set (0.00 sec)mysql> delete from order_master;
Query OK, 10 rows affected (0.02 sec)mysql> select * from order_master;
Empty set (0.01 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
ustomer_id,shipping_user,province,city,district,address,payment_method,order_money,district_money,shipping_money,payment_money,shippme,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  VALUES (1, 3, '雨昕', 1, 1, 1, '北京',NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL, '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_mo)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
ey,shipping_money,payment_money,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_poALUES (1, 8, '雨昕', 1, 1, 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:20:25');
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,district_moipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_time)  京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0, NULL,
Query OK, 1 row affected (0.12 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.11 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.11 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.11 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.12 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.12 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.11 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.12 sec)mysql> INSERT INTO `order_master` (order_sn,customer_id,shipping_user,province,city,district,address,payment_method,order_money,distoney,shipping_comp_name,shipping_sn,create_time,shipping_time,pay_time,receive_time,order_status,order_point,invoice_title,modified_ 1, '北京', 1, 10.00, 0.00, 0.00, 0.00, NULL, NULL, '2021-07-11 20:20:25', NULL, '2021-07-11 20:18:55', '2021-07-11 20:18:59', 0, 0,
Query OK, 1 row affected (0.11 sec)mysql> select customer_id,order_sn,order_id  from order_master order by order_id;
+-------------+----------+----------+
| customer_id | order_sn | order_id |
+-------------+----------+----------+
|           1 |        1 |        2 |
|           2 |        2 |        3 |
|           3 |        1 |        4 |
|           4 |        1 |        5 |
|           5 |        1 |        6 |
|           6 |        1 |        7 |
|           7 |        1 |        8 |
|           8 |        1 |        9 |
|           9 |        1 |       10 |
|          10 |        1 |       11 |
+-------------+----------+----------+
10 rows in set (0.03 sec)mysql> 

下一篇:企业实战_17_MyCat水平扩展_跨分片查询_ER分片
https://gblfy.blog.csdn.net/article/details/100066013

企业实战_16_MyCat全局自增ID相关推荐

  1. java 自定义自增_自定义全局自增ID生成器

    看了网上很多生成自增ID的策略,最终给出的都是雪花算法,leaf算法.但是却没有满足咱们对于自定义生成规则的需求. 在业务上有一部分ID往往是有规则的,比如某个产品的订单号往往是"产品标志+ ...

  2. 企业实战_15_MySql主从复制到MyCat总结

    接上一篇:企业实战_14_MyCat跨分片查询_全局表 https://gblfy.blog.csdn.net/article/details/100059621 文章目录 一.主从复制到MyCat总 ...

  3. 企业实战_17_MyCat水平扩展_跨分片查询_ER分片

    接上一篇:企业实战_16_MyCat全局自增ID https://blog.csdn.net/weixin_40816738/article/details/100064315 案例比较: 在垂直拆分 ...

  4. 企业实战_04_MyCat常用配置文件详解

    Mycat 常用配置文件,配置灵活,能应用于场景很多,建议根据应用场景去记忆,要理解! 接上一篇:企业实战_03_MyCat下载.安装.启动 https://gblfy.blog.csdn.net/a ...

  5. 企业实战_12_MyCat水平扩展_分库分表

    接上一篇:企业实战_11_MyCat垂直拆分相关配置 https://gblfy.blog.csdn.net/article/details/100055838 文章目录 一.概念理论理解 1. 垂直 ...

  6. MySQL 使用自增ID主键和UUID 作为主键的优劣比較具体过程(从百万到千万表记录測试)...

    測试缘由 一个开发同事做了一个框架.里面主键是uuid.我跟他建议说mysql不要用uuid用自增主键,自增主键效率高,他说不一定高,我说innodb的索引特性导致了自增id做主键是效率最好的,为了拿 ...

  7. MySQL 使用自增ID主键和UUID 作为主键的优劣比较详细过程(从百万到千万表记录测试)...

    Reference: https://blog.csdn.net/mchdba/article/details/52336203 一个开发同事做了一个框架,里面主键是uuid,我跟他建议说mysql不 ...

  8. 企业实战_10_Mycat集成ZK实现配置同步

    主机名 IP地址 角色 数据库 mycat 192.168.43.32 MYCAT ,MYSQL,ZK mycat(全局自增id) node1 192.168.43.104 ZKMYSQL order ...

  9. 企业实战_14_MyCat跨分片查询_全局表

    接上一篇:企业实战_13_MyCat清除冗余数据 https://gblfy.blog.csdn.net/article/details/100057317 文章目录 一.跨分片查询验证 1. 登录m ...

最新文章

  1. Example: Communication between Activity and Service using Messaging
  2. 【原】Linux设备网络硬件管理
  3. valid Palindrome -- leetcode
  4. 2016年10月20日 .NET Core 1.0.2 更新
  5. 如何进阶一名有竞争力的程序员?
  6. yield用法详解——最简单,最清晰的解释
  7. MSN Messenger协议简介
  8. 三菱伺服驱动器示例_三菱MRJB伺服放大器应用实例
  9. Python爬虫实战三之计算大学本学期绩点
  10. PHP+新浪微博开放平台+新浪云平台(SAE)
  11. 硬核3-D视觉 - 三维视觉简介
  12. android studio项目中将普通文件夹变成moudle
  13. hud 6078 Wavel Sequence
  14. C Primer Plus 第十二章 课后答案
  15. ARM Cortex-M处理器详解
  16. 纯CSS+HTML+JS实现的简易个人网站
  17. MFC中VC6.0工程项目中文乱码的显示处理
  18. 你手里期权值多少钱?写给上市公司的同学
  19. 斯坦福大学 Design School 所倡导设计思维的原则和步骤是什么?
  20. 麒麟操作系统(银河麒麟+中标麒麟)破解密码合集

热门文章

  1. 我们为什么要学数学?这里给你一个答案。
  2. 【转载保存】java 23种设计模式 深入理解
  3. HugeGraph 图数据库常见问题汇总
  4. Solr router 路由介绍
  5. opencv 图像访问索引
  6. 动态卡片:富媒体内容井喷式增长下,新一代移动端动态研发的模式
  7. IoT Studio可视化搭建平台编辑历史功能的思考与探索
  8. Serverless 工作流给人工智能带来了哪些变化?
  9. 性能为MySQL 10倍!阿里云推出云原生数据仓库AnalyticDB基础版
  10. Spring Cloud Alibaba迁移指南(四):零代码兼容 Api-Gateway 1