1. 程式人生 > 實用技巧 >css修改滾動條樣式

css修改滾動條樣式

目錄

回到頂部

錯誤日誌

錯誤日誌會記錄如下資訊

  • mysql執行過程中的錯誤資訊
  • mysql執行過程中的告警資訊
  • event scheduler執行時所產生資訊
  • mysq啟動和停止過程中產生的資訊
  • 主從複製結構中,重從伺服器IO複雜執行緒的啟動資訊
回到頂部

錯誤日誌相關引數

MariaDB [(none)]> show variables where
    -> variable_name="log_error" or
    -> variable_name="log_warnings";
+---------------+------------------------------------------------------+
| Variable_name | Value                                                |
+---------------+------------------------------------------------------+
| log_error     | D:\application\MariaDB 10.4\data\DESKTOP-A3DGD26.err |
| log_warnings  | 2                                                    |
+---------------+------------------------------------------------------+
2 rows in set (0.001 sec)

log_error:錯誤日誌的存放路徑

log_warnings:表示是否記錄告警資訊到錯誤日誌,0表示不記錄告警資訊,1表示記錄告警資訊,大於1表示各類告警資訊,例如有關網路故障的資訊和重新連線資訊寫入錯誤日誌

FILE:

InnoDB: using atomic writes.
2019-09-05 19:32:27 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2019-09-05 19:32:27 0 [Note] InnoDB: Uses event mutexes
2019-09-05 19:32:27 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-09-05 19:32:27 0 [Note] InnoDB: Number of pools: 1
2019-09-05 19:32:27 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-09-05 19:32:27 0 [Note] InnoDB: Initializing buffer pool, total size = 1G, instances = 1, chunk size = 128M
2019-09-05 19:32:27 0 [Note] InnoDB: Completed initialization of buffer pool
2019-09-05 19:32:27 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-09-05 19:32:27 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-09-05 19:32:27 0 [Note] InnoDB: Setting file '.\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-09-05 19:32:27 0 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB.
2019-09-05 19:32:27 0 [Note] InnoDB: Waiting for purge to start
2019-09-05 19:32:27 0 [Note] InnoDB: 10.4.7 started; log sequence number 139854; transaction id 21
2019-09-05 19:32:27 0 [Note] InnoDB: Loading buffer pool(s) from D:\application\MariaDB 10.4\data\ib_buffer_pool
2019-09-05 19:32:27 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-09-05 19:32:27 0 [Note] Server socket created on IP: '::'.
2019-09-05 19:32:28 0 [Note] InnoDB: Buffer pool(s) load completed at 190905 19:32:28
2019-09-05 19:32:28 0 [Note] Reading of all Master_info entries succeeded
2019-09-05 19:32:28 0 [Note] Added new Master_info '' to hash table
2019-09-05 19:32:28 0 [Note] D:\application\MariaDB 10.4\bin\mysqld.exe: ready for connections.
Version: '10.4.7-MariaDB'  socket: ''  port: 3306  mariadb.org binary distribution
2019-09-05 19:35:47 8 [Warning] Access denied for user '13098884691'@'localhost' (using password: NO)

  

回到頂部

查詢日誌

查詢自然在mysql中被稱之為general log,查詢日誌記錄了資料庫執行的命令,不管這些語法是否正確,都會被記錄。由於資料庫操作命令非常多而且比較頻繁,

所以開啟了查詢日誌以後,資料庫可能需要不停的寫入查詢,這樣會增大伺服器的IO壓力,增加很多的系統開銷,所以預設情況下,mysql的查詢日誌是沒有開啟

的,但是開啟查詢日誌也有助於我們分析那些語句執行密集,執行密集的select語句對應的資料是否能夠被快取,查詢日誌也可以幫助我們分析問題,所以,我

們可以更具實際情況決定是否開啟查詢日誌,如果需要可以手動開啟。

回到頂部

查詢日誌相關引數

