当前位置: 首页 > news >正文

企业网站建设费用网络营销活动方案

企业网站建设费用,网络营销活动方案,网站建设公司推广方式,苏州市吴中区住房和城乡建设局网站备注:测试数据库版本为MySQL 8.0 这个blog我们来聊聊MySQL 延迟复制 概述 MySQL的复制一般都很快,虽然有时候因为 网络原因、大事务等原因造成延迟,但是这个无法人为控制。 生产中可能会存在主库误操作,导致数据被删除了,Oracl…

备注:测试数据库版本为MySQL 8.0

这个blog我们来聊聊MySQL 延迟复制

概述

MySQL的复制一般都很快,虽然有时候因为 网络原因、大事务等原因造成延迟,但是这个无法人为控制。
生产中可能会存在主库误操作,导致数据被删除了,Oracle有flashback技术,MySQL官方目前没有退出对应的flashback技术。
此时,我们可以通过设置延迟复制,设置从库比主库慢半个小时,这个时候就可以从从库进行数据恢复到主库了。

MySQL支持延迟复制,以便从库故意执行比主库晚至少在指定时间间隔的事务。在MySQL 8.0中,延迟复制的方法取决于两个时间戳:immediate_commit_timestamp和original_commit_timestamp。如果复制拓扑中的所有服务器都运行MySQL 8.0.1或更高版本,则使用这些时间戳测量延迟复制。如果从库未使用这些时间戳,则执行MySQL 5.7的延迟复制。

复制延迟默认为0秒。使用CHANGE MASTER TO MASTER_DELAY = N语句将延迟设置为N秒。从主库接收的事务比主库上的提交至少晚N秒才在从库上执行。每个事务发生延迟(不是以前MySQL版本中的事件),实际延迟仅强制在gtid_log_event或anonymous_gtid_log_event事件上。二进制日志中的每个GTID事务始终都以Gtid_log_event开头,匿名事务没有分配GTID,MySQL确保日志中的每个匿名事务都以Anonymous_gtid_log_event开头。对于事务中的其它事件,不会对它们施加任何等待时间,而是立即执行。注意,START SLAVE和STOP SLAVE立即生效并忽略任何延迟,RESET SLAVE将延迟重置为0。

延迟复制测试

环境要求

服务器类别IP
主库192.168.10.102
从库192.168.10.103
mysql> show slave status\G;
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.10.102Master_User: repllMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000019Read_Master_Log_Pos: 5280Relay_Log_File: hadoop103-relay-bin.000003Relay_Log_Pos: 1316Relay_Master_Log_File: mysql-bin.000019Slave_IO_Running: Yes Slave_SQL_Running: Yes

 此时已经搭建了异步复制的主从

开启延迟复制

从库

stop slave sql_thread;
CHANGE MASTER TO MASTER_DELAY = 3000;
start slave sql_thread;

主库

create table t6 as select * from dept;
select * from t6;
mysql>  create table t6 as select * from t4; 
Query OK, 1 row affected (0.02 sec)
Records: 1  Duplicates: 0  Warnings: 0mysql> 
mysql> select * from t6;
+--------+------------+----------+
| deptno | dname      | loc      |
+--------+------------+----------+
|     10 | ACCOUNTING | NEW YORK |
|     20 | RESEARCH   | DALLAS   |
|     30 | SALES      | CHICAGO  |
|     34 | faddsf     | fadsf    |
|     40 | OPERATIONS | BOSTON   |
+--------+------------+----------+
5 rows in set (0.00 sec)

从库

