YMatrix 文档
关于 YMatrix
标准集群部署
数据写入
SQL 参考
- ABORT
- ALTER_DATABASE
- ALTER_EXTENSION
- ALTER_EXTERNAL_TABLE
- ALTER_FOREIGN_DATA_WRAPPER
- ALTER_FOREIGN_TABLE
- ALTER_FUNCTION
- ALTER_INDEX
- ALTER_RESOURCE_GROUP
- ALTER_RESOURCE_QUEUE
- ALTER_ROLE
- ALTER_RULE
- ALTER_SCHEMA
- ALTER_SEQUENCE
- ALTER_SERVER
- ALTER_TABLE
- ALTER_TABLESPACE
- ALTER_TYPE
- ALTER_USER_MAPPING
- ALTER_VIEW
- ANALYZE
- BEGIN
- CHECKPOINT
- COMMIT
- COPY
- CREATE_DATABASE
- CREATE_EXTENSION
- CREATE_EXTERNAL_TABLE
- CREATE_FOREIGN_DATA_WRAPPER
- CREATE_FOREIGN_TABLE
- CREATE_FUNCTION
- CREATE_INDEX
- CREATE_RESOURCE_GROUP
- CREATE_RESOURCE_QUEUE
- CREATE_ROLE
- CREATE_RULE
- CREATE_SCHEMA
- CREATE_SEGMENT_SET
- CREATE_SEQUENCE
- CREATE_SERVER
- CREATE_TABLE
- CREATE_TABLE_AS
- CREATE_TABLESPACE
- CREATE_TYPE
- CREATE_USER_MAPPING
- CREATE_VIEW
- DELETE
- DROP_DATABASE
- DROP_EXTENSION
- DROP_EXTERNAL_TABLE
- DROP_FOREIGN_DATA_WRAPPER
- DROP_FOREIGN_TABLE
- DROP_FUNCTION
- DROP_INDEX
- DROP_RESOURCE_GROUP
- DROP_RESOURCE_QUEUE
- DROP_ROLE
- DROP_RULE
- DROP_SCHEMA
- DROP_SEGMENT_SET
- DROP_SEQUENCE
- DROP_SERVER
- DROP_TABLE
- DROP_TABLESPACE
- DROP_TYPE
- DROP_USER_MAPPING
- DROP_VIEW
- END
- EXPLAIN
- GRANT
- INSERT
- LOAD
- LOCK
- REINDEX
- RELEASE_SAVEPOINT
- RESET
- REVOKE
- ROLLBACK_TO_SAVEPOINT
- ROLLBACK
- SAVEPOINT
- SELECT INTO
- SET ROLE
- SET TRANSACTION
- SET
- SHOW
- START TRANSACTION
- TRUNCATE
- UPDATE
- VACUUM
现场保存工具 - minirepro
在使用 YMatrix 的过程中,你可能会遇到如下问题:
- 慢查询
- 查询执行失败等
当遇到如上问题的时候,需要技术支持人员介入进行故障诊断,而技术人员做故障诊断则需要复原现场。minirepro
就是做现场保存的工具,只需要提供执行的 SQL,就可以通过该工具生成现场环境,供技术人员在本地环境复现并追查。
1 minirepro 使用方法
minirepro
会随着 YMatrix 一起安装在 $GPHOME/bin/minirepro
。可以通过如下命令查看使用方法:
[mxadmin@mdw ~]$ minirepro --help
Usage: minirepro <database> [options]
Options:
--version show program's version number and exit
-?, --help Show this help message and exit
-h HOST, --host=HOST Specify a remote host
-p PORT, --port=PORT Specify a port other than 5432
-U USER, --user=USER Connect as someone other than current user
-q QUERY_FILE file name that contains the query
-f OUTPUT_FILE minirepro output file name
-l, --hll Include HLL stats
WARNING: This tool collects statistics about your data, including most common
values, which requires some data elements to be included in the output file.
Please review output file to ensure it is within corporate policy to transport
the output file.
使用 minirepro
做 SQL 执行现场保存首先要将 SQL 语句存放在文件中。如:要保存 SQL 语句 SELECT * FROM data;
执行现场,将其保存在文件 query.sql
中:
[mxadmin@mdw ~]$ cat query.sql
SELECT * FROM data;
然后执行命令,连接数据库并指定 SQL 文件和输出文件:
[mxadmin@mdw ~]$ minirepro mxadmin -h 127.0.0.1 -U mxadmin -p 5432 -q query.sql -f outfile.sql
Connecting to database: host=127.0.0.1, port=5432, user=mxadmin, db=mxadmin ...
Extracting metadata from query file query.sql ...
psql mxadmin --pset footer --no-psqlrc -Atq -h 127.0.0.1 -p 5432 -U mxadmin -f /tmp/20210729132431/toolkit.sql
Invoking pg_dump to dump DDL ...
pg_dump -h 127.0.0.1 -p 5432 -U mxadmin -sxO mxadmin --relation-oids 32820 --function-oids 0 -f /tmp/20210729132431/pg_dump_out.sql
Writing schema DDLs ...
Writing relation and function DDLs ...
Writing table statistics ...
Writing column statistics ...
Attaching raw query text ...
--- MiniRepro completed! ---
WARNING: This tool collects statistics about your data, including most common values, which requires some data elements to be included in the output file.
Please review output file to ensure it is within corporate policy to transport the output file.
这样,现场环境就保存到了 outfile.sql
文件中,其内容包含了数据表和相关 catalog 信息。将该文件提供给技术人员即可。