MariaDB [(none)]> show variables where variable_name like "%general_log%" or variable_name = "log_output";
+------------------+---------------------+
| Variable_name    | Value               |
+------------------+---------------------+
| general_log      | OFF                 |
| general_log_file | DESKTOP-A3DGD26.log |
| log_output       | FILE                |
+------------------+---------------------+
3 rows in set (0.001 sec)  

general_log:表示查詢日誌是否開啟,ON表示開啟,OFF表示未開啟,預設未OFF

log_output:表示當查詢日誌開啟以後,以哪種方式存放。FILE表示存放於檔案中,TABLE表示存放於表mysql.general_log中(慢查詢存放於表mysql.slow_log),FILE,TABLE表示同時存放於檔案和表中

NONE表示不記錄日誌。log_output不僅控制查詢日誌,還控制慢查詢日誌。

general_log_file:表示查詢日誌存放於檔案的路徑

FILE:

D:\application\MariaDB 10.4\bin\mysqld.exe, Version: 10.4.7-MariaDB (mariadb.org binary distribution). started with:
TCP Port: 3306, Named Pipe: MySQL
Time		    Id Command	Argument
190905 21:51:24	    13 Connect	root@localhost as anonymous on 
		    13 Query	select @@version_comment limit 1
190905 21:53:09	    13 Query	create database testdata
190905 21:53:18	    13 Query	SELECT DATABASE()
		    13 Init DB	testdata
190905 21:53:47	    13 Query	create table book(namechar(20),author char(20))
190905 21:54:11	    13 Query	create table book(name char(20),author char(20))
190905 21:55:06	    13 Query	insert into book values('python','aaa')
190905 21:55:18	    13 Query	insert into book values('java','bbb')
190905 21:55:37	    13 Query	select * from book

TABLE:

MariaDB [mysql]> select * from general_log;
+----------------------------+------------------------------+-----------+-----------+--------------+-----------------------------------------------------------------------------------------+
| event_time                 | user_host                    | thread_id | server_id | command_type | argument                                                                                |
+----------------------------+------------------------------+-----------+-----------+--------------+-----------------------------------------------------------------------------------------+
| 2019-09-05 21:51:24.424262 | [root] @ localhost [::1]     |        13 |         1 | Connect      | root@localhost as anonymous on                                                          |
| 2019-09-05 21:51:24.425389 | root[root] @ localhost [::1] |        13 |         1 | Query        | select @@version_comment limit 1                                                        |
| 2019-09-05 21:53:09.520124 | root[root] @ localhost [::1] |        13 |         1 | Query        | create database testdata                                                                |
| 2019-09-05 21:53:18.755448 | root[root] @ localhost [::1] |        13 |         1 | Query        | SELECT DATABASE()                                                                       |
| 2019-09-05 21:53:18.755778 | root[root] @ localhost [::1] |        13 |         1 | Init DB      | testdata                                                                                |
| 2019-09-05 21:53:47.279001 | root[root] @ localhost [::1] |        13 |         1 | Query        | create table book(namechar(20),author char(20))                                         |
| 2019-09-05 21:54:11.155792 | root[root] @ localhost [::1] |        13 |         1 | Query        | create table book(name char(20),author char(20))                                        |
| 2019-09-05 21:55:06.938210 | root[root] @ localhost [::1] |        13 |         1 | Query        | insert into book values('python','aaa')                                                 |
| 2019-09-05 21:55:18.342203 | root[root] @ localhost [::1] |        13 |         1 | Query        | insert into book values('java','bbb')                                                   |
| 2019-09-05 21:55:37.666281 | root[root] @ localhost [::1] |        13 |         1 | Query        | select * from book                                                                      |
+----------------------------+------------------------------+-----------+-----------+--------------+-----------------------------------------------------------------------------------------+
21 rows in set (0.000 sec)

回到頂部

慢查詢日誌

某些sql語句執行完畢所花費的時間特別長,我們將這種響應比較慢的語句記錄在慢查詢日誌中,只要超過指定時間的sql語句,都稱為“慢查詢”,被記錄在慢查詢日誌中。

