作者:马顺华
从事运维管理工作多年,目前就职于某科技有限公司,熟悉运维自动化、OceanBase部署运维、MySQL 运维以及各种云平台技术和产品。并已获得OceanBase认证OBCA、OBCP证书。
OB 生态工具 ob_error 是 OceanBase 数据库的一个错误码解析工具,ob_error 可以根据您输入的错误码返回相对应的原因和解决方案。在 ob_error 的帮助下,您无需查找文档即可获取基本的错误信息。
机器信息
机器类型 | 主机配置 | 备注 |
---|---|---|
OS | Centos 7.4 | |
中控机 /OBD | CPU:8C | 内存:16G |
目标机器 /OBserver | CPU:16C | 内存:64G |
系统盘 / | dev/vda 50G | LVS分区、文件系统:EXT4 |
数据盘 /data | dev/vdb 100G | GPT分区、文件系统:xfs |
事务日志盘 /redo | dev/vdc 100G | GPT分区、文件系统:xfs |
一、如何构建 ob_error 错误码解析工具
1、配置 YUM 源
[root@CAIP131 ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo adding repo from: https://mirrors.aliyun.com/oceanbase/OceanBase.repo grabbing file https://mirrors.aliyun.com/oceanbase/OceanBase.repo to /etc/yum.repos.d/OceanBase.repo repo saved to /etc/yum.repos.d/OceanBase.repo
复制
2、YUM安装 OB-CE-utils 运维小工具(可选)
[root@CAIP131 ~]# yum install oceanbase-ce-utils base | 3.6 kB 00:00:00 epel/x86_64/metalink | 5.1 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 oceanbase.community.stable | 3.0 kB 00:00:00 oceanbase.development-kit | 3.0 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/3): oceanbase.community.stable/7/x86_64/primary_db | 48 kB 00:00:00 epel/x86_64/updateinfo FAILED | 2.8 MB 00:00:58 ETA https://mirror.nevacloud.com/fedora/fedora-epel/7/x86_64/repodata/1239e77ff175271844debbbdde2eee1db3817b61f980631d308d76751a80844e-updateinfo.xml.bz2: [Errno 12] Timeout on https://mirror.nevacloud.com/fedora/fedora-epel/7/x86_64/repodata/1239e77ff175271844debbbdde2eee1db3817b61f980631d308d76751a80844e-updateinfo.xml.bz2: (28, 'Operation timed out after 30001 milliseconds with 0 out of 0 bytes received') Trying other mirror. epel/x86_64/updateinfo FAILED | 5.9 MB 00:00:27 ETA http://mirror.earthlink.iq/epel/7/x86_64/repodata/1239e77ff175271844debbbdde2eee1db3817b61f980631d308d76751a80844e-updateinfo.xml.bz2: [Errno 12] Timeout on http://mirror.earthlink.iq/epel/7/x86_64/repodata/1239e77ff175271844debbbdde2eee1db3817b61f980631d308d76751a80844e-updateinfo.xml.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds') Trying other mirror. (2/3): epel/x86_64/updateinfo | 1.0 MB 00:00:00 (3/3): epel/x86_64/primary_db | 7.0 MB 00:01:11 Resolving Dependencies --> Running transaction check ---> Package oceanbase-ce-utils.x86_64 0:4.0.0.0-100000272022110114.el7 will be installed --> Processing Dependency: libmariadb.so.3(libmysqlclient_18)(64bit) for package: oceanbase-ce-utils-4.0.0.0-100000272022110114.el7.x86_64 --> Processing Dependency: libmariadb.so.3()(64bit) for package: oceanbase-ce-utils-4.0.0.0-100000272022110114.el7.x86_64 --> Running transaction check ---> Package oceanbase-ce-libs.x86_64 0:4.0.0.0-100000272022110114.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================= Package Arch Version Repository Size ======================================================================================================= Installing: oceanbase-ce-utils x86_64 4.0.0.0-100000272022110114.el7 oceanbase.community.stable 64 M Installing for dependencies: oceanbase-ce-libs x86_64 4.0.0.0-100000272022110114.el7 oceanbase.community.stable 155 k Transaction Summary ======================================================================================================= Install 1 Package (+1 Dependent package) Total download size: 64 M Installed size: 294 M Is this ok [y/d/N]: y Downloading packages: (1/2): oceanbase-ce-libs-4.0.0.0-100000272022110114.el7.x86_64.rpm | 155 kB 00:00:00 (2/2): oceanbase-ce-utils-4.0.0.0-100000272022110114.el7.x86_64.rpm | 64 MB 00:02:38 ------------------------------------------------------------------------------------------------------- Total 413 kB/s | 64 MB 00:02:38 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : oceanbase-ce-libs-4.0.0.0-100000272022110114.el7.x86_64 1/2 Installing : oceanbase-ce-utils-4.0.0.0-100000272022110114.el7.x86_64 2/2 Verifying : oceanbase-ce-libs-4.0.0.0-100000272022110114.el7.x86_64 1/2 Verifying : oceanbase-ce-utils-4.0.0.0-100000272022110114.el7.x86_64 2/2 Installed: oceanbase-ce-utils.x86_64 0:4.0.0.0-100000272022110114.el7 Dependency Installed: oceanbase-ce-libs.x86_64 0:4.0.0.0-100000272022110114.el7 Complete!
复制
3、RPM 安装包 (可选)
ob_error 在安装包 oceanbase-ce-utils-3.1.1-4.el7.x86_64.rpm 中提供,您可访问 下载页面 下载该安装包。
阿里云镜像站软件包地址下载,请根据 OS 版本自行选择。
阿里云镜像站 https://mirrors.aliyun.com/oceanbase/community/stable/el/8/x86_64/
复制
之后可运行以下命令进行安装:
[root@CAIP131 ~]# ls 1.sh nginx-1.18.0 openssh-portable anaconda-ks.cfg nginx-1.18.0.tar.gz soft example oceanbase-ce-utils-3.1.4-10000092022071511.el8.x86_64.rpm [root@CAIP131 ~]# rpm -ivh oceanbase-ce-utils-3.1.4-10000092022071511.el8.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:oceanbase-ce-utils-3.1.4-10000092################################# [100%] [root@CAIP131 ~]#
复制
注意
版本号后期可能会发生变化,请您以实际版本为准。
二、如何使用 OB 生态工具 ob_error 错误码解析工具
1、通用查询格式
您只需要输入错误码就可以得到与操作系统、Oracle 模式、MySQL 模式和 OceanBase 数据库中存在的错误相对应的错误信息。(直接在Linux命令下执行)
例如:
[root@CAIP131 ~]# ob_error 4001 OceanBase: OceanBase Error Code: OB_OBJ_TYPE_ERROR(-4001) Message: Object type error Cause: Internal Error Solution: Contact OceanBase Support Oracle: Oracle Error Code: ORA-04001 Message: sequence parameter must be an integer Related OceanBase Error Code: OB_ERR_SEQ_OPTION_MUST_BE_INTEGER(-4317) [root@CAIP131 ~]#
复制
2、指定模式查询
您也可以通过添加前缀(也称为设施)来搜索特定模式的错误码信息。
当设施为 my 时,如果错误码不是 MySQL 模式中的错误,您将得到 OceanBase 数据库的错误信息(前提是输入的错误码在 OceanBase 数据库中存在)。否则,您将得到 MySQL 模式的错误信息。
[root@CAIP131 ~]# ob_error my 4000 OceanBase: OceanBase Error Code: OB_ERROR(-4000) Message: Common error Cause: Internal Error Solution: Contact OceanBase Support [root@CAIP131 ~]#
复制
[root@CAIP131 ~]# ob_error my 1210 MySQL: MySQL Error Code: 1210 (HY000) Message: Invalid argument Message: Miss argument Message: Incorrect arguments to ESCAPE Related OceanBase Error Code: OB_INVALID_ARGUMENT(-4002) OB_MISS_ARGUMENT(-4277) INCORRECT_ARGUMENTS_TO_ESCAPE(-5832) [root@CAIP131 ~]#
复制
当设施为 ora 或 pls 时,如果输入的错误码在 Oracle 模式中存在,您将得到 Oracle 模式的错误信息。
[root@CAIP131 ~]# ob_error ora 51 Oracle: Oracle Error Code: ORA-00051 Message: timeout occurred while waiting for a resource Related OceanBase Error Code: OB_ERR_TIMEOUT_ON_RESOURCE(-5848) [root@CAIP131 ~]#
复制
还有一种特殊情况,如果您使用 -a 选项,若输入的错误码在对应模式中存在,您将会得到 OceanBase 数据库错误信息和 Oracle 模式错误信息。
[root@CAIP131 ~]# ob_error ora 600 -a 5727 OceanBase: OceanBase Error Code: OB_ERR_PROXY_REROUTE(-5727) Message: SQL request should be rerouted Cause: Internal Error Solution: Contact OceanBase Support Oracle: Oracle Error Code: ORA-00600 Message: internal error code, arguments: -5727, SQL request should be rerouted Related OceanBase Error Code: OB_ERR_PROXY_REROUTE(-5727) [root@CAIP131 ~]#
复制
说明
-a 选项用来定位带变量的 ORA-00600 错误。ORA-00600 是 Oracle 的内部错误。
3、查看ob_error 错误码解析运维小工具帮助
此外,您还可以通过 --help 命令获得完整的用户手册。
[root@CAIP131 ~]# ob_error --help This is the ob_error tool. Usage: ob_error [option] ob_error [facility] error_code [-a ARGUMENT] ob_error [facility] error_code [--argument ARGUMENT] Get the error information, reasons and possible solutions. Query an error: ob_error error_code Query an error in MySQL mode: ob_error MY error_code Query an error in ORACLE mode: ob_error facility error_code ob_error facility error_code -a ARGUMENT ob_error facility error_code --argument ARGUMENT ARGUMENT: Positive number OceanBase error_code in ORA-00600 error output. facility: MY MySQL mode. ORA ORACLE mode. Error from database. PLS ORACLE mode. Error from the stored procedure. Normal options: --help, -h Print this message and then exit. --version, -V Print version information and then exit. [root@CAIP131 ~]#
复制
如何添加错误原因和解决方案
4、查看ob_error 错误码
本文介绍了 OceanBase 数据库中 MySQL 租户和 Oracle 租户的错误信息,通过错误码您可以快速的定位数据库的问题,提高问题的解决速度。
MySQL 租户
错误信息格式
OceanBase 数据库高度兼容 MySQL,这不仅体现在常用 MySQL 功能及 MySQL 前后台协议,OceanBase 数据库原生的错误信息也对 MySQL 进行了兼容。因此,OceanBase 数据库 MySQL 租户的错误信息格式与 MySQL 保持一致,如下所示。
ERROR <err_num> (<sql_stat>) : err_msg
复制
其中,err_num 表示错误码,sql_stat 表示 SQL STATE,err_msg 表示错误信息。
错误信息中的变量
为了帮助您找到并解决错误,OceanBase 数据库将参数嵌入了错误信息。本手册中,这些参数会以百分号(%)的形式展示。例如:
ERROR 4626 (HY000) : resource pool '%s' has already been granted to a tenant
复制
上面的消息实际上可能显示如下:
ERROR 4626 (HY000) : resource pool 'pool1' has already been granted to a tenant
复制
01) OB 错误信息范围
系统错误码取值范围说明如下表所示。
02) 有关 MySQL 服务端错误码请参见
https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html
03) 更多 OB 错误码详情,请参见 错误码 章节。
https://www.oceanbase.com/docs/community-observer-cn-10000000000901232