亿级流量点赞系统第六章
项目地址
GitHub地址💥:https://github.com/tenyon61/likeboom
后端初始化模板💥:https://github.com/tenyon61/springboot3-demo/tree/single
快速开始
✨方案选型
选用TiDB数据库替代MySQL
✨部署TiDB
💥腾讯云按量收费

💥执行安装
▼shell复制代码curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
安装成功

立即生效
▼shell复制代码source /root/.bashrc
💥启动数据库
▼shell复制代码tiup playground --tag thumb
启动成功

💥反代控制台
使用1panel面板,教程链接:https://www.codefather.cn/post/1912901809601032194

成功登录

✨数据迁移
💥导出MySQL脚本

💥连接TiDB

💥执行脚本

💥功能验证
▼yaml复制代码spring: datasource: url: jdbc:mysql://${datasource.mysql.host}:4000/likeboom username: ${datasource.mysql.username} password: ${datasource.mysql.password} driver-class-name: com.mysql.cj.jdbc.Driver hikari: pool-name: HikariCPDatasource minimum-idle: 5 idle-timeout: 180000 maximum-pool-size: 10 auto-commit: true max-lifetime: 1800000 connection-timeout: 30000 connection-test-query: SELECT 1
如果没用权限需要给root用户授权
▼shell复制代码GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
执行点赞,成功入库

本章总结
了解和使用TiDB,同时实操将数据库从MySQL丝滑迁移到TiDB,增强水平扩展能力,确保数据强一致性。
项目踩坑
- 本地windows访问有问题需要修改配置
/root/.tiup/data/thumb/tidb-0/tidb.toml
▼toml复制代码[security] auto-tls = true [server] host = "0.0.0.0" port = 4000
使用命令
▼shell复制代码tiup playground --tag thumb --db.host 0.0.0.0
评论
问答助学
相关内容
0个评论
全部评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