慢查詢日誌預設情況下是關閉的,預設設定下,超過10s的語句才會被記錄到慢查詢日誌中。

回到頂部

慢查詢日誌相關引數

MariaDB [(none)]> show  variables where variable_name like 'slow_query%' or variable_name='long_query_time' or variable_name='log_queries_not_using_indexes';
+-------------------------------+--------------------------+
| Variable_name                 | Value                    |
+-------------------------------+--------------------------+
| log_queries_not_using_indexes | OFF                      |
| long_query_time               | 10.000000                |
| slow_query_log                | ON                       |
| slow_query_log_file           | DESKTOP-A3DGD26-slow.log |
+-------------------------------+--------------------------+
4 rows in set (0.001 sec)

slow_query_log:表示查詢日誌是否開啟,ON表示開啟,OFF表示未開啟,預設OFF

slow_query_log_file:表示查詢日誌存放於檔案的路徑

long_query_time:表示多長時間的查詢被認為"慢查詢",預設10s

log_queries_not_using_indexes:表示如果執行的sql語句沒有使用到索引,也被記錄到慢查詢日誌,OFF表示不記錄,ON表示記錄,預設OFF

FILE:

D:\application\MariaDB 10.4\bin\mysqld.exe, Version: 10.4.7-MariaDB (mariadb.org binary distribution). started with:
TCP Port: 3306, Named Pipe: MySQL
Time		    Id Command	Argument
# Time: 190906  3:26:04
# User@Host: root[root] @ localhost [::1]
# Thread_id: 18  Schema:   QC_hit: No
# Query_time: 11.001576  Lock_time: 0.000000  Rows_sent: 1  Rows_examined: 0
# Rows_affected: 0  Bytes_sent: 64
SET timestamp=1567711564;
select sleep(11);
# Time: 190906  3:26:58
# User@Host: root[root] @ localhost [::1]
# Thread_id: 18  Schema:   QC_hit: No
# Query_time: 12.000767  Lock_time: 0.000000  Rows_sent: 1  Rows_examined: 0
# Rows_affected: 0  Bytes_sent: 64
SET timestamp=1567711618;
select sleep(12);  

TABLE:

MariaDB [(none)]> select * from mysql.slow_log;
+----------------------------+------------------------------+-----------------+-----------------+-----------+---------------+----+----------------+-----------+-----------+------------------+-----------+
| start_time                 | user_host                    | query_time      | lock_time       | rows_sent | rows_examined | db | last_insert_id | insert_id | server_id | sql_text         | thread_id |
+----------------------------+------------------------------+-----------------+-----------------+-----------+---------------+----+----------------+-----------+-----------+------------------+-----------+
| 2019-09-06 03:26:04.673659 | root[root] @ localhost [::1] | 00:00:11.001576 | 00:00:00.000000 |         1 |             0 |    |              0 |         0 |         1 | select sleep(11) |        18 |
| 2019-09-06 03:26:58.246917 | root[root] @ localhost [::1] | 00:00:12.000767 | 00:00:00.000000 |         1 |             0 |    |              0 |         0 |         1 | select sleep(12) |        18 |
+----------------------------+------------------------------+-----------------+-----------------+-----------+---------------+----+----------------+-----------+-----------+------------------+-----------+
2 rows in set (0.000 sec)  

回到頂部

二進位制日誌

二進位制日誌是一個二進位制檔案,記錄了對MySQL資料庫執行更改的所有操作,並且記錄了語句發生時間、執行時長、

操作資料等其他額外資訊,但是他不記錄SELECT、SHOW等那些不改變資料庫的SQL語句。二進位制日誌主要用於資料

庫恢復和主從複製,以及審計操作。

回到頂部

二進位制日誌相關引數

