# spring-sharding-demo **Repository Path**: buptnetwork/spring-sharding-demo ## Basic Information - **Project Name**: spring-sharding-demo - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-04-19 - **Last Updated**: 2022-04-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 工程简介 本项目演示使用apache shardingsphere进行数据分片和读写分离 ## 数据分片配置 1. 在application.yml中配置active: sharding 2. 在本地MySQL服务器上创建ds0、ds1两个数据库 3. 在数据库中创建product表和comment表,建表语句为resources/sharding-schema.sql 4. 修改配置文件application-sharding.yml中的数据源配置,如本地MySQL数据库用户及密码等 5. 启动SpringShardingDemoApplication ## 读写分离配置 1. 在application.yml中配置active: master-slave 2. 在本地MySQL服务器上创建master、slave0、slave1三个数据库 3. 在数据库中创建product表和comment表,建表语句为resources/master-slave.sql 4. 修改配置文件application-master-slave.yml中的数据源配置,如本地MySQL数据库用户及密码等 5. 启动SpringShardingDemoApplication # 延伸阅读