```sql
begin
DELETE FROM `binlog_inspector`.`emp` WHERE `id`=1
# datetime=2017-10-23_00:14:28 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=417 stoppos=575
commit
```
```sql
begin
# datetime=2017-10-23_00:14:28 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=417 stoppos=575
INSERT INTO `binlog_inspector`.`emp` (`id`,`name`,`sr`,`icon`,`points`,`sa`,`sex`) VALUES (1,張三1,華南理工大學(xué)&SCUT,X89504e47,1.1,1.1,1)
commit
```
1. 速度快。 解釋512MB的binlog:
--prefix-database
```sql
begin
# datetime=2017-10-23_00:14:34 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=21615 stoppos=22822
UPDATE `binlog_inspector`.`emp` SET `sa`=1001 WHERE `id`=5;
# datetime=2017-10-23_00:14:45 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=22822 stoppos=23930
UPDATE `binlog_inspector`.`emp` SET `name`=null WHERE `id`=5;
commit
```
```sql
begin
# datetime=2017-10-23_00:14:34 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=21615 stoppos=22822
UPDATE `emp` SET `sa`=1001 WHERE `id`=5;
# datetime=2017-10-23_00:14:45 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=22822 stoppos=23930
UPDATE .`emp` SET `name`=null WHERE `id`=5;
commit
```
--keep-trx
```sql
begin
# datetime=2017-10-23_00:14:34 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=21615 stoppos=22822
UPDATE `binlog_inspector`.`emp` SET `sa`=1001 WHERE `id`=5;
# datetime=2017-10-23_00:14:45 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=22822 stoppos=23930
UPDATE `binlog_inspector`.`emp` SET `name`=null WHERE `id`=5;
commit
```
```sql
# datetime=2017-10-23_00:14:34 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=21615 stoppos=22822
UPDATE `binlog_inspector`.`emp` SET `sa`=1001 WHERE `id`=5;
# datetime=2017-10-23_00:14:45 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=22822 stoppos=23930
UPDATE `binlog_inspector`.`emp` SET `name`=null WHERE `id`=5;
```
```sql
# datetime=2017-10-23_00:14:34 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=21615 stoppos=22822
UPDATE `binlog_inspector`.`emp` SET `sa`=1001 WHERE `id`=5;
# datetime=2017-10-23_00:14:45 database=binlog_inspector table=emp binlog=mysql-bin.000012 startpos=22822 stoppos=23930
UPDATE `binlog_inspector`.`emp` SET `name`=null WHERE `id`=5;
```
否則為:
```sql
UPDATE `binlog_inspector`.`emp` SET `sa`=1001 WHERE `id`=5;
UPDATE `binlog_inspector`.`emp` SET `name`=null WHERE `id`=5;
```
```sql
UPDATE `binlog_inspector`.`emp` SET `sa`=1001 WHERE `id`=5;
DELETE FROM `binlog_inspector` WHERE `id`=5;
```
--full-columns 則為
```sql
UPDATE `binlog_inspector`.`emp` SET `id`=5, `age`=21, `sex`=M,`sa`=1001, `name`=Danny WHERE `id`=5 and `age`=21 and `sex`=M and `sa`=900 and `name`=Danny;
DELETE FROM `binlog_inspector` WHERE `id`=5 and `age`=21 and `sex`=M and `sa`=900 and `name`=Danny;
```
```sql
create table emp (name varchar(50), sr text, points float, sa decimal(10,3), sex enum("f", "m"), icon blob)
alter table emp add column id int first
truncate table emp
alter table emp add primary key (id)
alter table emp modify id int auto_increment
alter TABLE emp add column updatetime datetime comment 更新時(shí)間, add createtime timestamp default current_timestamp comment 創(chuàng)建時(shí)間
alter TABLE emp drop column updatetime
```
```sql
CREATE TABLE `emp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`sr` text,
`points` float DEFAULT NULL,
`sa` decimal(10,3) DEFAULT NULL,
`sex` enum(f,m) DEFAULT NULL,
`icon` blob,
`createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 創(chuàng)建時(shí)間,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8
```
```sql
begin;
# datetime=2018-02-05_10:12:41 database=binlog_inspector table=emp binlog=mysql-bin.000001 startpos=1614 stoppos=1772
INSERT INTO `binlog_inspector`.`emp` (`id`,`name`,`sr`,`points`,`sa`,`sex`) VALUES (張三1,Xe58d8ee58d97e79086e5b7a5e5a4a7e5ada62653435554,1.100000023841858,1.1,1,X89504e47);
commit;
```
```sql
datetime binlog startpos stoppos sql
2018-02-05_10:12:18 mysql-bin.000001 1115 1320 create table emp (name varchar(50), sr text, points float, sa decimal(10,3), sex enum("f", "m"), icon blob)
2018-02-05_10:15:10 mysql-bin.000001 8556 8694 alter table emp add column id int first
2018-02-05_10:16:41 mysql-bin.000001 8759 8856 truncate table emp
2018-02-05_10:16:42 mysql-bin.000001 8921 9055 alter table emp add primary key (id)
2018-02-05_10:17:21 mysql-bin.000001 9120 9262 alter table emp modify id int auto_increment
2018-02-05_13:46:18 mysql-bin.000001 400409 400653 alter TABLE emp add column updatetime datetime comment 更新時(shí)間, add createtime timestamp default current_timestamp comment 創(chuàng)建時(shí)間
```
```json
{
"binlog_inspector.emp": {
"_/0/0": {
"database": "binlog_inspector",
"table": "emp",
"columns": [
{
"column_name": "id",
"column_type": "int"
},
{
"column_name": "name",
"column_type": "varchar"
},
{
"column_name": "sr",
"column_type": "text"
},
{
"column_name": "points",
"column_type": "float"
},
{
"column_name": "sa",
"column_type": "decimal"
},
{
"column_name": "sex",
"column_type": "enum"
},
{
"column_name": "icon",
"column_type": "blob"
},
{
"column_name": "createtime",
"column_type": "timestamp"
}
],
"primary_key": [
"id"
],
"unique_keys": [],
"ddl_info": {
"binlog": "_",
"start_position": 0,
"stop_position": 0,
"ddl_sql": ""
}
}
}
}
```
```json
{
"binlog_inspector.emp": {
"mysql-bin.000001/8556/8694": {
"database": "binlog_inspector",
"table": "emp",
"columns": [
{
"column_name": "name",
"column_type": "varchar"
},
{
"column_name": "sr",
"column_type": "text"
},
{
"column_name": "points",
"column_type": "float"
},
{
"column_name": "sa",
"column_type": "decimal"
},
{
"column_name": "sex",
"column_type": "enum"
},
{
"column_name": "icon",
"column_type": "blob"
}
],
"primary_key": [],
"unique_keys": [],
"ddl_info": {
"binlog": "mysql-bin.000001",
"start_position": 8556,
"stop_position": 8694,
"ddl_sql": ""
}
},
"_/0/0": {
"database": "binlog_inspector",
"table": "emp",
"columns": [
{
"column_name": "id",
"column_type": "int"
},
{
"column_name": "name",
"column_type": "varchar"
},
{
"column_name": "sr",
"column_type": "text"
},
{
"column_name": "points",
"column_type": "float"
},
{
"column_name": "sa",
"column_type": "decimal"
},
{
"column_name": "sex",
"column_type": "enum"
},
{
"column_name": "icon",
"column_type": "blob"
},
{
"column_name": "createtime",
"column_type": "timestamp"
}
],
"primary_key": [
"id"
],
"unique_keys": [],
"ddl_info": {
"binlog": "_",
"start_position": 0,
"stop_position": 0,
"ddl_sql": ""
}
}
}
}
```
```sql
begin;
# datetime=2018-02-05_10:12:41 database=binlog_inspector table=emp binlog=mysql-bin.000001 startpos=1614 stoppos=1772
INSERT INTO `binlog_inspector`.`emp` (`name`,`sr`,`points`,`sa`,`sex`,`icon`) VALUES (張三1,**理工大學(xué)&SCUT,1.100000023841858,1.1,1,X89504e47);
commit;
```
./binlog_inspector --mode=repl --wtype=2sql --mtype=mysql --
threads=4 --serverid=3331 --host=127.0.0.1 --port=330 --
user=xxx --password=xxx --databases=db1,db2 --tables=tb1,tb2
--start-binlog=mysql-bin.000556 --start-pos=107 --stop-
binlog=mysql-bin.000559 --stop-pos=4 --min-columns --file-
each-table --insert-rows=20 --keep-trx --big-trx-rows=100 --
long-trx-seconds=10 --output-dir=/home/apps/tmp --table-
columns tbs_all_def.json
./binlog_inspector --mode=file --wtype=rollback --
mtype=mysql --threads=4 --host=127.0.0.1 --port=3306 --
user=xxx --password=xxx --databases=db1,db2 --tables=tb1,tb2
--start-datetime=2017-09-28 13:00:00 --stop-
datetime=2017-09-28 16:00:00 --min-columns --file-each-
table --insert-rows=20 --keep-trx --big-trx-rows=100 --long-
trx-seconds=10 --output-dir=/home/apps/tmp --table-columns
tbs_all_def.json /apps/dbdata/mysqldata_3306/log/mysql-
bin.000556
./binlog_inspector --mode=file --wtype=stats --mtype=mysql -
-interval=20 --big-trx-rows=100 --long-trx-seconds=10 --
output-dir=/home/apps/tmp mysql-bin.000556
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://m.specialneedsforspecialkids.com/yun/129710.html
摘要:不會(huì)記錄數(shù)據(jù)表的列名在接下來(lái)的實(shí)現(xiàn)中,我們會(huì)將自己的系統(tǒng)包裝成一個(gè)假的,通過(guò)開(kāi)源工具來(lái)實(shí)現(xiàn)監(jiān)聽(tīng)。因?yàn)槲覀冎恍枰械膬?nèi)容,那么我們也就只需要通過(guò)實(shí)現(xiàn)接口,來(lái)自定義一個(gè)監(jiān)聽(tīng)器實(shí)現(xiàn)我們的業(yè)務(wù)即可。 MySQL Binlog簡(jiǎn)介 什么是binlog? 一個(gè)二進(jìn)制日志,用來(lái)記錄對(duì)數(shù)據(jù)發(fā)生或潛在發(fā)生更改的SQL語(yǔ)句,并以而進(jìn)行的形式保存在磁盤中。 binlog 的作用? 最主要有3個(gè)用途: ...
閱讀 1353·2023-01-11 13:20
閱讀 1699·2023-01-11 13:20
閱讀 1211·2023-01-11 13:20
閱讀 1904·2023-01-11 13:20
閱讀 4161·2023-01-11 13:20
閱讀 2751·2023-01-11 13:20
閱讀 1397·2023-01-11 13:20
閱讀 3664·2023-01-11 13:20