MariaDB [(none)]> show variables where
variable_name="log_bin" or
variable_name="log_bin_basename" or
variable_name="max_binlog_size" or
variable_name="log_bin_index" or
variable_name="binlog_format" or
variable_name="sql_log_bin" or
variable_name="sync_binlog";
+------------------+------------+
| Variable_name    | Value      |
+------------------+------------+
| binlog_format    | MIXED      |
| log_bin          | OFF        |
| log_bin_basename |            |
| log_bin_index    |            |
| max_binlog_size  | 1073741824 |
| sql_log_bin      | ON         |
| sync_binlog      | 0          |
+------------------+------------+
7 rows in set (0.001 sec)

log_bin:表示二進位制日誌是否開啟,ON表示開啟,OFF表示未開啟,預設OFF

log_bin_basename:二進位制日誌檔案字首名,二進位制日誌就記錄在該檔案中

max_binlog_size:二進位制日誌檔案的最大大小,超過此大小,二進位制檔案會自動滾動

log_bin_index:二進位制日誌檔案索引檔名,用於記錄所有的二進位制檔案

binlog_format:決定了二進位制日誌的記錄方式,STATEMENT以語句的形式記錄,ROW以資料修改的形式記錄,MIXED以語句和資料修改混合形式記錄

sql_log_bin:決定是否對二進位制日誌進行日誌記錄,ON表示執行記錄,OFF表示不執行記錄,預設OFF,這個是會話級別變數可以通SET sql_log_bin = {0|1}來改變該變數值

sync_binlog:決定二進位制日誌寫入磁碟時機,如果sync_binlog為0,作業系統來決定什麼時候寫入磁碟,如果sync_binlog為N(N=1,2,3..),則每N次事務提交後,都立即將記憶體中的二進位制日誌寫入磁碟,如何選擇取決於安全性與效能的權衡

回到頂部

二進位制日誌的三種記錄方式

STATEMENT:記錄對資料庫做出修改的語句,比如,update A set test='test',如果使用statement模式,那麼這條update語句將被記錄到二進位制日誌中,使用statement模式時,優點是binlog日誌量少,IO壓力小,效能高,缺點是為了儘可能一致的還原操作,除了記錄語句本身外,可能還需要記錄一些相關資訊,而且,在使用一些特定函式時,並不能保證恢復操作與記錄完全一致

ROW:記錄對資料庫做出的修改的語句所影響到的資料行以及這些行的修改,比如,update A set test='test',如果使用row模式,那麼這條update所影響到的行所對應的修改,將會記錄在binlog中,使用row模式時,優點是能完還原和複製被日誌記錄時的操作,缺點是日誌量較大,IO壓力比較大,效能消耗比較大

MIXED:混合上述兩種模式,一般使用statement方式進行記錄,如果遇到一些特殊函式使用row方式進行記錄,這種記錄方式稱為mixed

回到頂部

二進位制日誌進行資料庫恢復

修改my.cnf

[mysqld]
log_bin=bin_log_file
binlog_format=row
sync_binlog=1
server_id=7

重啟mysql服務後,檢視是否生效

+------------------+-----------------------------------------------------+
| Variable_name    | Value                                               |
+------------------+-----------------------------------------------------+
| binlog_format    | ROW                                                 |
| log_bin          | ON                                                  |
| log_bin_basename | D:\application\MariaDB 10.4\data\bin_log_file       |
| log_bin_index    | D:\application\MariaDB 10.4\data\bin_log_file.index |
| max_binlog_size  | 1073741824                                          |
| sql_log_bin      | ON                                                  |
| sync_binlog      | 1                                                   |
+------------------+-----------------------------------------------------+
7 rows in set (0.001 sec)

生成的二進位制日誌檔案和二進位制日誌索引檔案

├─data
│  ├─bin_log_file.index
│  ├─bin_log_file.000001

二進位制日誌相關命令

MariaDB [(none)]> show binary logs;
+---------------------+-----------+
| Log_name            | File_size |
+---------------------+-----------+
| bin_log_file.000001 |       331 |
+---------------------+-----------+
1 row in set (0.000 sec)