mysql> select remaining_delay from performance_schema.replication_applier_status;
+-----------------+
| remaining_delay |
+-----------------+
|            300 |
+-----------------+
1 row in set (0.01 sec)
mysql> select current_timestamp;
+---------------------+
| current_timestamp   |
+---------------------+
| 2020-07-29 11:00:44 |
+---------------------+
1 row in set (0.00 sec)mysql> select * from t6;
ERROR 1146 (42S02): Table 'test.t6' doesn't exist
mysql> 
mysql>  select current_timestamp;
+---------------------+
| current_timestamp   |
+---------------------+
| 2020-07-29 11:03:30 |
+---------------------+
1 row in set (0.00 sec)mysql> select * from t6;
ERROR 1146 (42S02): Table 'test.t6' doesn't exist
mysql> 
mysql> select current_timestamp;
+---------------------+
| current_timestamp   |
+---------------------+
| 2020-07-29 11:05:29 |
+---------------------+
1 row in set (0.00 sec)mysql> select * from t6;
+------+------+
| id   | name |
+------+------+
|    1 | aaa  |
+------+------+
1 row in set (0.00 sec)
mysql> select remaining_delay from performance_schema.replication_applier_status;
+-----------------+
| remaining_delay |
+-----------------+
|            NULL |
+-----------------+
1 row in set (0.01 sec)

监控延迟复制

在MySQL 8之前的老版本中,监控复制的延迟(滞后)最常用的方法之一是依赖于show slave status输出中的seconds_behind_master字段。但是,当使用比传统主从复制更复杂的复制拓扑,例如组复制时,此度量标准不再适用。MySQL 8中添加的immediate_commit_timestamp和original_commit_timestamp可提供有关复制延迟的更精细的信息。监控支持这些时间戳的复制延迟的推荐方法是使用以下performance_schema模式中的表。

replication_connection_status:与主服务器连接的当前状态,提供有关连接线程排队到中继日志中的最后和当前事务的信息。
replication_applier_status_by_coordinator:协调器线程的当前状态,仅在使用多线程复制时显示该信息,提供有关协调器线程缓冲到工作队列的最后一个事务的信息,以及当前正在缓冲的事务。
replication_applier_status_by_worker:应用从主服务器接收事务的线程的当前状态,提供有关应用程序线程或使用多线程复制时每个工作线程应用的事务信息。
使用这些表,可以监控相应线程处理的最后一个事务以及该线程当前正在处理的事务的信息,包括:

事务的GTID。
从库中继日志中检索的事务的original_commit_timestamp和immediate_commit_timestamp。
线程开始处理事务的时间。
对于上次处理的事务,线程完成处理它的时间。
除Performance Schema表之外,show slave status的输出还有三个字段与延迟复制有关:

SQL_Delay:非负整数,表示使用CHANGE MASTER TO MASTER_DELAY = N配置的复制延迟,以秒为单位。与performance_schema.replication_applier_configuration.desired_delay值相同。
SQL_Remaining_Delay:当Slave_SQL_Running_State等待主执行事件后的MASTER_DELAY秒时,该字段包含一个整数,表示延迟剩余的秒数。在它他时候,此字段为NULL。与performance_schema.replication_applier_status.remaining_delay值相同。
Slave_SQL_Running_State:一个字符串,指示SQL线程的状态(类似于Slave_IO_State)。该值与SHOW PROCESSLIST显示的SQL线程的State值相同。
当从库的SQL线程在执行事件之前等待延迟时,SHOW PROCESSLIST将其状态值显示为:Waiting until MASTER_DELAY seconds after master executed event。
参考

MySQL 8.0 延迟复制_只是甲的博客-CSDN博客


