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

iis默认网站停止最权威的品牌排行榜网站

iis默认网站停止,最权威的品牌排行榜网站,河南网站推广优化排名,网站底部优化字什么是数据分片#xff1f; 简单来说#xff0c;就是指通过某种特定的条件#xff0c;将我们存放在同一个数据库中的数据分散存放到多个数据库#xff08;主机#xff09;上面#xff0c;以达到分散单台设备负载的效果。 数据的切分#xff08;Sharding#xff09;根据… 什么是数据分片 简单来说就是指通过某种特定的条件将我们存放在同一个数据库中的数据分散存放到多个数据库主机上面以达到分散单台设备负载的效果。 数据的切分Sharding根据其切分规则的类型可以分为两种切分模式 垂直纵向切分是按照不同的表或者 Schema来切分到不同的数据库主机之上 水平横向切分是根据表中的数据的逻辑关系将同一个表中的数据按照某种条件拆分到多台数据库主机上面。 注意分库分表必须是干净的库和表不能有数据 分片原则 能不切分尽量不要切分。数据量不是很大的库或者表尽量不要分片。 尽量按照功能模块分库避免跨库join。 项目中可以使用ShardingSphere-JDBC加载不同库中的表进行操作 一、准备服务器 服务器规划使用docker方式创建如下容器 主服务器容器名server-user端口3301从服务器容器名server-order端口3302 1. 创建server-user容器 1创建容器 docker run -d \ -p 3301:3306 \ -v /liush/server/user/conf:/etc/mysql/conf.d \ -v /liush/server/user/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORDroot \ --name server-user \ mysql:8.0.29 2登录MySQL服务器 ① 进入容器     docker exec -it server-user env LANGC.UTF-8 /bin/bash ② 进入容器内的mysql命令行     mysql -uroot -proot ③ 修改默认密码插件     ALTER USER root% IDENTIFIED WITH mysql_native_password BY root; 3创建数据库 CREATE DATABASE db_user; USE db_user; CREATE TABLE t_user (id BIGINT AUTO_INCREMENT,uname VARCHAR(30),PRIMARY KEY (id) ); 2. 创建server-order容器 1创建容器 docker run -d \ -p 3302:3306 \ -v /liush/server/order/conf:/etc/mysql/conf.d \ -v /liush/server/order/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORDroot \ --name server-order \ mysql:8.0.29 2登录MySQL服务器 ① 进入容器 docker exec -it server-order env LANGC.UTF-8 /bin/bash ② 进入容器内的mysql命令行 mysql -uroot -proot ③ 修改默认密码插件 ALTER USER root% IDENTIFIED WITH mysql_native_password BY root; 3创建数据库 CREATE DATABASE db_order; USE db_order; CREATE TABLE t_order (id BIGINT AUTO_INCREMENT,order_no VARCHAR(30),user_id BIGINT,amount DECIMAL(10,2),PRIMARY KEY(id) ); 二、程序实现 1. 创建实体类 TableName(t_order) Data public class Order {TableId(type IdType.AUTO)private Long id;private String orderNo;private Long userId;private BigDecimal amount; } 2. 创建Mapper Mapper public interface OrderMapper extends BaseMapperOrder { } 3. 配置垂直分片 垂直拆分 从不同的库中加载多张不同的表在一个项目中使用 # 应用名称 spring.application.namesharding-jdbc-demo # 环境设置 spring.profiles.activedev# 配置真实数据源 spring.shardingsphere.datasource.namesserver-user,server-order# 配置第 1 个数据源 spring.shardingsphere.datasource.server-user.typecom.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.server-user.driver-class-namecom.mysql.jdbc.Driver spring.shardingsphere.datasource.server-user.urljdbc:mysql://192.168.100.201:3301/db_user spring.shardingsphere.datasource.server-user.usernameroot spring.shardingsphere.datasource.server-user.passwordroot# 配置第 2 个数据源 spring.shardingsphere.datasource.server-order.typecom.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.server-order.driver-class-namecom.mysql.jdbc.Driver spring.shardingsphere.datasource.server-order.urljdbc:mysql://192.168.100.201:3302/db_order spring.shardingsphere.datasource.server-order.usernameroot spring.shardingsphere.datasource.server-order.passwordroot# 标准分片表配置数据节点 # table-name逻辑表名匹配 数据源名.真实表 #spring.shardingsphere.rules.sharding.tables.table-name.actual-data-nodes # 由数据源名 表名组成以小数点分隔。 spring.shardingsphere.rules.sharding.tables.t_user.actual-data-nodesserver-user.t_user spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodesserver-order.t_order # 打印SQL spring.shardingsphere.props.sql-showtrue user库order主库从库两个如下配置 # 配置真实数据源 spring.shardingsphere.datasource.namesserver-user,server-order# 配置第 1 个数据源user库的数据源 spring.shardingsphere.datasource.server-user.typecom.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.server-user.driver-class-namecom.mysql.jdbc.Driver spring.shardingsphere.datasource.server-user.urljdbc:mysql://192.168.1.171:3326/db_user spring.shardingsphere.datasource.server-user.usernameroot spring.shardingsphere.datasource.server-user.password123456# 配置第 2 个数据源:order库的数据源(order库可以配置读写分离) spring.shardingsphere.datasource.server-order.typecom.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.server-order.driver-class-namecom.mysql.jdbc.Driver spring.shardingsphere.datasource.server-order.urljdbc:mysql://192.168.1.171:3316/mydb3 spring.shardingsphere.datasource.server-order.usernameroot spring.shardingsphere.datasource.server-order.password123456# 标准分片表配置数据节点 # table-name逻辑表名匹配 数据源名.真实表 #spring.shardingsphere.rules.sharding.tables.table-name.actual-data-nodes # 由数据源名 表名组成以小数点分隔。 spring.shardingsphere.rules.sharding.tables.t_user.actual-data-nodesserver-user.t_user spring.shardingsphere.rules.sharding.tables.t_account.actual-data-nodesserver-user.t_account spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodesserver-order.t_order # 打印SQL spring.shardingsphere.props.sql-showtrue# 为订单库 mydb3配置读写分离 # 配置第 2 个数据源的salve1数据源 spring.shardingsphere.datasource.order-slave1.typecom.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.order-slave1.driver-class-namecom.mysql.jdbc.Driver spring.shardingsphere.datasource.order-slave1.urljdbc:mysql://192.168.1.171:3307/mydb3 spring.shardingsphere.datasource.order-slave1.usernameroot spring.shardingsphere.datasource.order-slave1.password123456 # 配置第 2 个数据源的salve2数据源 spring.shardingsphere.datasource.order-slave2.typecom.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.order-slave2.driver-class-namecom.mysql.jdbc.Driver spring.shardingsphere.datasource.order-slave2.urljdbc:mysql://192.168.1.171:3308/mydb3 spring.shardingsphere.datasource.order-slave2.usernameroot spring.shardingsphere.datasource.order-slave2.password123456 ## 读写分离配置 # 读写分离类型如: StaticDynamic # Static数据源在配置文件中是直接配置的 # Dynamic数据源是由程序动态读取的 spring.shardingsphere.rules.readwrite-splitting.data-sources.myds.typeStatic # 写数据源名称 spring.shardingsphere.rules.readwrite-splitting.data-sources.myds.props.write-data-source-nameserver-order # 读数据源名称多个从数据源用逗号分隔 spring.shardingsphere.rules.readwrite-splitting.data-sources.myds.props.read-data-source-namesserver-order,order-slave1,order-slave2 # 负载均衡算法名称 spring.shardingsphere.rules.readwrite-splitting.data-sources.myds.load-balancer-namealg_round # 负载均衡算法配置 # 负载均衡算法类型ROUND_ROBIN、RANDOM、WEIGHT spring.shardingsphere.rules.readwrite-splitting.load-balancers.alg_round.typeROUND_ROBIN # 负载均衡算法属性配置typeWEIGHT 的时候配置 #spring.shardingsphere.rules.readwrite-splitting.load-balancers.alg_weight.props.slave11 #spring.shardingsphere.rules.readwrite-splitting.load-balancers.alg_weight.props.slave21 三、测试垂直分片 SpringBootTest public class ShardingTest {Autowiredprivate UserMapper userMapper;Autowiredprivate OrderMapper orderMapper;/*** 垂直分片* user数据自动写入server-user服务器的的t_user表* order数据自动写入server-order服务器的的t_order表*/Testpublic void testInsert1(){User user new User();user.setUname(helen);userMapper.insert(user);Order order new Order();order.setOrderNo(ATGUIGU);order.setAmount(new BigDecimal(100));order.setUserId(user.getId());orderMapper.insert(order);} }
http://www.w-s-a.com/news/891887/

