Posted 鑰佸彾鑼堕
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了相关的知识,希望对你有一定的参考价值。
涓€銆侀棶棰樻弿杩?/span>
浠婂ぉ鏀跺埌涓讳粠寤惰繜鍛婅锛堝懆鏈潯浜嗕竴鏅氫笂娌$湅鍒板憡璀︼紝鐣ユ樉灏村艾馃槗锛夛紝璧剁揣鐪嬩笅浠庡簱鐘舵€?/p>
50:56 root@mysql3306.sock][(none)]> show slave status\G :
1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.100.63.10
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000383
Read_Master_Log_Pos: 132069756
Relay_Log_File: mlfslave164-relay-bin.000684
Relay_Log_Pos: 827356702
Relay_Master_Log_File: mysql-bin.000382
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 827356489
Relay_Log_Space: 1205833440
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 50064
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 30429
Master_UUID: d04dc0aa-ca9f-11e8-ba14-d094660e5c57
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Reading event from the relay log
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
浜屻€侀棶棰樿瘖鏂?/span>
2.1 鍒濇鍒ゆ柇
show鍑犳slave status鐨勭粨鏋滅湅鍒癊xec_Master_Log_Pos閮藉浜庝綅缃?27356489锛屾墍浠ュ緢瀹规槗灏卞彲浠ュ垽鏂嚭澶勪簬澶т簨鍔′簡銆?/p>
2.2 瑙f瀽binlog
閫氳繃瑙f瀽涓诲簱鐨刡inlog涓€鎺㈢┒绔燂紝
2.3 pstack
鍐嶇湅涓媝stack缁撴灉
Thread 217 (Thread 0x7fdf4af5c700 (LWP 180191)):
export/home/pb2/build/sb_0-29016441-1528454776.43/mysql-5.7.23/storage/innobase/row/row0sel.cc:3760 0 sel_restore_position_for_mysql (same_user_rec=0x7fdf4af5bb48, pcur=0x7fe0546e2718, moves_up=1, mtr=0x7fdf4af5aad0, latch_mode=1) at /
in row_search_mvcc (buf=0x7fe05451c5b0 "", mode=PAGE_CUR_G, prebuilt=0x7fe0546e2508, match_mode=0, direction=1) at /export/home/pb2/build/sb_0-29016441-1528454776.43/mysql-5.7.23/storage/innobase/row/row0sel.cc:5069 1 0x00000000011396b6
in ha_innobase::general_fetch (this=0x7fe054c79c60, buf=0x7fe05451c5b0 "", direction=1, match_mode=0) at /export/home/pb2/build/sb_0-29016441-1528454776.43/mysql-5.7.23/storage/innobase/handler/ha_innodb.cc:9021 2 0x000000000104af2e
in handler::ha_rnd_next (this=<optimized out>, buf=0x7fe05451c5b0 "") at /export/home/pb2/build/sb_0-29016441-1528454776.43/mysql-5.7.23/sql/handler.cc:2947 3 0x000000000081b9fa
in Rows_log_event::do_table_scan_and_update (this=0x7fe04954d970, rli=0x7fe048085f30) at /export/home/pb2/build/sb_0-29016441-1528454776.43/mysql-5.7.23/sql/log_event.cc:10804 4 0x0000000000ecd461
in Rows_log_event::do_apply_event (this=0x7fe04954d970, rli=0x7fe048085f30) at /export/home/pb2/build/sb_0-29016441-1528454776.43/mysql-5.7.23/sql/log_event.cc:11270 5 0x0000000000edb4f2
in slave_worker_exec_job_group (worker=0x7fe048085f30, rli=0x7fe01409f450) at /export/home/pb2/build/sb_0-29016441-1528454776.43/mysql-5.7.23/sql/rpl_rli_pdb.cc:2666 6 0x0000000000f2dbb5
in handle_slave_worker (arg=0x7fe048085f30) at /export/home/pb2/build/sb_0-29016441-1528454776.43/mysql-5.7.23/sql/rpl_slave.cc:6180 7 0x0000000000f199b3
in pfs_spawn_thread (arg=0x7fe04800dfa0) at /export/home/pb2/build/sb_0-29016441-1528454776.43/mysql-5.7.23/storage/perfschema/pfs.cc:2190 8 0x0000000000fc79a4
in start_thread () from /lib64/libpthread.so.0 9 0x00007feddcd23dd5
in clone () from /lib64/libc.so.6 10 0x00007feddb7dbead
鐪嬪埌sql_thread澶勪簬row_search_mvcc鐘舵€侊紝鍒拌繖閲屽叾瀹炲熀鏈笂鍙互鍒ゆ柇鍑虹敱浜庤〃娌℃湁涓婚敭鎴栬€呮病鏈夊悎閫傜殑绱㈠紩閫犳垚鐨勪富浠庡欢杩熴€?/p>
2.4 鏍瑰洜纭畾
鎴戜滑鍐嶇湅涓嬪搴旂殑琛ㄧ殑琛ㄧ粨鏋滐紝浠巄inlog鍙互鐪嬪埌鏇存柊鐨勮〃涓篸iwo_mydoc_inc$_temp锛岃〃缁撴瀯濡備笅锛?/p>
[20:29:34 root@mysql3306.sock][trswcmtest]> show create table diwo_mydoc_inc$_temp\G
*************************** 1. row ***************************
Table: diwo_mydoc_inc$_temp
Create Table: CREATE TABLE `diwo_mydoc_inc$_temp` (
`SEQ_ID` bigint(20) NOT NULL DEFAULT '0',
`viewkey` varchar(37) NOT NULL,
`SQL_TYPE` tinyint(4) NOT NULL,
`TRS_FLAG` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
鏋滅劧锛屽鎴戜滑鎵€鏂欙紝琛ㄤ笂娌℃湁涓婚敭锛屼篃娌℃湁浠讳綍绱㈠紩銆?br>
濂戒簡锛屽埌杩欓噷涓讳粠寤惰繜鐨勫師鍥犲凡缁忔壘鍒帮紝閭d箞璇ュ浣曡В鍐冲憿锛?/p>
涓夈€佽В鍐冲姙娉?/span>
3.1 缁х画绛夊緟
杩欐槸涓€绉嶅緢鏃犲鐨勬柟寮忥紝鍟ラ兘涓嶅仛
[20:32:28 root@mysql3306.sock][trswcmtest]> pager cat - |grep "row lock"
PAGER set to 'cat - |grep "row lock"'
[20:32:35 root@mysql3306.sock][trswcmtest]> show engine innodb status\G
0 lock struct(s), heap size 1136, 0 row lock(s)
0 lock struct(s), heap size 1136, 0 row lock(s)
0 lock struct(s), heap size 1136, 0 row lock(s)
0 lock struct(s), heap size 1136, 0 row lock(s)
0 lock struct(s), heap size 1136, 0 row lock(s)
0 lock struct(s), heap size 1136, 0 row lock(s)
0 lock struct(s), heap size 1136, 0 row lock(s)
0 lock struct(s), heap size 1136, 0 row lock(s)
0 lock struct(s), heap size 1136, 0 row lock(s)
1 row in set (0.00 sec)
閫氳繃杩欑鏂瑰紡鏌ョ湅琛岄攣鐨勬暟閲忥紝鍙互浼扮畻鍑哄ぇ姒傝繕闇€瑕佸灏戞椂闂村畬鎴恇inlog搴旂敤锛堝綋鏃跺お鍖嗗繖锛屽繕璁版埅鍥句簡锛夛紝鏁呴殰褰撴椂绮楃暐浼扮畻杩橀渶瑕?涓皬鏃舵墠鑳藉簲鐢ㄥ畬锛屾灉鏂娇鐢ㄤ簡绗簩绉嶆柟娉曘€?br>
3.2 閲嶅惎銆佸缓绱㈠紩
姝ゆ椂濡傛灉鎸夋甯竤hutdown鎴栬€卻top slave鐨勬柟寮忔潵鍋滄澶嶅埗闇€瑕佺殑鏃堕棿鍙兘宸茬粡涓嶆涓€鐐瑰崐鐐逛簡锛岃繃娈祂ill -9 `pid of mysqld`锛屽惎鍔ㄦ椂娣诲姞鍙傛暟`鈥?skip-slave-start`淇濊瘉slave鍚姩鏃朵笉寮€鍚鍒躲€?/p>
瑙傚療琛╠iwo_mydoc_inc$_temp鐨勬暟鎹垎甯冿紝鍙戠幇viewkey瀛楁鏉ユ簮浜庡彟澶栦袱寮犺〃鐨勨€濊〃鍚嶁€?鍞竴閿紝SQL_TYPE瀛楁鏍囪瘑浜哠QL鐨勭被鍨嬶紝閭d箞鎴戜滑鍙互瀵箆iewkey寤虹珛绱㈠紩锛屼笖鍖哄垎搴﹁緝楂樸€?span class="mq-19">
set sql_log_bin=0;
create index idx_viewkey on diwo_mydoc_inc$_temp(viewkey);
寤虹珛绱㈠紩浠ュ悗锛屽啀寮€鍚鍒讹紝2鍒嗛挓浠ュ悗灏辫拷涓婁簡涓诲簱锛屽彲瑙佸鍒惰繕鏄緢缁欏姏鐨勩€?/p>
3.3 淇敼slave_rows_search_algorithms
slave_rows_search_algorithms榛樿鍊间负TABLE_SCAN,INDEX_SCAN锛屾垜浠彲浠ヨ缃瓾ASH_SCAN鏉ュ姞閫焍inlog event鍦ㄥ簲鐢ㄨ繃绋嬩腑鐨剅ow瀹氫綅銆侶ASH_SCAN鎻愰珮鎬ц兘鐨勪袱涓潯浠跺涓嬶細
琛ㄤ腑娌℃湁浠讳綍绱㈠紩鎴栬€呮湁绱㈠紩涓旀湰鏉pdate/delete鐨勬暟鎹叧閿瓧閲嶅鍊艰緝澶?/p>
涓€涓猽pdate/delete璇彞鍒犻櫎浜嗗ぇ閲忕殑鏁版嵁锛屽舰鎴愪簡寰堝涓?K宸﹀彸鐨刄PDATE_ROW_EVENT/DELETE_ROW_EVENT銆倁pdate/delete鍙慨鏀瑰皯閲忕殑鏁版嵁锛堟瘮濡傛瘡涓鍙ヤ慨鏀逛竴琛屾暟鎹級骞朵笉鑳芥彁楂樻€ц兘
鍥涖€佹€濊€?/span>
鍒拌繖閲岋紝闂宸茶В鍐冲ぇ鍗婏紝浣嗘槸缁欐垜浠殑璀︾ず杩樺緱鐗㈣浜庡績
澶т簨鍔★紝涓讳粠澶嶅埗閫犳垚寤惰繜鐨勭姜榄佺ジ棣?/p>
鏃犱富閿€佸敮涓€閿紝涓讳粠寤惰繜鐨勫偓鍖栧墏锛屽缓璁瘡涓〃杩樻槸淇濈暀鑷涓婚敭浠ユ彁楂樺鍒舵€ц兘
鏈枃缁欏嚭浜嗗揩閫熻瘖鏂富浠庡欢杩熺殑鎬濊矾鍙婃柟娉曪紝寤鸿鏂版墜鏈嬪弸浠彲浠ュ涔犱竴涓嬭繖涓璺?nbsp;
鍙﹀锛屽彾鑰佸笀鍦ㄨ吘璁鍫傜殑鐭绋嬨€?span class="mq-34">MySQL鎬ц兘浼樺寲銆嬪凡寮€璇撅紝鏈绋嬭瑙h鍑犱釜MySQL鎬ц兘浼樺寲鐨勬牳蹇冭绱狅細鍚堢悊鍒╃敤绱㈠紩锛岄檷浣庨攣褰卞搷锛屾彁楂樹簨鍔″苟鍙戝害銆?span class="mq-38">
涓嬮潰鏄姤鍚嶅皬绋嬪簭鐮?/p>
以上是关于的主要内容,如果未能解决你的问题,请参考以下文章