MySQL Interview common knowledge

Before a brief summary of what MySQL interview knowledge of the scene

1. Under speak MVCC principle 
2.MySQL high-availability architecture introduced 
3.OSC (online change the table structure) principle 
4.MySQL tuning what key points / experience 
5.MySQL online backup solution, Xtrabackup principle 
6.MySQL monitor what indicators 
7. how to migrate online MySQL 
8.MySQL 5.7 What are the new features / functions 
9.Update t1 set c1 = v1 where id = 123; id is a general index, the operation, which locks will be added? 
10. The lock is void solve any problem? 
11. The server parameter tuning, what are the key points 
12. understand what middleware, understanding of LVS, MHA of 
13. The operation and maintenance of MySQL master-slave replication cluster, which encountered problems, how to solve? 
14. The operation and maintenance of MySQL process, encountered any major failure, how to deal with? 
15. Database Monitoring Automation Solutions 
16. innodb_autoinc_lock_mode # increment lock marching how set up? Which parameter set, how much value, why?

1 mvcc

mysql database multi-version concurrency control, consistency, non-locking tables innodb engine line read, if read the current data being 
dml operation, a read operation does not wait for a row lock, innodb be reading a snapshot, snapshot version is the version before the start of the transaction by the innodb 
to implement undo, different transaction isolation level, the transaction snapshot definition is not the same. Each row is stored version number, the transaction will be saved each version understandable 
to check the version of each line in accordance with the version of the transaction.

2 mysql high availability architecture

a double main keepalived, master-master, by providing a virtual IP keepalived, and provides heartbeat script (ka_check_mysql.sh) 
 , if the script mysql detection fails, the host removed keepalived 
 B MHA, Manager nodes, a plurality of node, 1 a master, a plurality of Slave, mha can automatically switch, manual switch, since mha ensure 
  plurality of merged log, log comparison, data will be lost to a minimum 
 c lvs + keepalived + slave slave load balancing  
d pxc

Since this is summarized in 2016, should now add MGR

3 osc online change table structure

mysql native online ddl, copy and InPlace 
 --add index: Copy, with the new index table, the original table lock, prohibiting DML, allowing select, the original table to the temporary table data, read prohibited, for the rename, upgraded dictionaries lock, complete the creation of the index action 
 --add index (second index): inplace , create index data dictionary, plus a shared lock, prohibit dml, allow select, read the clustered index, construct a new index entries, sort and insert a new index 
    wait open all read-only transactions submitted to the current table, create end 
 third-party tools for online DDL, OAK, pt-online-DDL 
 --oak, checking for compliance with the oak-online-alter-table, no fk, trigger, online ddl, data consistency checking, table switching, rename, delete trigger 
 --pt

4 mysql performance tuning

 --mysql 参数,
  --innodb_buffer_pool_size
  --innodb_thread_concurrency
  --innodb_io_capacity
  --innodb_flush_method
  --innodb_flush_log_at_trx_commit
  --sync_binlog

5 mysql online backup solution, xtrabackup

   a mysqldump, online backup logic, export to create, insert format 
   b xtrabackup, innobackupex online physical backup, the data file opened innodb read-write mode, 
    each read and write data 1mb, a traverse one due to not lock table, so the copy out data inconsistencies, for 
	myisam table, you must lock the table, and then copy the files 
     - start the background detection, real-time detection mysql redo changes, redo write once, immediately written to the log in the log xtrabackup_log 
	 - copy innodb data greetings and file system table space 
	 - to copy the end, the implementation of the table with the Read Lock flush 
	 - copy frm, myd, myi and other documents 
	 - this moment to get the binary log position 
	 --unlock the tables 
	 InnoDB maintains a redo log, also known as the transaction log, the transaction log, which contains data innodb 
	all the changes of circumstances. When InnoDB start, it will go to check the data file and transaction log, and will 
	do a two-step operation: 
	1.It committed Transaction log entries It Applies to the Data Files at The 
	2.It Performs Use the undo Operation ON AN Transactions that the any Modified But the Data did not commit.

6 mysql monitoring indicators

  zabbix监控mysql,指标
    --cpu,processor load,memory,swap
    --qps,tps,mysqld
    --slave_io_running,slave_sql_running

7 Migration Online mysql

    migrate through a master-slave online manual migration 
    b switched by MHA, manual 
    c pt-archive

