logo资料库

mysql5.7-ocp-888 .docx

第1页 / 共117页
第2页 / 共117页
第3页 / 共117页
第4页 / 共117页
第5页 / 共117页
第6页 / 共117页
第7页 / 共117页
第8页 / 共117页
资料共117页,剩余部分请下载后查看
Question: 1
Question: 2
Question: 3
Question: 4
Question: 5
Question: 6
Question: 7
Question: 8
Question: 9
Question: 10
Question: 11
Question: 12
Question: 13
Question: 14
Question: 15
Question: 16
Question: 17
Question: 18
Question: 19
Question: 20
Question: 21
Question: 22
Question: 23
Question: 24
Question: 25
Question: 26
Question: 27
Question: 28
Question: 29
Question: 30
Question: 31
Question: 32
Question: 33
Question: 34
Question: 35
Question: 36
Question: 37
Question: 38
Question: 39
Question: 40
Question: 41
Question: 42
Question: 43
Question: 44
Question: 45
Question: 46
Question: 47
Question: 48
Question: 49
Question: 50
Question: 51
Question: 52
Question: 53
Question: 54
Question: 55
Question: 56
Question: 57
Question: 58
Question: 59
Question: 60
Question: 61
Question: 62
Question: 63
Question: 64
Question: 65
Question: 66
Question: 67
Question: 68
Question: 69
Question: 70
Question: 71
Question: 72
Question: 73
Question: 74
Question: 75
Question: 76
Question: 77
Question: 78
Question: 79
Question: 80
Question: 81
Question: 82
Question: 83
Question: 84
2019年2月份新题
Question: 85
Question: 86
Question: 87
Question: 88
Question: 89
Question: 90
Question: 91
Question: 92
Question: 93
Question: 94
Question: 95
Question: 96
Question: 97
Question: 98
Question: 99
Question: 100
Question: 101
Question: 102
Question: 103
Question: 104
Question: 105
Question: 106
Question: 107
Question: 108
Question: 109
Question: 110
Question: 111
Question: 112
Question: 113
Question: 114
Question: 115
Question: 116
Question: 117
Question: 118
Question: 119
Question: 120
Question: 121
Question: 122
Question: 123
Question: 124
Question: 125
Question: 126
Question: 127
Question: 128
Question: 129
Question: 130
Question: 131
Question: 132
Question: 133
Question: 134
Question: 135
Question: 136
Question: 137
Question: 138
Question: 139
Question: 140
Question: 141
Question: 142
Question: 143
Question: 144
Question: 145
Question: 146
Question: 147
Question: 148
Question: 149
Question: 150
Question: 151
Question: 152
Question: 153
Question: 154
Question: 155
Question: 156
Question: 157
Question: 158
Question: 159
Question: 160
Question: 161
Question: 162
Question: 163
Question: 164
Question: 165
Question: 166
Question: 167
Question: 168
Question: 169
Question: 170
Question: 171
Question: 172
Question: 173
Question: 174
Question: 175
Question: 176
Question: 177
Question: 178
Question: 179
Question: 180
Question: 181
Question: 182
Question: 183
Question: 184
Question: 185
Question: 186
Question: 1 A MySQL database uses all InnoDB tables and is configured as follows: #MySQL 数据库使用所有 InnoDB 表,配置如下: shell>cat/ etc/ my.cnf [mysqld] log-bin server-id=1 You will be setting up a replication slave by using mysqldump. You will need a consistent backup taken from your running production server. The process should have minimal impact to active database connections. Which two arguments will you pass to mysqldump to achieve this? #您将使用 mysqldump 设置复制从机。您将需要从正在运行的生产服务器上获取一致的备份。 该进程应该对活动数据库连接的影响最小。为了实现这一点,您将把哪两个参数传递给 mysqldump? A. --skip-opt B. --lock-all-tables C. --create-apply-log D. --single-transaction E. --master-data Answer: DE 备份时要对服务器影响最小, --skip-opt 选 项 ,相 当 于 禁 用 下 面 几 个 参 数 : --add-drop-table, --add-locks,--create-options, --quick, --extended-insert,--lock-tables, --set-charset, and --disable-keys 选项 --create-option skip-opt 是--opt 的反操作,一般都是作为兼容性考虑,一般--opt 是默认打开的,可以提升 性能 --lock-all-tables --lock-tables lock-all-tables 锁了更多的表,对要导出的表影响更大了 --create-apply-log 没有这个参数 Lock all tables across all databases,对所有库的所有表加锁 Lock all tables before dumping them,对要导出的表加锁 --single-transactio n --master-data Issue a BEGIN SQL statement before dumping data from server,可以 保 证导出数据的一致性 Write the binary log file name and position to the output,导出日志 中显 示当前日志文件和位置,方便导入后做一致性恢复
Question: 2 It caches index blocks for MyISAM tables only. It caches index blocks for all storage engine tables. Consider the key buffer in a MySQL server. Which two statements are true about this feature? #考虑 MySQL 服务器中的 key buffer。关于这个特性,哪两种说法是正确的? A. #它只缓存 MyISAM 表的索引块。 B. #它缓存所有存储引擎表的索引块。 C. #它是一个全局缓冲区。 D. # D.按每个连接设置。 E. # E.它只缓存 InnoDB 表的索引块。 It is a global buffer. It is set on a per-connection basis. It caches index blocks for InnoDB tables only. Answer: A,C key_buffer_size 只对 myisam 表起作用,即使不使用 myisam 表,但是内部的临时磁盘表是 myisam 表, 也要使用该值。 key_buffer_size 只能用于 MyISAM 引擎 A 对 B 错 E 错, per_thread_buffers=(read_buffer_size+read_rnd_buffer_size+sort_buffer_size+thread_stac k+join_buffer_size+binlog_cache_size+tmp_table_size)*max_connections global_buffers=innodb_buffer_pool_size+innodb_additional_mem_pool_size+innodb_log_b uffer_size+key_buffer_size+query_cache_size key_buffer_size 是一种全局缓存,官方文档建议 key_buffer_size 设置为全局 25% 索引块 MyISAM 表缓冲和由所有线程共享。key_buffer_size 是用于索引块的缓冲区大小。关 键的缓冲区也被称为密钥缓存。 Question: 3 You have a MySQL replication setup and you intentionally stop the SQL thread on the slave. #您有一个 MySQL 复制设置,并且有意停止从机上的 SQL 线程。 mysql> SHOW SLAVE STATUS\ G Slave_IO_Running: Yes Slave_SQL_Running: No What are two reasons that you may stop the SQL thread on the slave while keeping the I/ O thread running? #在保持 I/O 线程运行的同时,可以停止从机上的 SQL 线程的两个原因是什么?
A. to allow the remaining events to be processed on the slave while not receiving new events from the master to allow a backup to be created under reduced load to allow for point-in-time recovery on the slave to prevent schema changes from propagating to the slave before they are validated #允许在从机上处理剩余的事件,而不从主机接收新事件 B. #允许在减少负载的情况下创建备份 C. #允许从机上的时间点恢复 D. # D.防止模式更改在验证之前传播到从属服务器 E. to prevent any transaction experiencing a deadlock Answer:BC 关闭 Slave_SQL_Running,slave 依旧要接收信息的,所以错 stopping only the SQL thread can be useful if you want to perform a backup or other task. B.不进行 sql 应用, 降低负载 C.没有 sql 应用,所以能取到当时时间点的数据 D.防止用户没有经过验证的改变,应该是指的延迟复制, CHANGE MASTER TO MASTER_DELAY =N; E.防止事务死锁, 没这效果 Stopping the I/O thread but permitting the SQL thread to run helps ensure that there is not a massive backlog of events to be executed when replication is started again. Question: 4 Which three statements correctly describe MySQL InnoDB Cluster? #哪三个语句正确地描述了 MySQL InnoDB 集群? A. The cluster can be operated in multimaster mode with conflict detection for DML statements. # A.集群可以在多主机模式下运行,并对 DML 语句进行冲突检测。 B. All MySQL client programs and connectors can be used for executing queries. #所有 MySQL 客户端程序和连接器都可以用于执行查询。 C. It provides fully synchronous replication between the nodes. #它在节点之间提供完全同步的复制。 D. There is support for automatic failover when one node fails. #当一个节点发生故障时,支持自动故障转移。 E. The data is automatically shared between the nodes.
# E.数据在节点之间自动共享。 F. Each query will be executed in parallel across the nodes. # F.每个查询将跨节点并行执行。 Answer: ABD mysql innodb cluster 为 mysql 提供了一个完整的高可用性解决方案。 mysql shell 包含 adminapi, 它使您 能够轻松地配置和管理至少三个 mysql 服务器实例组, 以作为 innodb 集群。 每个 mysql 服务器实例都 运行 mysqlgroup replication,它提供了在 innodb 集群内复制数据的机制,并内置故障转移。adminapi 消 除了在 InnoDB 集群中直接使用组复制的需要, 但有关更多信息, 请参阅第 17 章, 组复制, 其中解 释了详细信息。 MySQL 路由器可以根据您部署的集群自动配置自己, 将客户机应用程序透明地连接到服 务器实例。 如果服务器实例发生意外故障, 群集将自动重新配置。 在默认的单主模式下, InnoDB 集群 有一个读写服务器实例——主服务器。 多个辅助服务器实例是主服务器的副本。 如果主服务器出现故障, 辅助服务器将自动提升为主服务器的角色。 MySQL 路由器检测到这一点, 并将客户端应用程序转发到新 的主服务器。 高级用户还可以将集群配置为具有多个主要副本 https://dev.mysql.com/doc/refman/5.7/en/group-replication.html 组可以在具有自动主要选举的单主模式下操作, 其中一次只有一个服务器接受更新。 或者, 对于更高级 的用户, 可以在多主模式下部署组, 其中所有服务器都可以接受更新, 即使它们是同时发布的。 A 对 B 对, Group Replication ensures that a transaction only commits after a majority of the members in a group have
received it and agreed on the relative order between all transactions that were sent concurrently. This approach works well if the total number of writes to the group does not exceed the write capacity of any member in the group. If it does and some of the members have less write throughput than others, particularly less than the writer members, those members can start lagging behind of the writers. 组复制可确保事务仅在组中的大多数成员收到事务后提交, 并同意所有并发发送的事务之间的相对顺序。 如果对组的写入总数不超过组中任何成员的写入容量, 则此方法很有效。 如果确实如此, 并且某些成员 的写入吞吐量低于其他成员, 特别是少于作者成员, 那些成员可能会开始落后于作者。 C 错 D 对 Finally, Group Replication is a shared-nothing replication scheme where each server has its own entire copy of the data. E 错 Question: 5 The innodb_locks_unsafe_for_binlog setting determines which transaction is rolled back. How does the InnoDB storage engine handle deadlocks when they are detected? #当检测到死锁时,InnoDB 存储引擎如何处理它们? A. Both the affected transactions will be rolled back. # A.两个受影响的事务都将回滚。 B. The affected transactions wait for innodb_lock_wait_timeout seconds, and then roll back. # B.受影响的事务等待 innodb_lock_wait_超时秒,然后回滚。 C. One of the affected transactions will be rolled back, the other is allowed to proceed. #一个受影响的事务将回滚,另一个允许继续。 D. The transaction isolation level determines which transaction is rolled back. # D.事务隔离级别决定回滚哪个事务。 E. # E.innodb_locks_unsafe_for_binlog 设置确定回滚哪个事务。 Answer: C 解析: 这道题问的是已经检测到死锁会如何处理 A 错,一个会回滚,一个会正常继续的 B 错,当检测到死锁时会报错而直接回滚,不是解决死锁的 C 正确 D 错决定如何回滚和隔离级别没关系,和事务处理的数据数量有关,会回滚事务(处理的 行数)较小的 E 错误,innodb_locks_unsafe_for_binlog 最主要的作用就是控制 innodb 是否对 gap 加 锁,对 rollback 没影响
Question: 6 Which three allocate memory per thread in MySQL? #在 MySQL 中,哪三个线程分配内存? A. query cache B. thread cache C. read buffer D. internal temporary table E. sort buffer F. InnoDB buffer pool instance Answer: C,D,E A query cache 是全局的, A 错 B When a thread is no longer needed, the memory allocated to it is released and returned to the system unless the thread goes back into the thread cache. In that case, the memory remains allocated. B 错 F .InnoDB buffer pool instance 指的是个数, 不是内存 答案应该是 CDE 首先我们来看一个公式, MySQL 中内存分为全局内存和线程内存两大部分( 其实并 不全部, 只是影响比较大的 部分): per_thread_buffers=(read_buffer_size+read_rnd_buffer_size+sort_buffer_size+thread_stack +join_buffer_size+binlog_cache_size+tmp_table_size)*max_connections global_buffers=innodb_buffer_pool_size+innodb_additional_mem_pool_size+innodb_log_b uffer_size+key_buffer_size+query_cache_size total_memory=global_buffers+per_thread_buffers 全局缓存: key_buffer_size: 决定索引处理的速度, 尤其是索引读的速度。 默认值是 16M, 通 过检查状态值 Key_read_requests 和 Key_reads, 可以知道 key_buffer_size 设置是否 合理。比例 key_reads / key_read_requests 应该尽可能的低,至少是 1:100,1:1000 更 好( 上述状态值可以使用'key_read%'获得用来显示状态数据)。 key_buffer_size 只对 MyISAM 表起作用。 即使你不使用 MyISAM 表, 但是内部的临时磁盘表是 MyISAM 表, 也要使用该值。 可以使用检查状态值'created_tmp_disk_tables'得知详情。 innodb_buffer_pool_size: InnoDB 使用该参数指定大小的内存来缓冲数据和索引, 这 个是 Innodb 引擎中影响性能最大的参数。 innodb_additional_mem_pool_size: 指定 InnoDB 用来存储数据字典和其他内部数据结 构的内存池大小。 缺省值是 8M。 通常不用太大, 只要够用就行, 应该与表结构的 复杂度有关系。 如果不够用, MySQL 会在错误日志中写入一条警告信息。 innodb_log_buffer_size: 指定 InnoDB 用来存储日志数据的缓存大小, 如果您的表操 作中包含大量并发事务( 或大规模事务), 并且在事务提交前要求记录日志文件, 请
尽量调高此项值, 以提高日志效率。 query_cache_size: 是 MySQL 的查询缓冲大小。( 从 4.0.1 开始, MySQL 提供了查 询缓冲机制) 使用查询缓冲, MySQL 将 SELECT 语句和查询结果存放在缓冲区中, 今 后对于同样的 SELECT 语句( 区分大小写),将直接从缓冲区中读取结果。根据 MySQL 用户手册,使用查询缓冲最多可以达到 238%的效率。 通过检查状态值’Qcache_%’, 可 以知道 query_cache_size 设置是否合理: 如果 Qcache_lowmem_prunes 的值非常大, 则表明 经常出现缓冲不够的情况, 如果 Qcache_hits 的值也非常大, 则表明查询缓冲使用非 常频繁,此时需要增加缓冲大小; 如果 Qcache_hits 的值不大, 则表明你的查询重复 率很低, 这种情况下使用查询缓冲反而会影响效率, 那么可以考虑不用查询缓冲。 此 外, 在 SELECT 语句中加入 SQL_NO_CACHE 可以明确表示不使用查询缓冲。 线程缓存 每个连接到 MySQL 服务器的线程都需要有自己的缓冲。 大概需要立刻分配 256K, 甚 至在线程空闲时, 它们使用默认的线程堆栈, 网络缓存等。 事务开始之后, 则需要 增加更多的空间。 运行较小的查询可能仅给指定的线程增加少量的内存消耗, 然而如 果对数据表做复杂的操作例如扫描、 排序或者需要临时表, 则需分配大约 read_buffer_size,sort_buffer_size, read_rnd_buffer_size, tmp_table_size 大小的内存 空间。 不过它们只是在需要的时候才分配, 并且在那些操作做完之后就释放了。 有 的是立刻分配成单独的组块。tmp_table_size 可能高达 MySQL 所能分配给这个操作的 最大内存空间了。 read_buffer_size: 是 MySQL 读入缓冲区大小。 对表进行顺序扫描的请求将分配一个 读入缓冲区, MySQL 会为它分配一段内存缓冲区。 read_buffer_size 变量控制这一缓 冲区的大小。 如果对表的顺序扫描请求非常频繁, 并且你认为频繁扫描进行得太慢, 可以通过增加该变量值以及内存缓冲区大小提高其性能。 sort_buffer_size: 是 MySQL 执行排序使用的缓冲大小。 如果想要增加 ORDER BY 的 速度,首先看是否可以让 MySQL 使用索引而不是额外的排序阶段。 如果不能, 可以 尝试增加 sort_buffer_size 变量的大小。 read_rnd_buffer_size: 是 MySQL 的随机读缓冲区大小。 当按任意顺序读取行时(例如, 按照排序顺序), 将分配一个随机读缓存区。 进行排序查询时, MySQL 会首先扫描一 遍该缓冲, 以避免磁盘搜索, 提高查询速度, 如果需要排序大量数据, 可适当调高 该值。 但 MySQL 会为每个客户连接发放该缓冲空间, 所以应尽量适当设置该值, 以 避免内存开销过大。 tmp_table_size: 是 MySQL 的临时表缓冲大小。 所有联合在一个 DML 指令内完成, 并且大多数联合甚至可以不用临时表即可以完成。 大多数临时表是基于内存的(HEAP) 表。 具有大的记录长度的临时表 (所有列的长度的和)或包含 BLOB 列的表存储在硬盘 上。 如果某个内部 heap(堆积) 表大小超过 tmp_table_size, MySQL 可以根据需要
自动将内存中的 heap 表改为基于硬盘的 MyISAM 表。还可以通过设置 tmp_table_size 选项来增加临时表的大小。也就是说, 如果调高该值, MySQL 同时将增加 heap 表 的大小, 可达到提高联接查询速度的效果。 thread_stack : 主要用来存放每一个线程自身的标识信息, 如线程 id, 线程运行时 基本信息等等, 我们可以通过 thread_stack 参数来设置为每一个线程栈分配多大的内 存。 join_buffer_size: 应用程序经常会出现一些两表(或多表) Join 的操作需求, MySQL 在完成某些 Join 需求的时候(all/index join), 为了减少参与 Join 的“被驱动表”的读 取次数以提高性能, 需要使用到 Join Buffer 来协助完成 Join 操作。 当 Join Buffer 太 小, MySQL 不会将该 Buffer 存入磁盘文件, 而是先将 Join Buffer 中的结果集与需要 Join 的表进行 Join 操作, 然后清空 Join Buffer 中的数据, 继续将剩余的结果集写入 此 Buffer 中, 如此往复。这势必会造成被驱动表需要被多次读取, 成倍增加 IO 访 问, 降低效率。 binlog_cache_size: 在事务过程中容纳二进制日志 SQL 语句的缓存大小。 二进制日志 缓存是服务器支持事务存储引擎并且服务器启用了二进制日志(—log-bin 选项)的前提 下为每个客户端分配的内存, 注意, 是每个 Client 都可以分配设置大小的 binlog cache 空间。 如果系统中经常会出现多语句事务的话, 可以尝试增加该值的大小, 以 获得更好的性能。当然, 我们可以通过 MySQL 的以下两个状态变量来判断当前的 binlog_cache_size 的状况:Binlog_cache_use 和 Binlog_cache_disk_use。 “max_binlog_cache_size”: 和"binlog_cache_size"相对应, 但是所代表的是 binlog 能够 使用的最大 cache 内存大小。 当我们执行多语句事务的时候, max_binlog_cache_size 如果不够大的话, 系统可能会报出“ Multi-statement transaction required more than 'max_binlog_cache_size' bytes ofstorage”的错误。 其中需要注意的是: table_cache 表示的是所有线程打开的表的数目, 和内存无关。 Question: 7 You are setting up a new installation of MySQL Server 5.7 (a GA release.) You have used a ZIP or TAR package to ensure that the mysqld binary, along with its support files, such as plug-ins and error messages, now exist on the host. Assume that the default datadir exists on the host. You installed the binary in the default location (the default --basedir value) for your operating system. Which step should you perform before defining your own databases and database tables? #您正在安装 MySQL Server 5.7(GA 释放)的新安装。您已经使用了 ZIP 或 TAR 包,以确保 MySQL 二进制文件及其支持文件(例如插件和错误消息)现在存在于主机上。
分享到:
收藏