logo资料库

mysql5.6ocp 1z0-883.docx

第1页 / 共76页
第2页 / 共76页
第3页 / 共76页
第4页 / 共76页
第5页 / 共76页
第6页 / 共76页
第7页 / 共76页
第8页 / 共76页
资料共76页,剩余部分请下载后查看
1, A simple master-to-slave replication is currently being used. The following information is extracted from the SHOW SLAVE STATUS output: Last_SQL_Error: Error 'Duplicate entry '8' for key 'PRIMARY'' on query. Default database: '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 required before 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 at any time. B. All data in p1 and p3 partitions are removed, but the table definition remains unchanged. C. A syntax error will result as you cannot specify more than one partition in the same statement. D. All data in pi and p3 partitions are removed and the table definition is changed. -------------------------------------------------------------------- 答案:D 在删除部分分区后,可以使用 show create table 查看其定义也一并改变了 3. You inherit a legacy 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') does not 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 INFORMATION_SCHEMA.ROUTINES SELECT * FROM WHERE
DEFINER='bob@localhost';. D.Execute SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER='bob' and HOST='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 an InnoDB 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 are always 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 操作符的操作 Can’t find record in ‘t1’, test.t1; 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 event on table 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? Error_code: handler 1032; A. The slave SQL thread does not have DELETE privileges to execute on test.t1 table.s B. The table definition on the slave litters from the master. C. Multi-threaded replication slaves can have temporary errors occurring for cross database updates. D. The slave SQL thread attempted to remove a row from the test.t1 table, but the 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 schema backup; Shell> mysqldump –u root –p sakila > sakila2013.sql Which two commands will restore the sakila database without interfering with other running
database? A. Mysql> USE sakila; LOAD DATA INFILE 'sakila2013.sql'; B. Shell> mysql –u root –p sakila < 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 -------------------------------------------------------------------------------- 答案:B 分析: 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.log file? 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 connections that 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 (DATE_SUB(NOW(), INTERVAL 180 SECOND)); * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE STATE < 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 a read-intensive server that is operating with query_cache_type = DEMAND. The database is refreshed periodically, but the resultset size of the queries does 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 for this has
correctly been identified as the increase in the number of concurrent users accessing the web service. Based solely on the information provided, what is the most likely cause for this 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 increased performance overhead due to additional memory block lookups. C. Mutex contention on the Query Cache is forcing the queries to take longer due to its singlethreaded nature. D. The average resultset of a query is increasing due to an increase in the number 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" mysql_config_editor command. You need to check what is defined for this login_path to ensure that it is correct for you deployment. created by using the that was
分享到:
收藏