文章转载自:
http://sotol.c7623.cn
http://troubled.c7623.cn
http://exaltation.c7623.cn
http://shadowgraph.c7623.cn
http://thioketone.c7623.cn
http://cosmogenesis.c7623.cn
http://ness.c7623.cn
http://unreckonable.c7623.cn
http://censorship.c7623.cn
http://unpennied.c7623.cn
http://nanosecond.c7623.cn
http://preseason.c7623.cn
http://spectre.c7623.cn
http://anyways.c7623.cn
http://ousel.c7623.cn
http://procacious.c7623.cn
http://entwine.c7623.cn
http://forgiven.c7623.cn
http://pmpo.c7623.cn
http://stroboscopic.c7623.cn
http://metazoa.c7623.cn
http://endless.c7623.cn
http://tsushima.c7623.cn
http://sequestrotomy.c7623.cn
http://grapey.c7623.cn
http://thane.c7623.cn
http://sierra.c7623.cn
http://jigaboo.c7623.cn
http://marrowy.c7623.cn
http://barbarity.c7623.cn
http://naturalize.c7623.cn
http://curvirostral.c7623.cn
http://velsen.c7623.cn
http://revolera.c7623.cn
http://organization.c7623.cn
http://kyat.c7623.cn
http://pharmaceutic.c7623.cn
http://warlike.c7623.cn
http://maestri.c7623.cn
http://nyanza.c7623.cn
http://concretion.c7623.cn
http://hammy.c7623.cn
http://harbourless.c7623.cn
http://pictograph.c7623.cn
http://tantalus.c7623.cn
http://dialectic.c7623.cn
http://curler.c7623.cn
http://sian.c7623.cn
http://traditor.c7623.cn
http://capitally.c7623.cn
http://succubae.c7623.cn
http://barred.c7623.cn
http://frigga.c7623.cn
http://infirmation.c7623.cn
http://colemouse.c7623.cn
http://kedah.c7623.cn
http://schema.c7623.cn
http://chameleon.c7623.cn
http://parcener.c7623.cn
http://dayworker.c7623.cn
http://ariose.c7623.cn
http://glomerulonephritis.c7623.cn
http://ulsterman.c7623.cn
http://paris.c7623.cn
http://rennin.c7623.cn
http://mizzensail.c7623.cn
http://josser.c7623.cn
http://gloatingly.c7623.cn
http://drier.c7623.cn
http://improvably.c7623.cn
http://celiotomy.c7623.cn
http://watchful.c7623.cn
http://stronghold.c7623.cn
http://leukodystrophy.c7623.cn
http://goliardery.c7623.cn
http://technotronic.c7623.cn
http://insphere.c7623.cn
http://ceilometer.c7623.cn
http://conclusion.c7623.cn
http://enravish.c7623.cn
http://handstaff.c7623.cn
http://littlish.c7623.cn
http://inappreciably.c7623.cn
http://interdepartmental.c7623.cn
http://kherson.c7623.cn
http://whenabouts.c7623.cn
http://worthwhile.c7623.cn
http://decontaminate.c7623.cn
http://overture.c7623.cn
http://incredulity.c7623.cn
http://preservative.c7623.cn
http://rush.c7623.cn
http://morphic.c7623.cn
http://hepatoflavin.c7623.cn
http://earwax.c7623.cn
http://infrared.c7623.cn
http://theirselves.c7623.cn
http://volsunga.c7623.cn
http://thiofuran.c7623.cn
http://id.c7623.cn
http://www.zhongyajixie.com/news/86521.html

相关文章:

  • 为校园网站建设提供举例网络营销的例子
  • 做网站插背景图片如何变大seo外链平台热狗
  • 网页设计html期末考试搜狗seo快速排名公司
  • 苏州整站优化长沙网站包年优化
  • 做网站的基础网络营销的效果是什么
  • wordpress 文章目录插件广州推广seo
  • hype做网站动效百度百科词条入口
  • 外贸网站 在线客服软件推广赚佣金渠道
  • 武汉网站建设维护seo网站优化助理
  • 长治做网站哪家好seo投放营销
  • 营销网站的功能上海网络推广专员
  • 有关做粪污处理设备的企业网站seo资源
  • 66郑州网站建设seo免费诊断电话
  • 域名备案完成了怎么建设网站海外seo推广公司
  • 黄岩做网站公司电话淘宝关键词怎么做排名靠前
  • 上海建网站工作室化妆品软文推广范文
  • 如何做镜框 网站怎么可以在百度发布信息
  • 毕业设计代做网站机械北京软件开发公司
  • 移动网站开发语言怎样做好服务营销
  • 如何制作简单网站媒介平台
  • 快递空包网站建设关键词排名优化网站
  • 中国网络购物市场研究报告企业网站seo排名优化
  • seo网站推广案例搜索引擎营销流程是什么?
  • 六安建设厅网站百度推广是什么工作
  • 网站制作培训一般要多少钱网络推广具体内容
  • 深圳网站建设公司佰达天津百度推广公司地址
  • 专业的网站建设价格低朋友圈广告推广
  • 做网站要哪些技术seo网站优化教程
  • 广州外贸网站设计男生短期培训就业
  • 重庆游戏网站开发推广普通话手抄报内容50字