8 5.7 new features, functions

   After a security not initialized to null the password, the password change policy, user lock, etc. 
   b json format support for 
     the CREATE  TABLE t_jeson (jdoc the JSON);
      INSERT  INTO t_jeson   the VALUES ( ' { "key1": "VALUE1", "key2 ":" value2 "} ' ); 
   C Generate column 
     the CREATE  TABLE Triangle (SideA DOUBLE , SideB DOUBLE , Area DOUBLE  the AS (SideA * SideB /  2 )); 
   D is introduced SYS Schema , a system library that contains some views, functions and procedures 
   e online open GTID

9.Update t1 set c1 = v1 where id = 123; id is normal index, this operation, which lock will be added

   a innodb table, the RR mode index id is first positioned by the first record satisfying the query, plus X lock records, add the gap GAP lock, the lock then x clustered index on the added record, and then returns 
     , then read remove a repeated until the recording for the first condition is not satisfied, then x does not require additional lock, the lock is still need to add gap. 
   b inndob table, RC mode, corresponding to all the records satisfy the query criteria sql, will be locked, at the same time, these records recorded on the primary key index, will be locked  

Lock on this one, we can speak detailed look at the mysql 45 inside the lock explain

10. The lock is void solve any problem?

In the RR mode, in order to solve InnoDB phantom read, generating a gap locks in the same transaction, the current read twice, return to exactly the same record.

11. The server tuning parameters, which key

	1 os system selection, RedHat, CentOS, SUSE 
	2 off the swap, vm.swappiness = 10 
	. 3 mysql single instance, closed NUMA, os kernel set, when closing the parameter start mysql 
	4 do Ethernet Adapter, bond0, adjusting network parameters 
	5 disk scheduling settings 
	6 file system recommended xfs / ext4, noatime, nobarrier   

12. understand what middleware, understanding of LVS, MHA's

   a mycat middleware, read and write can be separated from the main automatic switch, mainly in sub-library sub-table 
   b lvs load balancing, DR mode, routed mode, turn responsible to send 
   c mha availability architecture, manager responsible for the management node Node, available for failover and manual switching standby database 
D DBLE
E-Sharding the JDBC

13. The operation and maintenance of MySQL master-slave replication cluster, which encountered problems, how to solve?

   Cluster problems: 
   1 being given from the library: 1062 
		STOP Slave; 
		Delete from T1 WHERE ename = 'Robin'; 
		Start Slave;    
	2 1032 
		STOP Slave SQL_THREAD; 
		INSERT INTO T1 values (1, 'linuxidc', 'HTTP: //www.linuxidc .com / linuxidc '); 
		Start Slave SQL_THREAD; 
	. 3 libraries are missing from the deleted record (corresponding Errno: 1032) 
		STOP Slave SQL_THREAD;			 
		SET gtid_next =' 1b64c25d-8d2b-11e6-9ac0-000c29b82d0d: 92 ';	 
		the begin ; the commit; 
		SET gtid_next = 'AUTOMATIC'; 
		Start Slave SQL_THREAD; 
	case 4 is binlog purge the primary library (Errno: 1236) 
		Last_IO_Error: Got fatal error 1236 from master When Reading Data from binary log:

14. The operation and maintenance of MySQL process, encountered any major failure, how to deal with?

15. Database Monitoring Automation Solutions

16. innodb_autoinc_lock_mode # increment lock marching how set up? Which parameter set, how much value, why?  

  Insertion Type 
   INSERT = INSERT-like, Replace, INSERT ... SELECT, SELECT ... Replace, Load Data 
   Simple inserts = INSERT, replacce 
   Bulk inserts INSERT = SELECT ..., replace..select, Load Data 
   Mixed-MODE inserts INSERT INTO T1 = (C1, C2) values (. 1, 'A'), (null, 'B'), (. 5, 'B'), (null, 'D') 
   innodb_autoinc_lock_mode = 0,1,2 
   . 1 default value, only for simple inserts mutex in memory calculator accumulates for bulk inserts, or traditional use 
     of auto-inc locking manner, without regard to ROLLBACK, since the growth or continuous. 
	 If you use the value of self-generated growth of auto-inc locking manner, a simple inserts, need to wait for the release of auto-inc locking of 
   2 All insert-like, self-generated growth through value are two mutually exclusive, rather than auto-inc locking manner, the highest performance 
     concurrent insert, each insert, since the values may not increase continuously, using this mode, from the master to use row-base replication, to ensure the 
	 consistency and the primary maximum concurrent performance of data replication from  

Most of the above are a little biased understanding of theoretical knowledge, in fact, there are a lot of knowledge not listed

In some time, the interviewer will be more concerned about: cluster size , traffic data , type of business practical problems

Guess you like

Origin www.cnblogs.com/yhq1314/p/11309597.html