MariaDB [(none)]> show master status;
+---------------------+----------+--------------+------------------+
| File                | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------------+----------+--------------+------------------+
| bin_log_file.000001 |      331 |              |                  |
+---------------------+----------+--------------+------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> show binlog events in "bin_log_file.000001";
+---------------------+-----+-------------------+-----------+-------------+-----------------------------------------------+
| Log_name            | Pos | Event_type        | Server_id | End_log_pos | Info                                          |
+---------------------+-----+-------------------+-----------+-------------+-----------------------------------------------+
| bin_log_file.000001 |   4 | Format_desc       |         7 |         256 | Server ver: 10.4.7-MariaDB-log, Binlog ver: 4 |
| bin_log_file.000001 | 256 | Gtid_list         |         7 |         285 | []                                            |
| bin_log_file.000001 | 285 | Binlog_checkpoint |         7 |         331 | bin_log_file.000001                           |
+---------------------+-----+-------------------+-----------+-------------+-----------------------------------------------+
3 rows in set (0.000 sec)

新增資料,在模擬資料被誤刪除

建立資料庫->建立表->表插入資料->表刪除資料->刪除表->刪除資料庫

create database zz;
use zz;
create table zz_table(id int);
insert into zz_table values(1);
insert into zz_table values(2);
insert into zz_table values(3);
insert into zz_table values(4);
insert into zz_table values(5);
delete from zz_table where id=4;
drop table zz_table;
drop database zz;

我現在需要根據二進位制日誌恢復到刪除表之前的狀態

