MYSQL5.6 OCP 1Z0-883 5.6题库及解析一

1A simplemaster-to-slave replication is currently being used. The following informationis extracted from the SHOW SLAVE STATUS output: 

Last_SQL_Error: Error 'Duplicate entry '8' for key 'PRIMARY'' on query. Defaultdatabase: 'mydb'.

Query: 'insert into mytable VALUES ('8', 'George')'

Skip_Counter: 0


Retrieved_Gtid_Set: 38f32e23480a7-32a1-c323f78067fd37821: 1-8

Auto_Position: 1

You execute a "SHOW CREATE TABLE mytable" on the slave:


CREATE TABLE 'mytable' (

'ID' int(11) NOT NULL DEFAULT '0',

'name' char(10) DEFAULT NULL,

PRIMARY KEY ('ID')

)

The table mytable on the slave contains the following:


You have issued a STOP SLAVE command. One or more statements are requiredbefore you can

issue a START SLAVE command to resolve the duplicate key error.

Which statement should be used?

A)

SET GLOBAL SQL_SKIP_SLAVE_COUNTER=1

B)


SET GTID_NEXT="CONSISTENCY";


BEGIN; COMMIT;


SET GTID_NEXT=" AUTOMATIC

’;

C)

SET GLOBAL enforce_gtid_consistency=ON

D)

SET GTID_EXECUTED="38f32e23480a7-32a1-c323f78067fd37821 : 9";

E)

SET GTID_NEXT="38f32e23480a7-32a1-c323f78067fd37821 : 9"; 

BEGIN; COMMIT;


SET GTID_NEXT="AUTOMATIC";

--------------------------------------------------------------------

答案:E

分析:此题中使用的Replication是通过GTID实现的,因此

A

错,因此GLOBAL SQL_SKIP_SLAVE_COUNTER=1对使用GTID进行的Replication无效

C

错,因为GLOBAL enforce_gtid_consistency=ON是实现的前提。由于GTID_NEXT的有效值为:

AUTOMATIC / ANONYMOUS / :

因此 B错由于Retrieved_Gtid_Set:38f32e23480a7-32a1-c323f78067fd37821: 1-8

因此已经收到主库事务1-8,因此报错是从第9个事务重复记录导致的,很有可能slave上的第8行被人为录入了,导致同步问题。

D

错,因为GTID_EXECUTED表示已经执行完成的事务。

为了临时绕过这个问题,使用注入空事务(BEGIN; COMMIT; ) 代替完成第9个事务.

完成后GTID_EXECUTED才会变为"38f32e23480a7-32a1-c323f78067fd37821: 9"

这时候重新SET GTID_NEXT="AUTOMATIC"; 重启slave后,开始从第10个事务开始同步。


2.Consider the following

statement on a RANGE partitioned table: 

ALTER TABLE orders DROP PARTITION p1, p3;

What is the outcome of executing the above statement?

A.Only the first partition (p1) will be dropped as only one can be dropped atany time.

B.All data in p1 and p3 partitions are removed, but the table definitionremains unchanged.

C.A syntax error will result as you cannot specify more than one partition inthe same statement.

D.All data in pi and p3 partitions are removed and the table definition ischanged.

--------------------------------------------------------------------

答案:D

在删除部分分区后,可以使用show create table查看其定义也一并改变了


3.You inherit alegacy database system when the previous DBA, Bob, leaves the company. You are

notified that users are getting the following error:

mysql> CALL film_in_stock (40, 2, @count);

ERROR 1449 (HY000): The user specified as a definer ('bob'@'localhost') doesnot exist

How would you identify all stored procedures that pose the same problem?

A.Execute SELECT * FROM mysql.routines WHERE DEFINER='bob@localhost';.

B.Execute SHOW ROUTINES WHERE DEFINER='bob@localhost'.

C.Execute SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHEREDEFINER='bob@localhost';.

D.Execute SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER='bob' andHOST='localhost';.

E.Examine the Mysql error log for other ERROR 1449 messages.

----------------------------------------------------------------------------------

答案:C 

分析:routines表在库INFORMATION_SCHEMA下,因此A错。可以登陆MySQL后,使用? show命令查看show语法。可知show无routine语句,B错。

可使用以下命令来查看routines:

pager less;

select * from information_schema.routines\G

可知C正确

INFORMATION_SCHEMA.PROCESSLIST

表中仅显示了当前正在运行的线程信息,D错。

Mysql error log

是对报错信息的记录,并不会有所有存储过程的记录,E错。


4.When designing anInnoDB table, identify an advantage of using the BIT datatype Instead of one

of the integer datatypes.

A.BIT columns are written by InnoDB at the head of the row, meaning they arealways the first to


be retrieved.

B.Multiple BIT columns pack tightly into a row, using less space.

C.BIT(8) takes less space than eight TINYINT fields.

D.The BIT columns can be manipulated with the bitwise operators &, |, ~, ^,<<, and >>. The other


integer types cannot.

------------------------------------------------

答案:C

