-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
187 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Download | ||
|
||
Click "Download Here" to download OpenTenBase | ||
|
||
| Kernel | Download URL | | ||
| -------- | --------------- | | ||
| TBase | [Download Here](https://github.com/OpenTenBase/OpenTenBase/tags) | | ||
| TXSQL | [Download Here](https://github.com/OpenTenBase/TXSQL/tags) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 下载 | ||
请点击如下链接下载 | ||
|
||
| 内核 | 下载地址 | | ||
| ----- | ------- | | ||
| TBase | [点击下载](https://github.com/OpenTenBase/OpenTenBase/tags) | | ||
| TXSQL | [点击下载](https://github.com/OpenTenBase/TXSQL/tags) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
# 常见问题 | ||
|
||
1. 强同步等待ack超过sqlasyntimeout(默认30s)后的错误提示 | ||
|
||
```sql | ||
ERROR 1613 (XA106): The transaction is in doubt. Please check whether the transaction has been committed. | ||
``` | ||
|
||
2. 大事务产生的binlog超过binlog_write_threshold(默认1610612736)后错误提示: | ||
|
||
```sql | ||
ERROR 4040 (HY000): binlog write threshold(xxx) exceeded, the transaction has xxx (bytes) binlogs, it is aborted. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# TXSQL概述 | ||
TXSQL 是腾讯数据库团队基于社区MySQL定制的企业级MySQL内核,100%兼容原生 MySQL 版本,并提供了类似于 MySQL 企业版的诸多功能,如审计、线程池、备份恢复等功能。 | ||
|
||
TXSQL 不仅对 InnoDB 存储引擎、查询优化、复制性能等方面进行了大量优化,同时提升了云数据库 MySQL 的易用性和可维护性,在为用户提供 MySQL 全部功能的同时,还提供了企业级的性能优化、数据压缩、加密、强同步、全局一致性等高级特性。 | ||
|
||
当前TXSQL内核广泛应用于金融、游戏、电商、新能源等各行各业的核心业务场景中。 | ||
|
||
## 核心特性简介 | ||
TXSQL基于广泛的业务需求,自主实现大量的企业级特性,下面进行示例介绍。 | ||
|
||
1. 强同步 | ||
|
||
作为金融级分布式数据库,数据的强一致是生命线。而原生的MySQL的同步复制是半同步或异步,无法满足金融场景的需要,因此TXSQL基于raft协议自研强同步方案,在保证数据强一致的同时尽可能提高性能。 | ||
|
||
2. 线程池 | ||
|
||
社区版的MySQL的连接处理方法默认是为每个连接创建一个工作线程的one-thread-per-connection(Per_thread)模式。这种模式下,由于系统的资源是有限的,随着连接数的增加,资源的竞争也增加,连接的响应时间也随之增加,如response time图所示。对于数据库整体吞吐而言,则是在资源未耗尽时随着连接数增加,一旦连接数超过了某个耗尽系统资源的临界点,数据库整体吞吐就会各连接的资源争抢而下降。 | ||
|
||
TXSQL通过实现线程池,来避免因资源竞争而导致系统吞吐下降的问题。 | ||
|
||
线程池的思路即为限制同时运行的线程数,减少线程池间上下文切换和热锁争用,从而对OLTP工作负载(CPU消耗较少的查询)产生积极影响。当连接数上升时,在线程池的帮助下数据库整体吞吐维持在一个较高水准。 | ||
|
||
3. 全局一致性事务 | ||
|
||
社区MySQL只能保证单节点事务的ACID,但分布式场景下,通常一个集群会有多个MySQL实例。TXSQL通过自研的全局一致性时钟方案,保证集群中各个TXSQL实例的全局数据一致性。 | ||
|
||
4. 审计 | ||
|
||
TXSQL提供数据库审计能力,记录对数据库的访问及 SQL 语句执行情况(包括语句开启时间、扫描行数、锁等待时间、 CPU 使用时间、客户端 IP、用户名、SQL 内容等),帮助企业进行风险控制,提高数据安全等级。主要适用于需要对数据库遭受到的风险行为进行告警,针对数据库 SQL 注入、异常操作等数据库风险行为进行记录与告警的场景。 | ||
|
||
5. 列压缩 | ||
|
||
当前有针对行格式的压缩和针对数据页面的压缩,但是这两种压缩方式在处理一个表中的某些大字段和其他很多小字段,同时对小字段的读写很频繁,对大字段访问不频繁的情形中,在读写访问时都会造成很多不必要的计算资源的浪费。 | ||
|
||
列压缩功能可以压缩那些访问不频繁的大字段而不压缩那些访问频繁的小字段,这样不仅能够减少整行字段的存储空间,而且可以提高读写访问的效率。 | ||
|
||
例如,一张员工表:`create table employee(id int, age int, gender boolean, other varchar(1000) primary key (id))`,当对 id,age,gender 小字段访问比较频繁,而对 other 大字段的访问频率比较低时,可以将 other 列创建为压缩列。一般情况下,只有对 other 的读写才会触发对该列的压缩和解压,对其他列的访问并不会触发该列的压缩和解压。由此进一步降低了行数据存储的大小,使得对访问频繁的小字段能够实现更快访问,对访问频率比较低的大字段的存储空间能够实现进一步降低。 | ||
|
||
6. XA事务增强 | ||
|
||
TXSQL应用在金融场景,对XA事务数据一致性要求极高。通过持续打磨XA事务,提供XA事务性能,其中10+特性已回馈社区。 | ||
|
||
7. 空闲事务主动断连 | ||
|
||
TXSQL对于处于开启事务状态的连接(显示使用 begin、start transaction 或者隐式开启事务),如果超时时间内没有下一条语句执行,会kill 连接,以释放资源提升性能。 | ||
|
||
8. returning支持 | ||
|
||
在某些使用场景下,需要在 DML 操作后返回刚操作的数据行。实现这个需求一般有两种办法: | ||
|
||
一是在开启事务后在 DML 语句后紧跟一条 SELECT 语句。 | ||
|
||
二是使用触发器等较为复杂的操作实现。 | ||
|
||
前者主要会增加一条 SELECT 语句的开销,后者则会令 SQL 的实现变得更加复杂并且不够灵活(需要创建触发器)。 因此,RETURNING 语法的设计主要针对该场景的优化,通过在 DML 语句后增加 RETURNING 关键字可以灵活高效地实现上述的需求。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# TXSQL 安装指南 | ||
|
||
## 部署方案介绍 | ||
|
||
本文档适用于基于TXSQL分别在基于x86(64)芯片、基于ARM(鲲鹏920)系列芯片上的CentOS7.8、7.9,TencentOS Server,银河麒麟操作系统V10,如下表。 | ||
|
||
|CPU | 操作系统 | | ||
| ----- | ------- | | ||
| X86_64 | CentOS 7.8、7.9(含补丁),TencentOS Server| | ||
|ARM(aarch64)鲲鹏920系列 | 银河麒麟V10(含补丁)| | ||
|
||
## 编译TXSQL | ||
|
||
### 安装依赖 | ||
|
||
```bash | ||
# yum install -y git ncurses-devel bison cmake3 libaio-devel openssl openssl-devel cyrus-sasl-devel openldap-devel gtest libtirpc-devel | ||
|
||
### gcc | ||
# yum install centos-release-scl -y | ||
# yum install devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-binutils -y | ||
``` | ||
|
||
## 编译流程 | ||
|
||
选择tdsql-develop-8.0.18分支 | ||
|
||
```bash | ||
# cd tdsql/ | ||
|
||
### -t 可选择debug和release模式 | ||
# bash make.sh -t release -r 1 | ||
``` | ||
|
||
编译生成的TXSQL二进制包,是存在代码库tdsql/mysql_install目录下 | ||
|
||
## 安装和卸载TXSQL | ||
|
||
### 安装TXSQL | ||
|
||
TXSQL在mysql-server-8.0.18的install目录下,有封装的install_mysql_innodb.sh脚本可以用于快速安装 | ||
|
||
```bash | ||
# cd ./install | ||
# export change_ip_before_use=$ip;bash ./install_mysql_innodb.sh default mysql $port $bpsize $datadir $logdir "character_set_server=utf8&collation_server=utf8_general_ci&lower_case_table_names=1" | ||
``` | ||
|
||
- $ip:部署所在的本机物理ip,如:192.168.1.1 | ||
- $port:指定TCP/IP连接监听的端口号,如:4001 | ||
- $bpsize:innodb_buffer_pool_size配置,如:96000M | ||
- $datadir:存储数据路径,如:/data2/tdsql/data | ||
- $logdir:存储日志路径,如:/data2/tdsql/log | ||
|
||
执行脚本后,有如下信息返回,则表示安装成功 | ||
```bash | ||
... | ||
+---------------------+ | ||
| now() | | ||
+---------------------+ | ||
| xxxx-xx-xx xx:xx:xx | | ||
+---------------------+ | ||
+----------------------------------+ | ||
| version() | | ||
+----------------------------------+ | ||
| 8.0.xx-v18-txsql-xx.x.x-xxxxxxxx | | ||
+----------------------------------+ | ||
START SUCCESS. | ||
[xxxx-xx-xx xx:xx:xx] installing finished:xxxx! | ||
``` | ||
### 卸载TXSQL | ||
|
||
卸载会清理该节点的所有binlog和数据,谨慎执行 | ||
|
||
```bash | ||
# cd ./install | ||
# ./uninstall_mysql.sh $port | ||
``` | ||
|
||
- $port:安装TXSQL时指定的监听端口号,如:4001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters