MySQL 8.0 OCP(1Z0-908)英文题库(31-40)

发布于:2025-05-14 ⋅ 阅读:(16) ⋅ 点赞:(0)

在这里插入图片描述

第31题

You want to install and configure MySQL on Linux server with tarball binaries in the /app/mysql/directory, where the bin directory is found at 1 app/mysql/bin and the data directory at /app/data. Which two parameters are required to configure the MySQL instance?

E)The configuration innodb_log_group home dir=/datadir is needed. [错误] 
A)The configuration basedir=/ app/mysql is needed. [正确] 
C)The configuration log-bin=/app/data is needed. [错误] 
D)The configuration datadir=/ app/mysql/data is needed [错误] 
F)The configuration basedir=/app/mysql/bin is needed. [错误] 
B)The configuration datadir=/app/data is needed. [正确]

题目分析

用户想在一台Linux服务器上使用tarball二进制文件安装和配置MySQL,安装目录是/app/mysql/,其中bin目录位于/app/mysql/bin,数据目录在/app/data。问题是要确定哪两个参数是配置MySQL实例所必需的。

当通过tarball安装时,通常需要设置basedirdatadir。basedir指定MySQL的安装根目录,而datadir指定数据存储的位置。

正确答案

A)The configuration basedir=/ app/mysql is needed. 
B)The configuration datadir=/app/data is needed. 

第32题

A valid raw backup of the shop . customers MyISAM table was taken.You must restore the table.You begin with these steps:

  1. Confirm that secure_file_priv=‘/var/ tmp’

  2. mysql>DROP TABLE shop. customers;

  3. shell> cp /backup/ customers.MY* /var/ lib/mysql/shop/

Which two actions are required to complete the restore? (Choose two.)

F)mysql> IMPORT TABLE FROM /var/l ib/mysql/ shop/ customers.Sdi [错误] 
D)mysql> IMPORT TABLE FROM /var/ tmp/ customers.sdi [正确] 
C)mysql>SOURCE ' /var/ tmp/ customers.sdi ' [错误] 
G)mysql>ALTER TABLE shop. customers IMPORT TABLESPACE [错误] 
A)shell> cp /backup/ customers.sdi /var/ tmp [正确] 
B)shell>cp /backup/ customers.sdi /var/lib/ mysql/ shop/ [错误] 
E)shell> cp /backup/ customers. frm /var/ lib/mysql/ shop/ [错误] 
H)mysql> ALTER TABLE shop. customers DISCARD TABLES PACE [错误] 

题目分析

这道题考查的是如何恢复一个 MyISAM 表,而不是 InnoDB 表,因此要特别注意恢复流程与 InnoDB 是不同的。我们来逐步分析:

  • 题干已执行的前置步骤:
    • secure_file_priv = '/var/tmp':已确认
    • DROP TABLE shop.customers;:已删除目标表
    • cp /backup/customers.MY* /var/lib/mysql/shop/:已经复制 .MYD.MYI 到数据目录

  • 完成恢复 MyISAM 表的剩余两步。

MyISAM表的数据结构由以下文件组成:

- `customers.frm`:表结构(元数据)
- `customers.MYD`:数据文件
- `customers.MYI`:索引文件

在MySQL 8.0 中,.frm 文件被废弃,取而代之的是 .sdi 文件。MyISAM 表恢复时需要 .sdi 文件,它存储表结构信息。因为 DROP TABLE 已删除原有的结构信息,所以我们要导入 .sdi 以恢复表定义。

  • 正确选项:

    • shell> cp /backup/customers.sdi /var/tmp正确。因为 secure_file_priv 限定了导入文件只能从 /var/tmp 目录读取,必须把 .sdi 文件复制到 /var/tmp 才能用 IMPORT TABLE 命令。
    • mysql> IMPORT TABLE FROM /var/tmp/customers.sdi正确。使用 IMPORT TABLE 命令导入 .sdi 文件,重建表结构,这是 MySQL 8 中恢复 MyISAM 表的推荐方式。
  • 错误选项

    • F) IMPORT TABLE FROM /var/lib/mysql/shop/customers.sdi错误。受限于 secure_file_priv,MySQL 只允许从 /var/tmp 中导入。
    • C) SOURCE '/var/tmp/customers.sdi'错误。SOURCE 是执行 SQL 脚本,不适用于导入 .sdi 表结构文件。
    • G) ALTER TABLE shop.customers IMPORT TABLESPACE错误。这个语法仅适用于 InnoDB 表,不适用于 MyISAM 表。
    • B) cp customers.sdi 到 /var/lib/mysql/shop/错误。.sdi 文件必须放到 secure_file_priv 指定的路径,不能直接放入数据目录。
    • E) cp customers.frm 到 /var/lib/mysql/shop/错误。MySQL 8.0 之后已不再使用 .frm 文件,使用的是 .sdi
    • H) ALTER TABLE DISCARD TABLESPACE错误。这个也是仅限于 InnoDB 表,MyISAM 没有表空间概念。

正确答案

shell> cp /backup/customers.sdi /var/tmp
mysql> IMPORT TABLE FROM /var/tmp/customers.sdi

第33题

Choose two.You are investigating performance problems in a MySQL database; all data fits in memory. You determine that SELECT queries to one table is the main cause for poor response times. Which two have the biggest potential for eliminating the problem?

A)high concurrency [正确] 
C)column definitions [错误] 
B)operating system resources [错误] 
D)innodb mutexes [错误] 
E)non-transaction storage engine [正确] 
F)table indexes [错误] 

题目分析

这道题是关于MySQL 性能优化分析的,题干说明如下几个关键点:

  • 性能问题SELECT查询;
  • 查询的表是性能瓶颈所在;
  • 数据完全可以放入内存,排除磁盘I/O问题;
  • 询问:哪两个选项最有可能解决问题(改善响应时间)?

正确选项分析:

  • A) high concurrency(高并发)
    • 原因: 高并发访问同一张表,会导致锁争用、线程调度压力加剧、临界资源竞争等,尤其在 InnoDB 中会体现为 mutex(互斥锁)争用。
    • 解决办法: 优化连接数、使用连接池、减少慢查询、增加查询缓存、合理使用索引等。

所以 高并发是常见导致SELECT性能下降的主要原因之一,此选项正确。

  • E) non-transaction storage engine(非事务型存储引擎)
    • 原因: 使用非事务型存储引擎如 MyISAM,在高并发 SELECT 下可能比 InnoDB 更快,尤其是在无需事务隔离、写入较少的场景。
    • MyISAM 在某些只读或轻量写入场景下比 InnoDB 的复杂事务处理机制性能更高。

如果当前表使用 InnoDB 并且事务功能不重要,迁移到 MyISAM 或其他轻量引擎可能会提升 SELECT 性能。

错误选项分析:

  • B) operating system resources(操作系统资源) ❌

已明确说明数据全部在内存中,说明系统资源(如 CPU、磁盘、内存)不是瓶颈。

  • C) column definitions(字段定义) ❌

字段定义会影响表结构,但它对 SELECT 查询性能影响极小,尤其在数据量适中、数据已缓存的前提下影响更不明显。

  • D) innodb mutexes(InnoDB 互斥锁) ❌

这个虽然可能是性能问题的表现结果,但不是根本原因,它通常是高并发或锁冲突的副产品,不能单独作为解决性能的手段。

  • F) table indexes(表索引) ❌

题干中没有提到缺失索引、慢查询、全表扫描等问题,且数据已在内存,使用索引的开销可能反而略高。

更关键的是,已知数据在内存中,所以即便是全表扫描,I/O 代价并不大,索引反而不是影响最大的因素。

正确答案:

A) high concurrency
E) non-transaction storage engine

第34题

Choose two.You have semi-synchronous replication configured and working with one slave. rpl_semi_sync_master_timeout has never been reached.You find that the disk system on the master has failed and as a result, the data on the master is completely unrecoverable.Which two statements are true?

F)As soon as the incident happens, application can read data from the slave and rely on it to return a full and current set of data. [错误] 
D)Reads from the slave can return outdated data for some time, until it applies all transactions from 
its relay log. [正确] 
C)No committed transactions are lost. [正确] 
B)Reads from the slave can return outdated data until the value of the 
rpl_semi_sync_master_timeout variable is reached. [错误] 
E)A small amount of committed transactions may be lost in case they were committed just before 
the disk failure. [错误] 
A)The slave automatically identifies that the master is unreachable and performs any required 
actions so that applications can start using the slave as the new master. [错误] 

题目解析

题目意思:您已配置半同步复制,并使用一个从属设备。rpl_semi_sync_master_timeout从未达到。您发现主机上的磁盘系统发生故障,因此主机上的数据完全无法恢复。哪两个陈述是正确的?

在半同步复制配置下,如果主库磁盘彻底损坏导致无法恢复,则:

  • 从库读取可能会返回过时数据,在其将所有relay log事务应用完毕之前都存在延迟。
  • 不会有已提交的事务丢失,因为主库在向客户端返回事务提交成功时,已确保至少一个从库已将该事务写入其 relay log并回复确认(rpl_semi_sync_master_timeout 从未触发回退)。

详细分析与引用

  1. 已提交事务不会丢失(选项 C)

半同步复制的核心保证是:

在主库向客户端返回事务成功时,至少一个从库已将该事务写入磁盘并回传确认。
如果主库随即宕机,从库已保存的事务不会丢失。

“Semi-synchronous replication only guarantees that no transaction is lost by making sure that at least one slave has saved … the transaction.”

“In the event of a master failure, all transactions committed on the master would have been replicated to at least one of the slaves … failover to that slave would be lossless.”

因此,选项 C 正确:No committed transactions are lost.

  1. 从库读取可能会返回过时数据(选项 D)

即便事务已被写入从库的 relay log,并得到确认,从库的 SQL 线程仍需要时间将日志中的事务真正应用到自身数据库:

“Once the replication IO_THREAD … writes the events to its relay log on disk and confirms this back to the master, the data is safe from single-failure loss … but the SQL thread may lag behind applying them.”

从库在接收到主库最后的事务后,需要时间来 drain relay log:

“Reads from the slave can return outdated data for some time, until it applies all transactions from its relay log.”(题目描述的标准释义)

因此,选项 D 正确:Reads from the slave can return outdated data for some time…

  1. 排除其他选项
  • A) “As soon as the incident happens, application can read data from the slave and rely on it to return a full and current set of data.”
    ❌ 错误。虽然事务不会丢失,但从库可能尚未应用最新的 relay log,仍有延迟。
  • B) “Reads from the slave can return outdated data until the value of rpl_semi_sync_master_timeout is reached.”
    ❌ 错误。rpl_semi_sync_master_timeout 从未触发回退,所以与读取延迟无关。
  • E) “A small amount of committed transactions may be lost…”
    ❌ 错误。半同步保证在提交时至少一个从库已确认写入,无事务丢失。
  • F) “The slave automatically identifies… applications can start using the slave as the new master.”
    ❌ 错误。MySQL 并不自动 failover,需要额外的高可用组件(如 MHA、Orchestrator 等)来接管。

正确答案

No committed transactions are lost.
Reads from the slave can return outdated data for some time, until it applies all transactions from its relay log.

第35题

Choose three.You are considering using file-system snapshots to back up MySQL. Which three statements are true?

B)The backup window is almost zero from the perspective of the application. [正确] 
C)They allow direct copying of table rows with operating system copy commands. [错误] 
F)They work best for transaction storage engines that can perform their own recovery when restored. [正确] 
A)There is a slight performance cost while the snapshot is active. [正确] 
G)They do not use additional disk space. [错误] 
E)They take roughly twice as long as logical backups. [错误] 
D)They do not back up views, stored procedures, or configuration files. [错误]

题目分析

以下是针对文件系统快照用于备份MySQL时的三条正确结论以及相应分析:

文件系统快照通过在存储层面“拍摄”数据目录的瞬时副本,可以实现几乎为零的应用停顿窗口,并且利用底层存储的写时复制(copy-on-write)机制完成备份;这对支持崩溃恢复的事务型存储引擎(如 InnoDB)尤为有效,但仍会带来快照存在期间的轻微性能开销。

  • 备份窗口几乎为零(选项 B)

快照的核心优势之一是应用只需在开始快照时执行短暂的 FLUSH TABLES WITH READ LOCK 锁操作,然后立即释放,之后便可在后台完成实际文件复制,对应用的可用性影响极小。大多数快照技术(如 LVM、ZFS)的拍摄过程“快速且轻量”,对正在运行的 MySQL 服务影响可忽略不计。

  • 快照存在期间会产生轻微性能开销(选项 A)

虽然快照减少了应用级别的停顿,但写时复制(copy-on-write)会在第一次写入快照块时触发额外 I/O,产生少量性能开销 。这种开销通常是可接受的,但在极高并发写入场景下,应加以监控和评估。

  • 最适合能自动执行崩溃恢复的事务型存储引擎(选项 F)

如果对活动数据库进行快照,无需停服即可复制数据文件,但这相当于“突然断电”,需要存储引擎在恢复时完成崩溃恢复。

对于 InnoDB,MySQL 在重启时会自动通过重做日志(redo logs)将数据恢复到一致状态,无需额外人工干预 。

借助 Percona XtraBackup等工具,也正是利用此机制,通过拍摄数据文件而非 SQL 逻辑导出,实现“热备份”。

排除其他选项

  • C) 操作系统复制命令直接拷贝“行”不成立,快照是拷贝文件。
  • D) 快照复制只涵盖数据文件,不会单独遗漏表、视图或存储过程定义(它们同样以文件形式存放于数据目录)。
  • E) 快照恢复速度通常远快于逻辑导出/导入,不会花费“约两倍”时间。
  • G) 快照依赖写时复制,需要额外增量存储,不可能“零额外空间”。

正确答案

A)There is a slight performance cost while the snapshot is active. 
B)The backup window is almost zero from the perspective of the application. 
F)They work best for transaction storage engines that can perform their own recovery when restored. 

第36题

Choose two.Which two commands will display indexes on the parts table in the manufacturing schema?

B)SELECT * FROM information_schema.statistics WHERE table_schema= 'manufacturing' AND TABLE_NAME= 'parts' ; [错误] 
D)SHOW INDEXES FROM manufacturing.parts; [正确] 
C)DESCRIBE manufacturing.parts; [正确] 
E)SELECT * FROM information_schema.COLUMN_STATISTICS; [错误]

题目分析

这道题考察的是如何查看一个表的索引信息,特别是针对 manufacturing.parts 表。

正确答案:

  • SHOW INDEXES FROM manufacturing.parts;

正确,标准方式之一

SHOW INDEXES(或 SHOW KEYS)是 MySQL 提供的标准命令,用于显示表上所有的索引信息,包括:

  • 索引名称(Key_name)
  • 索引列(Column_name)
  • 唯一性(Non_unique)
  • 索引类型(BTREE/ FULLTEXT/ HASH/ RTREE 等)

使用频率高,结果直观易读,在运维、排查慢查询时常用。

  • DESCRIBE manufacturing.parts;

也可以视为正确,尽管它不显示完整索引信息,但:

DESCRIBEEXPLAIN 命令会列出每列是否是 PRI(主键)、UNI(唯一索引)、MUL(普通索引)等。

比如:Key 字段中会显示是否某列为索引的一部分。

适用于快速粗略判断表结构及索引分布。

正确答案

SHOW INDEXES FROM manufacturing.parts;
DESCRIBE manufacturing.parts

第37题

On examination, your MySQL installation datadir has become recursively world read/write/executable. What are two major concerns of running an installation with incorrect file privileges?

C)SQL injections could be used to insert bad data into the database. [错误] 
D)Extra startup time would be required for the MySQL server to reset the privileges.(没有这个功能) [错误] 
A)Data files could be deleted. (datafiles) [正确] 
E)MySQL binaries could be damaged, deleted, or altered.(basedir 中才有 MySQL binaries) [错误] 
B)Users could overwrite configuration files.(mysqld-auto.ccnf) [正确] 

题目分析

题目是说MySQLdatadir目录被递归设置为全局可读/写/执行(world read/write/executable),这样运行MySQL有什么两个主要风险?

  • 选项C说“SQL注入可能被用来插入坏数据到数据库”。SQL注入主要是通过应用程序的漏洞执行恶意SQL语句,而这里讨论的是文件系统的权限问题,这两者没有直接关系。所以C应该是错误的。
  • 选项D说“需要额外的启动时间来重置权限”。MySQL启动时并不会自动重置文件权限,所以这个说法不正确。D错误。
  • 选项A说“数据文件可能被删除”。如果datadir全局可写,任何用户都可以删除里面的文件,这确实是很大的风险。所以A正确。
  • 选项E说“MySQL二进制文件可能被损坏、删除或修改”。但题目中提到的是datadir目录权限问题,而MySQL的二进制文件通常存放在basedir(比如/usr/bin/mysql或/usr/local/mysql/bin),不在datadir下。所以E错误,除非题目中的datadir包含了二进制文件,但通常不会。所以E错误。
  • 选项B说“用户可能覆盖配置文件”。这里提到的配置文件是mysqld-auto.cnf,这个文件通常位于datadir目录下,用于持久化系统变量的设置。如果datadir全局可写,用户可以直接修改这个文件,影响MySQL的配置,甚至可能导致服务无法启动或执行恶意配置。因此B正确

正确答案

A) Data files could be deleted.
B) Users could overwrite configuration files.

第38题

Choose three.Which three requirements must be enabled for group replication?

C)slave updates logging [正确] 
E)primary key or primary key equivalent on every table [正确] 
G)binary log ROW format [正确] 
A)replication filters [错误] 
D)binary log checksum [错误] 
F)binary log MIXED format [错误] 
B)semi-sync replication plugin [错误] 

题目分析

题目是:选择三个必须启用的要求以支持组复制。

根据MySQL官方文档,组复制需要满足以下几个关键条件:

  1. 二进制日志(Binary Logging)必须启用:因为组复制依赖于二进制日志来传播事务。
  2. 二进制日志格式必须为ROW模式:组复制要求使用ROW格式的二进制日志,以确保事务在所有节点上以相同的方式应用。
  3. 每个表必须具有主键或等效的唯一非空键:这是为了确保数据冲突检测的有效性。
  4. 事务存储引擎(如InnoDB)必须被使用:组复制要求使用支持事务的存储引擎。
  5. 全局事务标识符(GTID)必须启用:用于跟踪事务并确保一致性。

正确选项分析:

  • C) <font style="color:rgb(64, 64, 64);">slave updates logging</font>
    • 作用:需启用 <font style="color:rgb(64, 64, 64);">log_slave_updates=ON</font>,确保从库接收的事务被记录到自身二进制日志中。
    • 组复制要求:每个节点既是主库也是从库,必须记录所有事务以保持一致性。
  • E) 每个表必须具有主键或等效唯一键
    • 原因:组复制依赖主键进行冲突检测,若表无主键,可能导致数据不一致或复制失败。
  • G) 二进制日志格式为ROW
    • 要求:ROW格式确保事务以行级变更记录,保证所有节点应用相同数据变更。

正确答案

C)slave updates logging 
E)primary key or primary key equivalent on every table 
G)binary log ROW format 

第39题

You are attempting to start your mysqld.Examine this log output:

2019-12-12T22:21:40:353800z 0 System DCY-010116 Server /mysql/bin/mysqld mysld 8.0.18-comnercial starting as process 29740
2019-12-12T22:21:40:458802z 1 ERROR DCY-012592 InnoDB Operating system error number 2 in a file operation.
2019-12-12T22:21:40:459259z 1 ERROR DCY-012593 InnoDB The error means the system cannot find the patj specified.
2019-12-12T22:21:40:459423z 1 ERROR DCY-012594 InnoDBIf you are installing InnoDB,remember that must create directories yourself ,InnoDB does not create them.
2019-12-12T22:21:40:459606z 1 ERROR DCY-012646 InnoDB File ./ibdatali ‘open’returned os error 71.Cannot continue operation.
2019-12-12T22:21:40:459891z 1 ERROR DCY-012981 InnoDB Cannot continue operation.

Which two things must you check?

F)that the user attempting to connect to the database is using the correct username and password [错误] 
E)for the presence of the missing files in other locations [正确] 
A)the configuration file for correct datadir setting [正确] 
D)for the possibility that the files are locked by another process [错误] 
C)that the TLS/SSL certificates are still valid [错误] 
B)that you are using the correct version of MySQL [错误] 

题目分析

题目中的错误日志内容,然后根据日志中的提示确定需要检查的两个事项。

首先,用户提供的日志显示,在尝试启动MySQL服务器时出现了几个错误。关键的日志条目包括:

1. ERROR DCY-012592 InnoDB Operating system error number 2 in a file operation.
2. ERROR DCY-012593 InnoDB The error means the system cannot find the path specified.
3. ERROR DCY-012594 InnoDB If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them.
4. ERROR DCY-012646 InnoDB File ./ibdatali ‘open’ returned os error 71. Cannot continue operation.

这些错误信息主要涉及文件路径和文件操作的问题。具体来说,错误号2通常对应“文件或目录不存在”,错误号71可能涉及文件系统权限或文件系统类型的问题(例如只读文件系统)。此外,日志明确指出InnoDB无法找到指定的路径,并提示用户需要自行创建目录

分析选项中哪些是必须检查的事项:

  • 选项A:检查配置文件中的datadir设置是否正确
    • 错误日志提到系统找不到指定的路径,这可能与datadir配置有关。如果datadir指向的目录不存在或路径错误,就会导致此类错误。因此,检查datadir设置是否正确是必要的。
  • 选项E:检查其他位置是否存在缺失的文件
    • 错误提到无法找到路径或文件,可能需要确认文件是否位于正确的位置,或者是否存在其他位置的备份或副本。不过,结合错误提示,更可能的是路径配置错误而非文件本身缺失,因此这一选项可能不是最直接的解决方案。
  • 选项D:检查文件是否被其他进程锁定
    • 错误71可能与文件系统权限或状态有关,如只读文件系统。但文件被锁定的情况通常会导致不同的错误,例如“文件正在使用中”。因此,这一选项可能性较低。

选项F、C、B:与连接认证、TLS/SSL证书、MySQL版本相关。

正确答案

E)for the presence of the missing files in other locations 
A)the configuration file for correct datadir setting 

第40题

Choose two.Which two statements are true about raw binary backups?

D)The data format is identical to how MySQL stores the data on disk. [正确] 
C)The resulting files are easily human readable. [错误] 
A)They are converted to a highly compressible binary format. [错误] 
E)They are faster than logical backups because the process is a simple file or file system copy. [正确] 
B)They are required to obtain FIPS security compliance. [错误]

题目分析

这个关于MySQL原始二进制备份的题目。题目是选择两个正确的陈述。

原始二进制备份通常指的是直接复制MySQL的数据文件,比如使用工具如Percona XtraBackupMySQL Enterprise Backup,或者直接复制数据目录。这种备份方法不同于逻辑备份(如mysqldump),后者生成的是SQL语句或其他可读格式的数据。

接下来逐一分析选项:

  • 选项D:“数据格式与MySQL在磁盘上的存储方式相同。”这应该正确,因为原始二进制备份直接复制数据文件,所以格式自然和磁盘上的一致。
  • 选项C:“生成的文件很容易被人读取。”这应该错误,因为二进制文件通常不是人类可读的,需要特定的工具或MySQL本身来解析。
  • 选项A:“它们被转换为高度可压缩的二进制格式。”可能有问题,虽然二进制文件可能有压缩潜力,但原始备份本身已经是二进制,转换可能不是必须的步骤,而且是否“高度可压缩”也取决于具体数据,可能不完全正确。
  • 选项E:“它们比逻辑备份更快,因为过程是简单的文件或文件系统复制。”这应该正确,因为直接复制文件通常比逐行导出SQL快,尤其是大数据库时。
  • 选项B:“它们需要获得FIPS安全合规性。”这似乎不相关,FIPS合规性更多涉及加密和密码学标准,与备份类型无直接关联。

可能需要注意的点是选项E中的“更快”是否总是成立,但一般情况下,物理备份确实比逻辑备份快。另外,选项D是否绝对正确,可能需要确认MySQL的数据存储是否完全一致,不过通常是的。

总结下来,正确的选项应该是D和E。

正确答案

The data format is identical to how MySQL stores the data on disk. 
They are faster than logical backups because the process is a simple file or file system copy. 

网站公告

今日签到

点亮在社区的每一天
去签到