分析:关于数据类型的存储,可查看http://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html

A, B

都没有特别在guide中提到。

BIT(8)

大致长度为1个Byte, 8个tinyint的存储长度相当于一个bigint了, 请注意并不是说tinyint(8),括号中为可显示的长度,由于一个tinyint为1个Byte,因此8个自然要更长。因此C正确。

D

错,int类型值夜可以进行bit操作符的操作


5.ROW-based replication has stopped working.

You investigate the error log file and find the following entries: 

2013-08-27 14:15:47 9056 [ERROR] Slave SQL: Could not execute Delete_rows eventon table test.t1; Can

’t find record in ‘t1’, Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event’s master log 56_master-bin.000003, end_log_pos 851, Error_code: 1032

2013-08-27 14:15:47 9056 [warning] Slave: Can

’t find

record in ‘t1’Error_code: 1032

2013-08-27 14:15:47 9056 [ERROR] Error running query, slave SQL thread aborted.Fix the problem, and restart the slave SQL thread with

“SLAVE START”. We stopped at log ‘56_masterbin.000003’position 684

Why did you receive this error?

A.The slave SQL thread does not have DELETE privileges to execute on test.t1table.s

B.The table definition on the slave litters from the master.

C.Multi-threaded replication slaves can have temporary errors occurring forcross database 

updates.

D.The slave SQL thread attempted to remove a row from the test.t1 table, butthe row did not


exist.

-------------------------------------------------------------------------------------------

答案:D

分析:报错中说的非常明确Could not execute Delete_rows event on

table test.t1; Can’t find record in ‘t1’,这说明slave上这条记录已经被人为删除了,导致Row-Based

Replication进行同步删除的时候,找不到这条记录。ABC选项都和此报错以及所问问题无关。


6.mysqldump was used to create a single schemabackup;

Shell> mysqldump

–u root –p sakila> sakila2013.sql

Which two commands will restore the sakila database without interfering withother running

database?

A.Mysql> USE sakila; LOAD DATA INFILE 'sakila2013.sql';

B.Shell> mysql

–u root –psakila < sakila2013.sql

C.Shell> mysqlimport

–u root –p sakila sakila2013.sql

D.Shell> mysql

–u root -p –e'use sakila; source sakila2013.sql'

E.Shell> mysql

–u root –p –silent < sakila2013.sql

--------------------------------------------------------------------------------

答案:BD

分析:

A

错,load data infile针对的是select

... into oufile输出的表数据文件,其文件中不含有插入执行语句,仅含有数据。而mysqldump导出的文件包含的数据是以可执行sql语句实现的。

C

错,因此mysqlimport是类似于load data infile语句功能的shell命令行工具,因此对应倒入的文件都应该是非sql语句执行的纯表数据文件。我们看到mysqldump在未使用--database项导出时,并未在文件中使用create database语句。

当导入数据库dump文件,你需要在命令中指定数据库名,即use

db_name进入此库:

shell> mysql db_name < dump.sql

因此B正确

mysql -e

可用于执行语句,但是mysql客户端语句需要使用分号作为终止符发给服务端,因此每个语句后都需要使用分号,D错误。

如果D为Shell> mysql –u root -p –e 'use sakila; source

sakila2013.sql;' 则正确。

E

错. mysql命令项使用中,短项使用单横杠,长命令项使用双横杠 -silent项应该时候双横杠,因此错。


7.Consider the Mysql Enterprise Audit plugin.

You are checking user accounts and attempt the following query:


Mysql> SELECT user, host, plugin FROM mysql.users;

ERROR 1146 (42S02): Table

‘mysql.users’ doesn’t exist

Which subset of event attributes would indicate this error in the audit.logfile?

A.NAME=

”Query” 

STATUS=

”1146” 

SQLTEXT=

”select user,host from users”/>

B.NAME=

”Error” 

STATUS=

”1146” 

SQLTEXT=

”Error 1146 (42S02): Table ‘mysql.users’ doesn’t

exist”/>

C.NAME=

”Query” 

STATUS=

”1146” 

SQLTEXT=

” Error 1146 (42S02): Table ‘mysql.users’ doesn’t

exist”/>

D.NAME=

”Error” 

STATUS=

”1146” 

SQLTEXT=

”select user,host from users”/>

E.NAME=

”Error” 

STATUS=

”0” 

SQLTEXT=

”Error 1146 (42S02): Table ‘mysql.users’ doesn’t

exist”/>

---------------------------------------------------------

答案:A

分析:注意:MySQL Enterprise Audit是包含在MySQL企业版中的一个扩展插件,因此如果你在学习时使用的是社区版的MySQL,那你是无法实验的。因为它需要在环境变量plugin_dir对应目录下存在audit_log.so插件文件。从选择答案中可知,Audit log中使用的是旧格式进行的记录。由于SQLTEXT仅在NAME为Query或Execute时,才会有出现,且NAME不存在Error状态。因此B,D,E错。而SQLTEXT仅存放所使用的SQL语句。而返回的状态存放在STATUS下,0为成功,非0为报错号,因此A对C错。