相关文章:

  • 网站群建设代理丰城网站建设公司
  • 青岛网站建设服务器wordpress迁移跳转原网站
  • 泰安网站建设哪里有公司如何注册网站
  • 做网站开专票税钱是多少个点上海市有哪些公司
  • 寿县有做网站开发的吗宁波网站建设方式
  • 网站建设和网站推广服务器怎么发布网站
  • 比较好的摄影网站雅安市政建设公司网站
  • 网站与微信区别wordpress 站内信
  • 宁夏网站开发设计说明书源码下载脚本之家
  • 邱县做网站百度搜索排名机制
  • 运城个人网站建设智慧团建系统官方网站登录
  • 公司营业执照可以做几个网站一家专门做母婴的网站
  • 网站建设商标属于哪个类别搜狗seo快速排名公司
  • 织梦做商城网站企业网络建站
  • 网站后期维护都有什么wordpress首页加图片
  • 展会网站怎么做网页设计与制作教程版徐洪亮课后答案
  • 石景山网站建设设计公司建设网站怎么建立服务器
  • 本地生活服务平台app网站关键词优化原理
  • 建网站的公司叫什么重庆论坛建站模板
  • 湖北网站制作公司银川网站建设哪家不错
  • 网站后台演示地址服装网站建设公司推荐
  • 湖北钟祥建设局网站旅游哪个网站最好
  • 浙江建设工程信息网站辽宁建设工程信息网场内业绩什么意思
  • 郑州做网站公司 汉狮网络专业图片搜集网站怎么做
  • 网站托管是什么品牌推广营销平台
  • 制作网站的难度贵州省兴义市建设局网站
  • 永春建设局网站室内设计师培训班学费多少
  • 做仿站如何获取网站源码windows2012做网站
  • 网站建设最好的公司东莞外贸网站
  • 普兰店网站建设一般做网站什么价格