emphasize proxy_heart_beat creation

This commit is contained in:
liuyanlei25 2018-09-20 17:11:13 +08:00
parent 1d393b5cfe
commit ea29096890
4 changed files with 7 additions and 5 deletions

View File

@ -68,12 +68,14 @@ create database if not exists proxy_heart_beat;
use proxy_heart_beat; use proxy_heart_beat;
CREATE TABLE if not exists `tb_heartbeat` ( CREATE TABLE if not exists `tb_heartbeat` (
`p_id` varchar(128) NOT NULL , `p_id` varchar(128) NOT NULL ,
`p_ts` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `p_ts` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
PRIMARY KEY (`p_id`) PRIMARY KEY (`p_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
GRANT ALL ON `proxy_heart_beat`.* TO 'cetus_app'@'192.0.0.1'; GRANT ALL ON `proxy_heart_beat`.* TO 'cetus_app'@'192.0.0.1';
**注意创建心跳表时p_ts精度必须到小数点后否则会影响主从延迟检测的准确度**
## sharding版MySQL环境准备 ## sharding版MySQL环境准备
若使用sharding功能则需要根据业务创建业务表并进行分库设计,若开启主从延迟检测,请参考读写分离版本配置心跳库和心跳表。 若使用sharding功能则需要根据业务创建业务表并进行分库设计,若开启主从延迟检测,请参考读写分离版本配置心跳库和心跳表。

View File

@ -20,7 +20,7 @@ Cetus 读写分离版将前端发来的读请求和写请求分别发送到不
CREATE TABLE tb_heartbeat ( CREATE TABLE tb_heartbeat (
p_id varchar(128) NOT NULL, p_id varchar(128) NOT NULL,
p_ts timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), p_ts timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
PRIMARY KEY (p_id) PRIMARY KEY (p_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8; ) ENGINE = InnoDB DEFAULT CHARSET = utf8;

View File

@ -7,7 +7,7 @@ SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `tb_heartbeat`; DROP TABLE IF EXISTS `tb_heartbeat`;
CREATE TABLE `tb_heartbeat` ( CREATE TABLE `tb_heartbeat` (
`p_id` varchar(128) NOT NULL, `p_id` varchar(128) NOT NULL,
`p_ts` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `p_ts` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
PRIMARY KEY (`p_id`) PRIMARY KEY (`p_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -487,9 +487,9 @@ update_master_timestamp(int fd, short what, void *arg)
/* Catch RW time /* Catch RW time
* Need a table to write from master and read from slave. * Need a table to write from master and read from slave.
* CREATE TABLE `tb_heartbeat` ( * CREATE TABLE if not exists `tb_heartbeat` (
* `p_id` varchar(128) NOT NULL, * `p_id` varchar(128) NOT NULL,
* `p_ts` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), * `p_ts` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
* PRIMARY KEY (`p_id`) * PRIMARY KEY (`p_id`)
* ) ENGINE = InnoDB DEFAULT CHARSET = utf8; * ) ENGINE = InnoDB DEFAULT CHARSET = utf8;
*/ */