8.Which query would you use to find connectionsthat are in the same state for longer than 180 seconds?

A.SHOW FULL PROCESSLIST WHERE Time > 180;

B.SELECT * FROM INFORMATION_SCHEMA.EVENTS SHERE STARTS < (DATE_SUB(NOW(),INTERVAL 180 SECOND));

C.SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE STATE <(DATE_SUB(NOW(), INTERVAL 180 SECOND));

D.SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE TIME > 180;

-------------------------------------------------

答案:D

分析:你可以使用 help show;命令来查看其语法可知:

SHOW [FULL] PROCESSLIST

此语法后面不可以跟where语句,因此A错。

INFORMATION_SCHEMA.EVENTS

表显示的是计划的作业,和连接保持的状态时间无关,B错。

INFORMATION_SCHEMA.SESSION_STATUS

表显示的是当前会话的变量及其变量值,和状态信息无关,C错。

INFORMATION_SCHEMA.PROCESSLIST

显示了当前的连接情况,状态,以及状态保持的时间,实际上show processlist也是查看的这张表,不过直接使用select可以使用where语句,D正确。


9.A database exists as aread-intensive server that is operating with query_cache_type =

DEMAND.

The database is refreshed periodically, but the resultset size of the queriesdoes not fluctuate.

—-Note the following details about this environment: 

A web application uses a limited set of queries.

The Query Cache hit rate is high.

All resultsets fit into the Query Cache.

All queries are configured to use the Query Cache successfully.

The response times for queries have recently started to increase. The cause forthis has correctly

been identified as the increase in the number of concurrent users accessing theweb service.

Based solely on the information provided, what is the most likely cause forthis slowdown at the

database level?

A.The Query Cache is pruning queries due to an increased number of requests.

B.Query_cache_min_res_unit has been exceeded, leading to an increasedperformance


overhead due to additional memory block lookups.

C.Mutex contention on the Query Cache is forcing the queries to take longer dueto its singlethreaded nature.

D.The average resultset of a query is increasing due to an increase in thenumber of users


requiring SQL statement execution.

---------------------------------------------------------------------------------------------------------

答案:C

分析:这是一个读密集型数据库,数据库会在一段时间后刷新,但是其查询的结果集大小波动不大。而所有结果集都在Query

Cache中,且网页应用使用一套有限的查询语句。且Query Cache hit rate很高。因此A,D错,请求通过的应用查询,查询语句数量有限,结果集都能放在Query Cache中,相同查询语句的请求不会增多Query Cache中的资源的占用,因此清理查询并非主要矛盾。

B

也错,因此Query_cache_min_res_unit设置过大,仅会造成Query Cache中碎片过多。如果请求的结果集都能在Query Cache中,这就和碎片没什么关系了。

C

正确,尽管官方文档中未大量解释Query Cache Mutex争用问题,在线程运行查询语句时,会在Query Cache中先获取Mutex锁,之后开始查询匹配的查询语句和结果集。如果找到后返回结果。如果未找到匹配,在执行查询后,需要将查询语句和结果集插入Query Cache中,这也会需要获取锁。尽管这个时间所需非常短,但是在读密集的情况下,资源争用会导致线程排队等待现象。


10.You have a login-path named"adamlocal" that was created by using the mysql_config_editor

command.

You need to check what is defined for this login_path to ensure that it iscorrect for you

deployment.

You execute this command:


$ mysql_config_editor print

–login-path=adamlocal

What is the expected output of this command?

A.The command prints all parameters for the login-path. The password is printedin plain text.

B.The command prints all parameters for the login-path. The password is shownonly when you 

provide the --password option.

C.The command prints all parameter for the login-path. The password is replacedwith stars.

D.The command prints the encrypted entry for the login-path. The is onlypossible to see if an


entry exists.

---------------------------------------------------

答案:C

分析:

mysql_config_editor

工具命令用于建立外部登陆文件,一般由mysql客户端或应用来使用,好处在于登陆时免去输入登陆密码,密码已经被保存在了登陆文件中。在环境变量MYSQL_TEST_LOGIN_FILE未设置的情况下,mysql_config_editor默认文件名为.mylogin.cnf,且文件保存在执行此命令的用户home目录下。登陆文件建立后,可直接使用以下命令登陆:

shell> mysql --login-path=login-path

当然,--login-path的默认值为client,因此如果你使用mysql_config_editer set --login-path=client 来进行用户密码设置设置,那么登陆所设用户的时候,连--login-path也可不用了:

shell> mysql

A, D

错,因为不管如何,你都看不到密码的,密码被加密保存后,使用mysql_config_editor

print会将密码替代以星号显示。

B

错,使用mysql_config_editor --help可知在参数项中没有此--password项,且通过参考文档可知--password是用于设置密码而非显示密码的。

C

正确。

你可能感兴趣的:(MYSQL5.6 OCP 1Z0-883 5.6题库及解析一)