MariaDB [(none)]> show binlog events in "bin_log_file.000001";
+---------------------+------+-------------------+-----------+-------------+-----------------------------------------------------------+
| Log_name            | Pos  | Event_type        | Server_id | End_log_pos | Info                                                      |
+---------------------+------+-------------------+-----------+-------------+-----------------------------------------------------------+
| bin_log_file.000001 |    4 | Format_desc       |         7 |         256 | Server ver: 10.4.7-MariaDB-log, Binlog ver: 4             |
| bin_log_file.000001 |  256 | Gtid_list         |         7 |         285 | []                                                        |
| bin_log_file.000001 |  285 | Binlog_checkpoint |         7 |         331 | bin_log_file.000001                                       |
| bin_log_file.000001 |  331 | Gtid              |         7 |         373 | GTID 0-7-1                                                |
| bin_log_file.000001 |  373 | Query             |         7 |         456 | create database zz                                        |
| bin_log_file.000001 |  456 | Gtid              |         7 |         498 | GTID 0-7-2                                                |
| bin_log_file.000001 |  498 | Query             |         7 |         592 | use `zz`; create table zz_table(id int)                   |
| bin_log_file.000001 |  592 | Gtid              |         7 |         634 | BEGIN GTID 0-7-3                                          |
| bin_log_file.000001 |  634 | Annotate_rows     |         7 |         687 | insert into zz_table values(1)                            |
| bin_log_file.000001 |  687 | Table_map         |         7 |         736 | table_id: 18 (zz.zz_table)                                |
| bin_log_file.000001 |  736 | Write_rows_v1     |         7 |         774 | table_id: 18 flags: STMT_END_F                            |
| bin_log_file.000001 |  774 | Xid               |         7 |         805 | COMMIT /* xid=13 */                                       |
| bin_log_file.000001 |  805 | Gtid              |         7 |         847 | BEGIN GTID 0-7-4                                          |
| bin_log_file.000001 |  847 | Annotate_rows     |         7 |         900 | insert into zz_table values(2)                            |
| bin_log_file.000001 |  900 | Table_map         |         7 |         949 | table_id: 18 (zz.zz_table)                                |
| bin_log_file.000001 |  949 | Write_rows_v1     |         7 |         987 | table_id: 18 flags: STMT_END_F                            |
| bin_log_file.000001 |  987 | Xid               |         7 |        1018 | COMMIT /* xid=15 */                                       |
| bin_log_file.000001 | 1018 | Gtid              |         7 |        1060 | BEGIN GTID 0-7-5                                          |
| bin_log_file.000001 | 1060 | Annotate_rows     |         7 |        1113 | insert into zz_table values(3)                            |
| bin_log_file.000001 | 1113 | Table_map         |         7 |        1162 | table_id: 18 (zz.zz_table)                                |
| bin_log_file.000001 | 1162 | Write_rows_v1     |         7 |        1200 | table_id: 18 flags: STMT_END_F                            |
| bin_log_file.000001 | 1200 | Xid               |         7 |        1231 | COMMIT /* xid=17 */                                       |
| bin_log_file.000001 | 1231 | Gtid              |         7 |        1273 | BEGIN GTID 0-7-6                                          |
| bin_log_file.000001 | 1273 | Annotate_rows     |         7 |        1326 | insert into zz_table values(4)                            |
| bin_log_file.000001 | 1326 | Table_map         |         7 |        1375 | table_id: 18 (zz.zz_table)                                |
| bin_log_file.000001 | 1375 | Write_rows_v1     |         7 |        1413 | table_id: 18 flags: STMT_END_F                            |
| bin_log_file.000001 | 1413 | Xid               |         7 |        1444 | COMMIT /* xid=19 */                                       |
| bin_log_file.000001 | 1444 | Gtid              |         7 |        1486 | BEGIN GTID 0-7-7                                          |
| bin_log_file.000001 | 1486 | Annotate_rows     |         7 |        1539 | insert into zz_table values(5)                            |
| bin_log_file.000001 | 1539 | Table_map         |         7 |        1588 | table_id: 18 (zz.zz_table)                                |
| bin_log_file.000001 | 1588 | Write_rows_v1     |         7 |        1626 | table_id: 18 flags: STMT_END_F                            |
| bin_log_file.000001 | 1626 | Xid               |         7 |        1657 | COMMIT /* xid=21 */                                       |
| bin_log_file.000001 | 1657 | Gtid              |         7 |        1699 | BEGIN GTID 0-7-8                                          |
| bin_log_file.000001 | 1699 | Annotate_rows     |         7 |        1753 | delete from zz_table where id=4                           |
| bin_log_file.000001 | 1753 | Table_map         |         7 |        1802 | table_id: 18 (zz.zz_table)                                |
| bin_log_file.000001 | 1802 | Delete_rows_v1    |         7 |        1840 | table_id: 18 flags: STMT_END_F                            |
| bin_log_file.000001 | 1840 | Xid               |         7 |        1871 | COMMIT /* xid=23 */                                       |
| bin_log_file.000001 | 1871 | Gtid              |         7 |        1913 | GTID 0-7-9                                                |
| bin_log_file.000001 | 1913 | Query             |         7 |        2025 | use `zz`; DROP TABLE `zz_table` /* generated by server */ |
| bin_log_file.000001 | 2025 | Gtid              |         7 |        2067 | GTID 0-7-10                                               |
| bin_log_file.000001 | 2067 | Query             |         7 |        2148 | drop database zz                                          |
+---------------------+------+-------------------+-----------+-------------+-----------------------------------------------------------+
41 rows in set (0.000 sec)

在檔案系統中也可以通過如下命令檢視

D:\application\MariaDB 10.4\data>mysqlbinlog bin_log_file.000001 

根據上述日誌可以發現,pos=373,end_log_pod'fdfs=1871即為要恢復的類容,擷取二進位制日誌,放入自定義檔案

mysqlbinlog --start-position=373 --stop-position=1871 bin_log_file.000001 > recover_file.sql

執行資料恢復

#臨時關閉binlog
set sql_log_bin=0;
#執行sql檔案
source recover_file.sql
#開啟binlog
set sql_log_bin=1;

檢視恢復結果

MariaDB [zz]> show tables;
+--------------+
| Tables_in_zz |
+--------------+
| zz_table     |
+--------------+
1 row in set (0.000 sec)

MariaDB [zz]> select * from zz_table;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
|    5 |
+------+
4 rows in set (0.000 sec)




# 轉自; https://www.cnblogs.com/plyonfly/p/11469802.html