- About MogDB
- MogDB Introduction
- Comparison Between MogDB and openGauss
- MogDB Release Notes
- High Availability and Performance
- Open Source Components
- Usage Limitations
- Terms of Use
- Quick Start
- Installation Guide
- Container Installation
- Simplified Installation Process
- Standard Installation
- Manual Installation
- Administrator Guide
- Routine Maintenance
- Starting and Stopping MogDB
- Using the gsql Client for Connection
- Routine Maintenance
- Checking OS Parameters
- Checking MogDB Health Status
- Checking Database Performance
- Checking and Deleting Logs
- Checking Time Consistency
- Checking The Number of Application Connections
- Routinely Maintaining Tables
- Routinely Recreating an Index
- Data Security Maintenance Suggestions
- Log Reference
- Primary and Standby Management
- MOT Engine
- Introducing MOT
- Using MOT
- Concepts of MOT
- Appendix
- Column-store Tables Management
- Backup and Restoration
- Importing and Exporting Data
- Importing Data
- Exporting Data
- Upgrade Guide
- Common Fault Locating Cases
- Core Fault Locating
- When the TPC-C is running and a disk to be injected is full, the TPC-C stops responding
- Standby Node in the Need Repair (WAL) State
- Insufficient Memory
- Service Startup Failure
- "Error:No space left on device" Is Displayed
- After You Run the du Command to Query Data File Size In the XFS File System, the Query Result Is Greater than the Actual File Size
- File Is Damaged in the XFS File System
- Primary Node Is Hung in Demoting During a Switchover
- Disk Space Usage Reaches the Threshold and the Database Becomes Read-only
- Slow Response to a Query Statement
- Analyzing the Status of a Query Statement
- Forcibly Terminating a Session
- Analyzing Whether a Query Statement Is Blocked
- Low Query Efficiency
- "Lock wait timeout" Is Displayed When a User Executes an SQL Statement
- Table Size Does not Change After VACUUM FULL Is Executed on the Table
- An Error Is Reported When the Table Partition Is Modified
- Different Data Is Displayed for the Same Table Queried By Multiple Users
- When a User Specifies Only an Index Name to Modify the Index, A Message Indicating That the Index Does Not Exist Is Displayed
- Reindexing Fails
- An Error Occurs During Integer Conversion
- "too many clients already" Is Reported or Threads Failed To Be Created in High Concurrency Scenarios
- B-tree Index Faults
- Routine Maintenance
- Security Guide
- Database Security Management
- Performance Tuning
- System Optimization
- SQL Optimization
- WDR Snapshot Schema
- TPCC Performance Tuning Guide
- Developer Guide
- Application Development Guide
- Development Specifications
- Development Based on JDBC
- Overview
- JDBC Package, Driver Class, and Environment Class
- Development Process
- Loading the Driver
- Connecting to a Database
- Connecting to the Database (Using SSL)
- Running SQL Statements
- Processing Data in a Result Set
- Closing a Connection
- Example: Common Operations
- Example: Retrying SQL Queries for Applications
- Example: Importing and Exporting Data Through Local Files
- Example 2: Migrating Data from a MY Database to MogDB
- Example: Logic Replication Code
- JDBC API Reference
- java.sql.Connection
- java.sql.CallableStatement
- java.sql.DatabaseMetaData
- java.sql.Driver
- java.sql.PreparedStatement
- java.sql.ResultSet
- java.sql.ResultSetMetaData
- java.sql.Statement
- javax.sql.ConnectionPoolDataSource
- javax.sql.DataSource
- javax.sql.PooledConnection
- javax.naming.Context
- javax.naming.spi.InitialContextFactory
- CopyManager
- Development Based on ODBC
- Development Based on libpq
- Development Based on libpq
- libpq API Reference
- Database Connection Control Functions
- Database Statement Execution Functions
- Functions for Asynchronous Command Processing
- Functions for Canceling Queries in Progress
- Example
- Connection Characters
- Commissioning
- Appendices
- Stored Procedure
- User Defined Functions
- Autonomous Transaction
- Logical Replication
- Logical Decoding
- Foreign Data Wrapper
- Materialized View
- Materialized View Overview
- Full Materialized View
- Incremental Materialized View
- AI Features
- Overview
- Predictor: AI Query Time Forecasting
- X-Tuner: Parameter Optimization and Diagnosis
- SQLdiag: Slow SQL Discovery
- A-Detection: Status Monitoring
- Index-advisor: Index Recommendation
- DeepSQL
- Application Development Guide
- Reference Guide
- System Catalogs and System Views
- Overview of System Catalogs and System Views
- System Catalogs
- GS_AUDITING_POLICY
- GS_AUDITING_POLICY_ACCESS
- GS_AUDITING_POLICY_FILTERS
- GS_AUDITING_POLICY_PRIVILEGES
- GS_CLIENT_GLOBAL_KEYS
- GS_CLIENT_GLOBAL_KEYS_ARGS
- GS_COLUMN_KEYS
- GS_COLUMN_KEYS_ARGS
- GS_ENCRYPTED_COLUMNS
- GS_MASKING_POLICY
- GS_MASKING_POLICY_ACTIONS
- GS_MASKING_POLICY_FILTERS
- GS_MATVIEW
- GS_MATVIEW_DEPENDENCY
- GS_OPT_MODEL
- GS_POLICY_LABEL
- GS_WLM_INSTANCE_HISTORY
- GS_WLM_OPERATOR_INFO
- GS_WLM_PLAN_ENCODING_TABLE
- GS_WLM_PLAN_OPERATOR_INFO
- GS_WLM_USER_RESOURCE_HISTORY
- PG_AGGREGATE
- PG_AM
- PG_AMOP
- PG_AMPROC
- PG_APP_WORKLOADGROUP_MAPPING
- PG_ATTRDEF
- PG_ATTRIBUTE
- PG_AUTHID
- PG_AUTH_HISTORY
- PG_AUTH_MEMBERS
- PG_CAST
- PG_CLASS
- PG_COLLATION
- PG_CONSTRAINT
- PG_CONVERSION
- PG_DATABASE
- PG_DB_ROLE_SETTING
- PG_DEFAULT_ACL
- PG_DEPEND
- PG_DESCRIPTION
- PG_DIRECTORY
- PG_ENUM
- PG_EXTENSION
- PG_EXTENSION_DATA_SOURCE
- PG_FOREIGN_DATA_WRAPPER
- PG_FOREIGN_SERVER
- PG_FOREIGN_TABLE
- PG_INDEX
- PG_INHERITS
- PG_JOB
- PG_JOB_PROC
- PG_LANGUAGE
- PG_LARGEOBJECT
- PG_LARGEOBJECT_METADATA
- PG_NAMESPACE
- PG_OBJECT
- PG_OPCLASS
- PG_OPERATOR
- PG_OPFAMILY
- PG_PARTITION
- PG_PLTEMPLATE
- PG_PROC
- PG_RANGE
- PG_RESOURCE_POOL
- PG_REWRITE
- PG_RLSPOLICY
- PG_SECLABEL
- PG_SHDEPEND
- PG_SHDESCRIPTION
- PG_SHSECLABEL
- PG_STATISTIC
- PG_STATISTIC_EXT
- PG_SYNONYM
- PG_TABLESPACE
- PG_TRIGGER
- PG_TS_CONFIG
- PG_TS_CONFIG_MAP
- PG_TS_DICT
- PG_TS_PARSER
- PG_TS_TEMPLATE
- PG_TYPE
- PG_USER_MAPPING
- PG_USER_STATUS
- PG_WORKLOAD_GROUP
- PLAN_TABLE_DATA
- STATEMENT_HISTORY
- System Views
- GS_AUDITING
- GS_AUDITING_ACCESS
- GS_AUDITING_PRIVILEGE
- GS_CLUSTER_RESOURCE_INFO
- GS_INSTANCE_TIME
- GS_LABELS
- GS_MASKING
- GS_MATVIEWS
- GS_SESSION_MEMORY
- GS_SESSION_CPU_STATISTICS
- GS_SESSION_MEMORY_CONTEXT
- GS_SESSION_MEMORY_DETAIL
- GS_SESSION_MEMORY_STATISTICS
- GS_SQL_COUNT
- GS_WLM_CGROUP_INFO
- GS_WLM_PLAN_OPERATOR_HISTORY
- GS_WLM_REBUILD_USER_RESOURCE_POOL
- GS_WLM_RESOURCE_POOL
- GS_WLM_USER_INFO
- GS_STAT_SESSION_CU
- GS_TOTAL_MEMORY_DETAIL
- MPP_TABLES
- PG_AVAILABLE_EXTENSION_VERSIONS
- PG_AVAILABLE_EXTENSIONS
- PG_COMM_DELAY
- PG_COMM_RECV_STREAM
- PG_COMM_SEND_STREAM
- PG_COMM_STATUS
- PG_CONTROL_GROUP_CONFIG
- PG_CURSORS
- PG_EXT_STATS
- PG_GET_INVALID_BACKENDS
- PG_GET_SENDERS_CATCHUP_TIME
- PG_GROUP
- PG_GTT_RELSTATS
- PG_GTT_STATS
- PG_GTT_ATTACHED_PIDS
- PG_INDEXES
- PG_LOCKS
- PG_NODE_ENV
- PG_OS_THREADS
- PG_PREPARED_STATEMENTS
- PG_PREPARED_XACTS
- PG_REPLICATION_SLOTS
- PG_RLSPOLICIES
- PG_ROLES
- PG_RULES
- PG_SECLABELS
- PG_SETTINGS
- PG_SHADOW
- PG_STATS
- PG_STAT_ACTIVITY
- PG_STAT_ALL_INDEXES
- PG_STAT_ALL_TABLES
- PG_STAT_BAD_BLOCK
- PG_STAT_BGWRITER
- PG_STAT_DATABASE
- PG_STAT_DATABASE_CONFLICTS
- PG_STAT_USER_FUNCTIONS
- PG_STAT_USER_INDEXES
- PG_STAT_USER_TABLES
- PG_STAT_REPLICATION
- PG_STAT_SYS_INDEXES
- PG_STAT_SYS_TABLES
- PG_STAT_XACT_ALL_TABLES
- PG_STAT_XACT_SYS_TABLES
- PG_STAT_XACT_USER_FUNCTIONS
- PG_STAT_XACT_USER_TABLES
- PG_STATIO_ALL_INDEXES
- PG_STATIO_ALL_SEQUENCES
- PG_STATIO_ALL_TABLES
- PG_STATIO_SYS_INDEXES
- PG_STATIO_SYS_SEQUENCES
- PG_STATIO_SYS_TABLES
- PG_STATIO_USER_INDEXES
- PG_STATIO_USER_SEQUENCES
- PG_STATIO_USER_TABLES
- PG_TABLES
- PG_TDE_INFO
- PG_THREAD_WAIT_STATUS
- PG_TIMEZONE_ABBREVS
- PG_TIMEZONE_NAMES
- PG_TOTAL_MEMORY_DETAIL
- PG_TOTAL_USER_RESOURCE_INFO
- PG_TOTAL_USER_RESOURCE_INFO_OID
- PG_USER
- PG_USER_MAPPINGS
- PG_VARIABLE_INFO
- PG_VIEWS
- PLAN_TABLE
- GS_FILE_STAT
- GS_OS_RUN_INFO
- GS_REDO_STAT
- GS_SESSION_STAT
- GS_SESSION_TIME
- GS_THREAD_MEMORY_CONTEXT
- Functions and Operators
- Logical Operators
- Comparison Operators
- Character Processing Functions and Operators
- Binary String Functions and Operators
- Bit String Functions and Operators
- Mode Matching Operators
- Mathematical Functions and Operators
- Date and Time Processing Functions and Operators
- Type Conversion Functions
- Geometric Functions and Operators
- Network Address Functions and Operators
- Text Search Functions and Operators
- JSON Functions
- HLL Functions and Operators
- SEQUENCE Functions
- Array Functions and Operators
- Range Functions and Operators
- Aggregate Functions
- Window Functions
- Security Functions
- Encrypted Equality Functions
- Set Returning Functions
- Conditional Expression Functions
- System Information Functions
- System Administration Functions
- Statistics Information Functions
- Trigger Functions
- Global Temporary Table Functions
- AI Feature Functions
- Other System Functions
- Internal Functions
- Obsolete Functions
- Supported Data Types
- SQL Syntax
- ABORT
- ALTER AGGREGATE
- ALTER AUDIT POLICY
- ALTER DATABASE
- ALTER DATA SOURCE
- ALTER DEFAULT PRIVILEGES
- ALTER DIRECTORY
- ALTER EXTENSION
- ALTER FOREIGN TABLE
- ALTER FUNCTION
- ALTER GROUP
- ALTER INDEX
- ALTER LANGUAGE
- ALTER LARGE OBJECT
- ALTER MASKING POLICY
- ALTER MATERIALIZED VIEW
- ALTER OPERATOR
- ALTER RESOURCE LABEL
- ALTER ROLE
- ALTER ROW LEVEL SECURITY POLICY
- ALTER RULE
- ALTER SCHEMA
- ALTER SEQUENCE
- ALTER SERVER
- ALTER SESSION
- ALTER SYNONYM
- ALTER SYSTEM KILL SESSION
- ALTER SYSTEM SET
- ALTER TABLE
- ALTER TABLE PARTITION
- ALTER TABLESPACE
- ALTER TEXT SEARCH CONFIGURATION
- ALTER TEXT SEARCH DICTIONARY
- ALTER TRIGGER
- ALTER TYPE
- ALTER USER
- ALTER USER MAPPING
- ALTER VIEW
- ANALYZE | ANALYSE
- BEGIN
- CALL
- CHECKPOINT
- CLOSE
- CLUSTER
- COMMENT
- COMMIT | END
- COMMIT PREPARED
- COPY
- CREATE AGGREGATE
- CREATE AUDIT POLICY
- CREATE CAST
- CREATE CLIENT MASTER KEY
- CREATE COLUMN ENCRYPTION KEY
- CREATE DATABASE
- CREATE DATA SOURCE
- CREATE DIRECTORY
- CREATE EXTENSION
- CREATE FOREIGN TABLE
- CREATE FUNCTION
- CREATE GROUP
- CREATE INCREMENTAL MATERIALIZED VIEW
- CREATE INDEX
- CREATE LANGUAGE
- CREATE MASKING POLICY
- CREATE MATERIALIZED VIEW
- CREATE OPERATOR
- CREATE ROW LEVEL SECURITY POLICY
- CREATE PROCEDURE
- CREATE RESOURCE LABEL
- CREATE ROLE
- CREATE RULE
- CREATE SCHEMA
- CREATE SEQUENCE
- CREATE SERVER
- CREATE SYNONYM
- CREATE TABLE
- CREATE TABLE AS
- CREATE TABLE PARTITION
- CREATE TABLESPACE
- CREATE TEXT SEARCH CONFIGURATION
- CREATE TEXT SEARCH DICTIONARY
- CREATE TRIGGER
- CREATE TYPE
- CREATE USER
- CREATE USER MAPPING
- CREATE VIEW
- CURSOR
- DEALLOCATE
- DECLARE
- DELETE
- DO
- DROP AGGREGATE
- DROP AUDIT POLICY
- DROP CAST
- DROP CLIENT MASTER KEY
- DROP COLUMN ENCRYPTION KEY
- DROP DATABASE
- DROP DATA SOURCE
- DROP DIRECTORY
- DROP EXTENSION
- DROP FOREIGN TABLE
- DROP FUNCTION
- DROP GROUP
- DROP INDEX
- DROP LANGUAGE
- DROP MASKING POLICY
- DROP MATERIALIZED VIEW
- DROP OPERATOR
- DROP OWNED
- DROP RESOURCE LABEL
- DROP ROW LEVEL SECURITY POLICY
- DROP PROCEDURE
- DROP ROLE
- DROP RULE
- DROP SCHEMA
- DROP SEQUENCE
- DROP SERVER
- DROP SYNONYM
- DROP TABLE
- DROP TABLESPACE
- DROP TEXT SEARCH CONFIGURATION
- DROP TEXT SEARCH DICTIONARY
- DROP TRIGGER
- DROP TYPE
- DROP USER
- DROP USER MAPPING
- DROP VIEW
- EXECUTE
- EXPLAIN
- EXPLAIN PLAN
- FETCH
- GRANT
- INSERT
- LOCK
- MOVE
- MERGE INTO
- PREPARE
- PREPARE TRANSACTION
- REASSIGN OWNED
- REFRESH INCREMENTAL MATERIALIZED VIEW
- REFRESH MATERIALIZED VIEW
- REINDEX
- RELEASE SAVEPOINT
- RESET
- REVOKE
- ROLLBACK
- ROLLBACK PREPARED
- ROLLBACK TO SAVEPOINT
- SAVEPOINT
- SELECT
- SELECT INTO
- SET
- SET CONSTRAINTS
- SET ROLE
- SET SESSION AUTHORIZATION
- SET TRANSACTION
- SHOW
- SHUTDOWN
- START TRANSACTION
- TRUNCATE
- UPDATE
- VACUUM
- VALUES
- SQL Reference
- MogDB SQL
- Keywords
- Constant and Macro
- Expressions
- Type Conversion
- Full Text Search
- Introduction
- Tables and Indexes
- Controlling Text Search
- Additional Features
- Parser
- Dictionaries
- Configuration Examples
- Testing and Debugging Text Search
- Limitations
- System Operation
- Controlling Transactions
- DDL Syntax Overview
- DML Syntax Overview
- DCL Syntax Overview
- Appendix
- GUC Parameters
- GUC Parameter Usage
- File Location
- Connection and Authentication
- Resource Consumption
- Parallel Import
- Write Ahead Log
- HA Replication
- Memory Table
- Query Planning
- Error Reporting and Logging
- Alarm Detection
- Statistics During the Database Running
- Load Management
- Automatic Vacuuming
- Default Settings of Client Connection
- Lock Management
- Version and Platform Compatibility
- Faut Tolerance
- Connection Pool Parameters
- MogDB Transaction
- Developer Options
- Auditing
- Upgrade Parameters
- Miscellaneous Parameters
- Wait Events
- Query
- System Performance Snapshot
- Equality Query in a Fully-encrypted Database
- Global Temporary Table
- Scheduled Task
- Thread Pool
- Appendix
- Information Schema
- DBE_PERF
- DBE_PERF Overview
- OS
- Instance
- Memory
- File
- Object
- STAT_USER_TABLES
- SUMMARY_STAT_USER_TABLES
- GLOBAL_STAT_USER_TABLES
- STAT_USER_INDEXES
- SUMMARY_STAT_USER_INDEXES
- GLOBAL_STAT_USER_INDEXES
- STAT_SYS_TABLES
- SUMMARY_STAT_SYS_TABLES
- GLOBAL_STAT_SYS_TABLES
- STAT_SYS_INDEXES
- SUMMARY_STAT_SYS_INDEXES
- GLOBAL_STAT_SYS_INDEXES
- STAT_ALL_TABLES
- SUMMARY_STAT_ALL_TABLES
- GLOBAL_STAT_ALL_TABLES
- STAT_ALL_INDEXES
- SUMMARY_STAT_ALL_INDEXES
- GLOBAL_STAT_ALL_INDEXES
- STAT_DATABASE
- SUMMARY_STAT_DATABASE
- GLOBAL_STAT_DATABASE
- STAT_DATABASE_CONFLICTS
- SUMMARY_STAT_DATABASE_CONFLICTS
- GLOBAL_STAT_DATABASE_CONFLICTS
- STAT_XACT_ALL_TABLES
- SUMMARY_STAT_XACT_ALL_TABLES
- GLOBAL_STAT_XACT_ALL_TABLES
- STAT_XACT_SYS_TABLES
- SUMMARY_STAT_XACT_SYS_TABLES
- GLOBAL_STAT_XACT_SYS_TABLES
- STAT_XACT_USER_TABLES
- SUMMARY_STAT_XACT_USER_TABLES
- GLOBAL_STAT_XACT_USER_TABLES
- STAT_XACT_USER_FUNCTIONS
- SUMMARY_STAT_XACT_USER_FUNCTIONS
- GLOBAL_STAT_XACT_USER_FUNCTIONS
- STAT_BAD_BLOCK
- SUMMARY_STAT_BAD_BLOCK
- GLOBAL_STAT_BAD_BLOCK
- STAT_USER_FUNCTIONS
- SUMMARY_STAT_USER_FUNCTIONS
- GLOBAL_STAT_USER_FUNCTIONS
- Workload
- Session/Thread
- SESSION_STAT
- GLOBAL_SESSION_STAT
- SESSION_TIME
- GLOBAL_SESSION_TIME
- SESSION_MEMORY
- GLOBAL_SESSION_MEMORY
- SESSION_MEMORY_DETAIL
- GLOBAL_SESSION_MEMORY_DETAIL
- SESSION_STAT_ACTIVITY
- GLOBAL_SESSION_STAT_ACTIVITY
- THREAD_WAIT_STATUS
- GLOBAL_THREAD_WAIT_STATUS
- LOCAL_THREADPOOL_STATUS
- GLOBAL_THREADPOOL_STATUS
- SESSION_CPU_RUNTIME
- SESSION_MEMORY_RUNTIME
- STATEMENT_IOSTAT_COMPLEX_RUNTIME
- Transaction
- Query
- STATEMENT
- SUMMARY_STATEMENT
- STATEMENT_COUNT
- GLOBAL_STATEMENT_COUNT
- SUMMARY_STATEMENT_COUNT
- GLOBAL_STATEMENT_COMPLEX_HISTORY
- GLOBAL_STATEMENT_COMPLEX_HISTORY_TABLE
- GLOBAL_STATEMENT_COMPLEX_RUNTIME
- STATEMENT_RESPONSETIME_PERCENTILE
- STATEMENT_USER_COMPLEX_HISTORY
- STATEMENT_COMPLEX_RUNTIME
- STATEMENT_COMPLEX_HISTORY_TABLE
- STATEMENT_COMPLEX_HISTORY
- STATEMENT_WLMSTAT_COMPLEX_RUNTIME
- STATEMENT_HISTORY
- Cache/IO
- STATIO_USER_TABLES
- SUMMARY_STATIO_USER_TABLES
- GLOBAL_STATIO_USER_TABLES
- STATIO_USER_INDEXES
- SUMMARY_STATIO_USER_INDEXES
- GLOBAL_STATIO_USER_INDEXES
- STATIO_USER_SEQUENCES
- SUMMARY_STATIO_USER_SEQUENCES
- GLOBAL_STATIO_USER_SEQUENCES
- STATIO_SYS_TABLES
- SUMMARY_STATIO_SYS_TABLES
- GLOBAL_STATIO_SYS_TABLES
- STATIO_SYS_INDEXES
- SUMMARY_STATIO_SYS_INDEXES
- GLOBAL_STATIO_SYS_INDEXES
- STATIO_SYS_SEQUENCES
- SUMMARY_STATIO_SYS_SEQUENCES
- GLOBAL_STATIO_SYS_SEQUENCES
- STATIO_ALL_TABLES
- SUMMARY_STATIO_ALL_TABLES
- GLOBAL_STATIO_ALL_TABLES
- STATIO_ALL_INDEXES
- SUMMARY_STATIO_ALL_INDEXES
- GLOBAL_STATIO_ALL_INDEXES
- STATIO_ALL_SEQUENCES
- SUMMARY_STATIO_ALL_SEQUENCES
- GLOBAL_STATIO_ALL_SEQUENCES
- GLOBAL_STAT_DB_CU
- GLOBAL_STAT_SESSION_CU
- Utility
- REPLICATION_STAT
- GLOBAL_REPLICATION_STAT
- REPLICATION_SLOTS
- GLOBAL_REPLICATION_SLOTS
- BGWRITER_STAT
- GLOBAL_BGWRITER_STAT
- GLOBAL_CKPT_STATUS
- GLOBAL_DOUBLE_WRITE_STATUS
- GLOBAL_PAGEWRITER_STATUS
- GLOBAL_RECORD_RESET_TIME
- GLOBAL_REDO_STATUS
- GLOBAL_RECOVERY_STATUS
- CLASS_VITAL_INFO
- USER_LOGIN
- SUMMARY_USER_LOGIN
- GLOBAL_GET_BGWRITER_STATUS
- Lock
- Wait Events
- Configuration
- Operator
- Workload Manager
- Global Plancache
- Appendix
- Tool Reference
- Tool Overview
- Client Tool
- Server Tools
- Tools Used in the Internal System
- Error Code Reference
- Description of SQL Error Codes
- Third-Party Library Error Codes
- GAUSS-00001 - GAUSS-00100
- GAUSS-00101 - GAUSS-00200
- GAUSS 00201 - GAUSS 00300
- GAUSS 00301 - GAUSS 00400
- GAUSS 00401 - GAUSS 00500
- GAUSS 00501 - GAUSS 00600
- GAUSS 00601 - GAUSS 00700
- GAUSS 00701 - GAUSS 00800
- GAUSS 00801 - GAUSS 00900
- GAUSS 00901 - GAUSS 01000
- GAUSS 01001 - GAUSS 01100
- GAUSS 01101 - GAUSS 01200
- GAUSS 01201 - GAUSS 01300
- GAUSS 01301 - GAUSS 01400
- GAUSS 01401 - GAUSS 01500
- GAUSS 01501 - GAUSS 01600
- GAUSS 01601 - GAUSS 01700
- GAUSS 01701 - GAUSS 01800
- GAUSS 01801 - GAUSS 01900
- GAUSS 01901 - GAUSS 02000
- GAUSS 02001 - GAUSS 02100
- GAUSS 02101 - GAUSS 02200
- GAUSS 02201 - GAUSS 02300
- GAUSS 02301 - GAUSS 02400
- GAUSS 02401 - GAUSS 02500
- GAUSS 02501 - GAUSS 02600
- GAUSS 02601 - GAUSS 02700
- GAUSS 02701 - GAUSS 02800
- GAUSS 02801 - GAUSS 02900
- GAUSS 02901 - GAUSS 03000
- GAUSS 03001 - GAUSS 03100
- GAUSS 03101 - GAUSS 03200
- GAUSS 03201 - GAUSS 03300
- GAUSS 03301 - GAUSS 03400
- GAUSS 03401 - GAUSS 03500
- GAUSS 03501 - GAUSS 03600
- GAUSS 03601 - GAUSS 03700
- GAUSS 03701 - GAUSS 03800
- GAUSS 03801 - GAUSS 03900
- GAUSS 03901 - GAUSS 04000
- GAUSS 04001 - GAUSS 04100
- GAUSS 04101 - GAUSS 04200
- GAUSS 04201 - GAUSS 04300
- GAUSS 04301 - GAUSS 04400
- GAUSS 04401 - GAUSS 04500
- GAUSS 04501 - GAUSS 04600
- GAUSS 04601 - GAUSS 04700
- GAUSS 04701 - GAUSS 04800
- GAUSS 04801 - GAUSS 04900
- GAUSS 04901 - GAUSS 05000
- GAUSS 05001 - GAUSS 05100
- GAUSS 05101 - GAUSS 05200
- GAUSS 05201 - GAUSS 05300
- GAUSS 05301 - GAUSS 05400
- GAUSS 05401 - GAUSS 05500
- GAUSS 05501 - GAUSS 05600
- GAUSS 05601 - GAUSS 05700
- GAUSS 05701 - GAUSS 05800
- GAUSS 05801 - GAUSS 05900
- GAUSS 05901 - GAUSS 06000
- GAUSS 06001 - GAUSS 06100
- GAUSS 06101 - GAUSS 06200
- GAUSS 06201 - GAUSS 06300
- GAUSS 06301 - GAUSS 06400
- GAUSS 06401 - GAUSS 06500
- GAUSS 06501 - GAUSS 06600
- GAUSS 06601 - GAUSS 06700
- GAUSS 06701 - GAUSS 06800
- GAUSS 06801 - GAUSS 06900
- GAUSS 06901 - GAUSS 07000
- GAUSS 07001 - GAUSS 07100
- GAUSS 07101 - GAUSS 07200
- GAUSS 07201 - GAUSS 07300
- GAUSS 07301 - GAUSS 07400
- GAUSS 07401 - GAUSS 07480
- GAUSS 50000 - GAUSS 50999
- GAUSS 51000 - GAUSS 51999
- GAUSS 52000 - GAUSS 52999
- GAUSS 53000 - GAUSS 53699
- System Catalogs and System Views
- FAQs
- Glossary
Physical Backup and Restoration
gs_basebackup
Background
After MogDB is deployed, problems and exceptions may occur during database running. gs_basebackup, provided by MogDB, is used to perform basic physical backup. gs_basebackup copies the binary files of the database on the server using a replication protocol. To remotely execute gs_basebackup, you need to use the system administrator account. gs_basebackup supports hot backup and compressed backup.
NOTE:
- gs_basebackup supports only full backup.
- gs_basebackup supports hot backup and compressed backup.
- gs_basebackup cannot back up tablespaces containing absolute paths on the same server. This is because the absolute path is unique on the same machine, and brings about conflicts. However, it can back up tablespaces containing absolute paths on different machines.
- If the functions of incremental checkpoint and dual-write are enabled, gs_basebackup also backs up dual-write files.
- If the pg_xlog directory is a soft link, no soft link is created during backup. Data is directly backed up to the pg_xlog directory in the destination path.
- If the backup permission is revoked during the backup, the backup may fail or the backup data may be unavailable.
- MogDB does not support version upgrade.
Prerequisites
- The MogDB database can be connected.
- User permissions are not revoked during the backup.
- In the pg_hba.conf file, the replication connection is allowed and the connection is established by a system administrator.
- If the Xlog transmission mode is stream, the number of max_wal_senders must be configured to at least one.
- If the Xlog transmission mode is fetch, the wal_keep_segments parameter must be set to a large value so that logs are not removed before the backup ends.
- During the restoration, backup files exist in the backup directory on all the nodes. If backup files are lost on any node, them to it from another node.
Syntax
-
Display help information.
gs_basebackup -? | --help
-
Display version information.
gs_basebackup -V | --version
Parameter Description
The gs_basebackup tool can use the following types of parameters:
- -D directory
Directory for storing backup files. This parameter is mandatory.
-
Common parameters
- -c, -checkpoint=fast|spread
Sets the checkpoint mode to fast or spread (default).
- -l, -label=LABEL
Adds tags for the backup.
- -P, -progress
Enables the progress report.
- -v, -verbose
Enables the verbose mode.
- -V, -version
Prints the version and exits.
- -?, -help
Displays gs_basebackup command parameters.
- -T, -tablespace-mapping=olddir=newdir
During the backup, the tablespace in the olddir directory is relocated to the newdir directory. For this to take effect, olddir must exactly match the path where the tablespace is located (but it is not an error if the backup does not contain the tablespaces in olddir). olddir and newdir must be absolute paths. If a path happens to contain an equal sign (=), you can escape it with a backslash (). This option can be used multiple times for multiple tablespaces.
- -F, -format=plain|tar
Sets the output format to plain (default) or tar. If this parameter is not set, the default value -format=plain is used. The plain format writes the output as a flat file, using the same layout as the current data directory and tablespace. When the cluster has no extra tablespace, the entire database is placed in the target directory. If the cluster contains additional tablespaces, the primary data directory will be placed in the target directory, but all other tablespaces will be placed in the same absolute path on the server. The tar mode writes the output as a tar file in the target directory. The primary data directory is written to a file named base.tar, and other tablespaces are named after their OIDs. The generated .tar package must be decompressed using the gs_tar command.
- -X, -xlog-method=fetch|stream
Sets the Xlog transmission mode. If this parameter is not set, the default value -xlog-method=stream is used. The required write-ahead log files (WALs) are included in the backup. This includes all WALs generated during the backup. In fetch mode, WAL files are collected at the end of the backup. Therefore, the wal_keep_segments parameter must be set to a large value so that logs are not removed before the backup ends. If it has been rotated when the log is to be transmitted, the backup fails and is unavailable. In stream mode, WALs are streamed when a backup is created. This will open a second connection to the server and start streaming WALs while the backup is running. Therefore, it will use up to two connections configured by the max_wal_senders parameter. As long as the client can receive WALs, no additional WALs need to be stored on the host.
- -x, -xlog
Equivalent to using -X with the fetch method.
- -Z -compress=level
Enables gzip compression for the output of the tar file and sets the compression level (0 to 9, where 0 indicates no compression and 9 indicates the best compression). The compression is available only when the tar format is used. The suffix .gz is automatically added to the end of all .tar file names.
- -z
Enables gzip compression for tar file output and uses the default compression level. The compression is available only when the tar format is used. The suffix .gz is automatically added to the end of all .tar file names.
- -t, -rw-timeout
Sets the checkpoint time limit during backup. The default value is 120s. If the full checkpoint of the database is time-consuming, you can increase the value of rw-timeout.
-
Connection parameters
- -h, -host=HOSTNAME
Specifies the host name of the machine on which the server is running or the directory for the Unix-domain socket.
- -p, -port=PORT
Specifies the port number of the database server.
You can modify the default port number using this parameter.
- -U, -username=USERNAME
Specifies the user that connects to the database.
- -s, -status-interval=INTERVAL
Specifies the time for sending status packets to the server, in seconds.
- -w,-no-password
Never issues a password prompt.
- -W, -password
Issues a password prompt when the -U parameter is used to connect to a local or remote database.
Example
gs_basebackup -D /home/test/trunk/install/data/backup -h 127.0.0.1 -p 21233
INFO: The starting position of the xlog of the full build is: 0/1B800000. The slot minimum LSN is: 0/1B800000.
Restoring Data from Backup Files
If a database is faulty, restore it from backup files. gs_basebackup backs up the database in binary mode. Therefore, you can directly and replace the original files or start the database on the backup database.
NOTE:
- If the current database instance is running, a port conflict may occur when you start the database from the backup file. In this case, you need to modify the port parameter in the configuration file or specify a port when starting the database.
- If the current backup file is a primary/standby database, you may need to modify the replication connections between the master and slave databases. That is, replconninfo1 and replconninfo2 in the postgresql.conf file.
To restore the original database, perform the following steps:
- Stop the database server. For details, see Administrator Guide.
- the original database and all tablespaces to another location for future use.
- Delete all or part of the files from the original database.
- Use the database system user rights to restore the required database files from the backup.
- If a link file exists in the database, modify the link file so that it can be linked to the correct file.
- Restart the database server and check the database content to ensure that the database is restored to the required status.
NOTE:
- Incremental restoration from backup files is not supported.
- After the restoration, check that the link file in the database is linked to the correct file.
gs_probackup
Background
gs_probackup is a tool used to manage MogDB database backup and restoration. It periodically backs up the MogDB instances so that the server can be restored when the database is faulty.
- It supports the physical backup of a standalone database or a primary node in a database.
- It supports the backup of contents in external directories, such as script files, configuration files, log files, and dump files.
- It supports incremental backup, periodic backup, and remote backup.
- It supports settings on the backup retention policy.
Prerequisites
- The MogDB database can be connected.
- To use PTRACK incremental backup, manually add enable_cbm_tracking = on to postgresql.conf.
Important Notes
- The backup must be performed by the user who runs the database server.
- The major version number of the database server to be backed up must be the same as that of the database server to be restored.
- To back up a database in remote mode using SSH, install the database of the same major version on the local and remote hosts, and run the ssh-copy-id remote_user@remote_host command to set an SSH connection without a password between the local host backup user and the remote host database user.
- In remote mode, only the subcommands add-instance, backup, and restore can be executed.
- Before running the restore subcommand, stop the gaussdb process.
Command Description
-
Print the gs_probackup version.
gs_probackup -V|--version gs_probackup version
-
Display brief information about the gs_probackup command. Alternatively, display details about parameters of a specified subcommand of gs_probackup.
gs_probackup -?|--help gs_probackup help [command]
-
Initialize the backup directory in backup-path. The backup directory stores the contents that have been backed up. If the backup-path backup path exists, it must be empty.
gs_probackup init -B backup-path [--help]
-
Initialize a new backup instance in the backup directory of backup-path and generate the pg_probackup.conf configuration file, which saves the gs_probackupsettings of the specified data directory pgdata-path.
gs_probackup add-instance -B backup-path -D pgdata-path --instance=instance_name [-E external-directories-paths] [remote_options] [--help]
-
Delete the backup content related to the specified instance from the backup-path directory.
gs_probackup del-instance -B backup-path --instance=instance_name [--help]
-
Add the specified connection, compression, and log-related settings to the pg_probackup.conf configuration file or modify the existing settings. You are not advised to manually edit the pg_probackup.conf configuration file.
gs_probackup set-config -B backup-path --instance=instance_name [-D pgdata-path] [-E external-directories-paths] [--archive-timeout=timeout] [--retention-redundancy=retention-redundancy] [--retention-window=retention-window] [--wal-depth=wal-depth] [--compress-algorithm=compress-algorithm] [--compress-level=compress-level] [-d dbname] [-h hostname] [-p port] [-U username] [logging_options] [remote_options] [--help]
-
Add the backup-related settings to the backup.control configuration file or modify the settings.
gs_probackup set-backup -B backup-path --instance=instance_name -i backup-id [--note=text] [pinning_options] [--help]
-
Display the content of the pg_probackup.conf configuration file in the backup directory. You can specify -format=json to display the information in JSON format. By default, the plain text format is used.
gs_probackup show-config -B backup-path --instance=instance_name [--format=plain|json] [--help]
-
Display the contents of the backup directory. If instance_name and backup_id are specified, detailed information about the backup is displayed. You can specify -format=json to display the information in JSON format. By default, the plain text format is used.
gs_probackup show -B backup-path [--instance=instance_name [-i backup-id]] [--archive] [--format=plain|json] [--help]
-
Create a backup for a specified database instance.
gs_probackup backup -B backup-path --instance=instance_name -b backup-mode [-D pgdata-path] [-C] [-S slot-name] [--temp-slot] [--backup-pg-log] [-j threads_num] [--progress] [--no-validate] [--skip-block-validation] [-E external-directories-paths] [--no-sync] [--note=text] [--archive-timeout=timeout] [logging_options] [retention_options] [compression_options] [connection_options] [remote_options] [pinning_options] [--help]
-
Restore a specified instance from the backup copy in the backup-path directory. If an instance to be restored is specified, gs_probackup will look for its latest backup and restore it to the specified recovery target. Otherwise, the latest backup of any instance is used.
gs_probackup restore -B backup-path --instance=instance_name [-D pgdata-path] [-i backup_id] [-j threads_num] [--progress] [--force] [--no-sync] [--no-validate] [--skip-block-validation] [--external-mapping=OLDDIR=NEWDIR] [-T OLDDIR=NEWDIR] [--skip-external-dirs] [-I incremental_mode] [recovery_options] [remote_options] [logging_options] [--help]
-
Merge all incremental backups between the specified incremental backup and its parent full backup into the parent full backup. The parent full backup will receive all merged data, while the merged incremental backup will be deleted as redundancy.
gs_probackup merge -B backup-path --instance=instance_name -i backup_id [-j threads_num] [--progress] [logging_options] [--help]
-
Delete a specified backup or delete backups that do not meet the current retention policy.
gs_probackup delete -B backup-path --instance=instance_name [-i backup-id | --delete-expired | --merge-expired | --status=backup_status] [--delete-wal] [-j threads_num] [--progress] [--retention-redundancy=retention-redundancy] [--retention-window=retention-window] [--wal-depth=wal-depth] [--dry-run] [logging_options] [--help]
-
Verify that all files required for restoring the database exist and are not damaged. If instance_nameis not specified, gs_probackupverifies all available backups in the backup directory. If instance_nameis specified and no additional options are specified, gs_probackupverifies all available backups for this backup instance. If both instance_name and backup-idor recovery objective-related options are specified, gs_probackupchecks whether these options can be used to restore the database.
gs_probackup validate -B backup-path [--instance=instance_name] [-i backup-id] [-j threads_num] [--progress] [--skip-block-validation] [--recovery-target-time=time | --recovery-target-xid=xid | --recovery-target-lsn=lsn | --recovery-target-name=target-name] [--recovery-target-inclusive=boolean] [logging_options] [--help]
Parameter Description
Common parameters
- command
Specifies subcommands except version and help: init, add-instance, del-instance, set-config, set-backup, show-config, show, backup, restore, merge, delete, and validate.
- -?, -help
Displays help information about the command line parameters of gs_probackup and exits.
Only -help can be used in subcommands; -? is forbidden.
- -V, -version
Prints the gs_probackup version and exits.
- -B backup-path, -backup-path=backup-path
Backup path.
System environment variable: $BACKUP_PATH
- -D pgdata-path, -pgdata=pgdata-path
Path of the data directory.
System environment variable: $PGDATA
- -instance=instance_name
Instance name.
- -i backup-id, -backup-id=backup-id
Unique identifier of a backup.
- -format=format
Specifies format of the backup information to be displayed. The plain and JSON formats are supported.
Default value: plain
- -status=backup_status
Deletes all backups in a specified state. The states are as follows:
-
OK: Backup is complete and valid.
-
DONE: Backup has been completed but not verified.
-
RUNNING: Backup is in progress.
-
MERGING: Backups are being merged.
-
DELETING: Backup is being deleted.
-
CORRUPT: Some backup files are damaged.
-
ERROR: Backup fails due to an unexpected error.
-
ORPHAN: Backup is invalid because one of its parent backups is corrupted or lost.
-
-j threads_num, -threads=threads_num
Sets the number of concurrent threads for the backup, restoration, and combination processes.
- -archive
Displays WAL archiving information.
- -progress
Displays progress.
- -note=text
Adds a note to the backup.
Backup-related parameters
- -b backup-mode, -backup-mode=backup-mode
Specifies the backup mode. The value can be FULL or PTRACK.
FULL: creates a full backup. The full backup contains all data files.
PTRACK: creates a PTRACK incremental backup.
- -C, -smooth-checkpoint
Expands checkpoints within a period of time. By default, gs_probackup attempts to complete checkpoints as soon as possible.
- -S slot-name, -slot=slot-name
Specifies the replication slot for WAL stream processing.
- -temp-slot
Creates a temporary physical replication slot for WAL stream processing in the backup instance to ensure that all required WAL segments are still available during the backup.
The default slot name is pg_probackup_slot, which can be changed using the -slot/-S option.
- -backup-pg-log
Includes the log directory in the backup. This directory typically contains log messages. By default, the log directory is not included.
- -E external-directories-paths, -external-dirs=external-directories-paths
Includes the specified directory in the backup. This option is useful for backing up scripts in external data directories, sql dumps, and configuration files. To back up multiple external directories, use colons (:) to separate their paths in Unix.
Example: -E /tmp/dir1:/tmp/dir2
- -skip-block-validation
Disables block-level verification to speed up backup.
- -no-validate
Skips the automatic verification when the backup is complete.
- -no-sync
Disables backup file synchronization to the disk.
- -archive-timeout=timeout
Specifies timeout interval for streaming processing, in seconds.
Default value: 300
- -t rwtimeout
The timeout period for connecting to the database in seconds.
Default value: 120
Restoration-related parameters
- -I, -incremental-mode=none|checksum|lsn
Reuses the valid pages available in PGDATA if they are not modified.
Default value: none
- -external-mapping=OLDDIR=NEWDIR
During restoration, the external directory contained in the backup is moved from OLDDIR to NEWDIR. OLDDIR and NEWDIR must be absolute paths. If the path contains an equal sign (=), use a backslash () to escape. This option can be specified for multiple directories.
- -T OLDDIR=NEWDIR, -tablespace-mapping=OLDDIR=NEWDIR
Relocates the tablespace from the OLDDIR directory to the NEWDIR directory during the restoration. OLDDIR and NEWDIR must be absolute paths. If the path contains an equal sign (=), use a backslash () to escape. This parameter can be specified multiple times for multiple tablespaces. This parameter must be used together with -external-mapping.
- -skip-external-dirs
Skips the external directories in the backup that are specified using the -external-dirs option. The contents of these directories will not be restored.
- -skip-block-validation
Skips block-level verification to speed up verification. During the automatic verification before the restoration, only file-level verification is performed.
- -no-validate
Skips the backup verification.
- -force
Specifies the invalid state that allows ignoring backup. This flag can be used if data needs to be restored from a damaged or invalid backup. Exercise caution when using it.
Recovery objective-related parameters (recovery_options)
NOTE: Currently, continuous WAL archiving PITR cannot be configured. Therefore, parameter usage is restricted as follows: To use continuously archived WAL logs for PITR, perform the following steps:
- Replace the target database directory with the physical backup files.
- Delete all files in the database directory pg_xlog/.
- Copy the archived WAL log file to the pg_xlog file. (Or you can configure restore_command in the recovery.conf file to skip this step.)
- Create the recovery command file recovery.conf in the database directory and specify the database recovery degree.
- Start the database.
- Connect to the database and check whether the database is recovered to the expected status. If the expected status is reached, run the pg_xlog_replay_resume() command so that the primary node can provide services externally.
- -recovery-target-lsn=lsn
Specifies LSN to be restored. Currently, only the backup stop LSN can be specified.
- -recovery-target-name=target-name
Specifies named savepoint to which data is restored. You can obtain the savepoint by viewing the recovery-name column in the backup.
- -recovery-target-time=time
Specifies time to which data is restored. Currently, only recovery-time can be specified.
- -recovery-target-xid=xid
Specifies transaction ID to which data is restored. Currently, only recovery-xid can be specified.
- -recovery-target-inclusive=boolean
When this parameter is set to true, the recovery target will include the specified content.
When this parameter is set to false, the recovery target will not include the specified content.
This parameter must be used together with -recovery-target-name, -recovery-target-time, -recovery-target-lsn, or -recovery-target-xid.
Retention-related parameters (retention_options)
NOTE: The following parameters can be used together with the backup and delete commands.
- -retention-redundancy=retention-redundancy
Number of full backups retained in the data directory. The value must be a positive integer. The value 0 indicates that the setting is disabled.
Default value: 0
- -retention-window=retention-window
Specifies the retention period. The value must be a positive integer. The value 0 indicates that the setting is disabled.
Default value: 0
- -wal-depth=wal-depth
Latest number of valid backups that must be retained on each timeline to perform the PITR capability The value must be a positive integer. The value 0 indicates that the setting is disabled.
Default value: 0
- -delete-wal
Deletes unnecessary WAL files from any existing backup.
- -delete-expired
Deletes the backups that do not comply with the retention policy defined in the pg_probackup.conf configuration file.
- -merge-expired
Merges the oldest incremental backup that meets the retention policy requirements with its expired parent backup.
- -dry-run
Displays the status of all available backups. Expired backups will not be deleted or merged.
Fixed backup-related parameters (pinning_options)
NOTE: To exclude certain backups from the established retention policy, you can use the following parameters with the backup and set-backup commands.
- -ttl=interval
Specifies a fixed amount of time to back up data from the restoration time. The value must be a positive integer. The value 0 indicates that the backup is canceled.
Supported unit: ms, s, min, h, d (default value: s)
For example, -ttl=30d.
- -expire-time=time
Specifies the timestamp when the backup is invalid. The time stamp must comply with the ISO-8601 standard.
For example, -expire-time='2020-01-01 00:00:00+03'.
Log-related parameters (logging_options)
Log levels: verbose, log, info, warning, error, and off.
- -log-level-console=log-level-console
Sets the level of logs to be sent to the console. Each level contains all the levels following it. A higher level indicates fewer messages sent. If this parameter is set to off, the log recording function of the console is disabled.
Default value: info
- -log-level-file=log-level-file
Sets the level of logs to be sent to the log file. Each level contains all the levels following it. A higher level indicates fewer messages sent. If this parameter is set to off, the log file recording function is disabled.
Default value: off
- -log-filename=log-filename
Specifies the name of the log file to be created. The file name can use the strftime mode. Therefore, %-escapes can be used to specify the file name that changes with time.
For example, if the pg_probackup-%u.log mode is specified, pg_probackup generates a log file each day of the week, with %u replaced by the corresponding decimal number, that is, pg_probackup-1.logindicates Monday.pg_probackup-2.log indicates Tuesday, and so on.
This parameter is valid if the -log-level-file parameter is specified to enable log file recording.
Default value: "pg_probackup.log"
- -error-log-filename=error-log-filename
Specifies the name of the log file that is used only for error logs. The specifying method is the same as that of the -log-filename parameter.
It is used for troubleshooting and monitoring.
- -log-directory=log-directory
Specifies the directory where log files are created. The value must be an absolute path. This directory is created when the first log is written.
Default value: $BACKUP_PATH/log
- -log-rotation-size=log-rotation-size
Specifies the maximum size of a log file. If the maximum size is reached, the log file will be circulated after the gs_probackup command is executed. The help and version commands will not lead to a log file circulation. The value 0 indicates that the file size-based loop is disabled.
The unit can be KB, MB, GB, or TB. The default unit is KB.
Default value: 0
- -log-rotation-age=log-rotation-age
Maximum life cycle of a log file. If the maximum size is reached, the log file will be circulated after the gs_probackup command is executed. The help and version commands will not lead to a log file circulation. The $BACKUP_PATH/log/log_rotation directory saves the time of the last created log file. The value 0 indicates that the time-based loop is disabled.
Supported unit: ms, s, min, h, d (default value: min)
Default value: 0
Connection-related parameters (connection_options)
NOTE: The following parameters can be used together with the backup command.
- -d dbname, -pgdatabase=dbname
Specifies the name of the database to connect to. This connection is only used to manage the backup process. Therefore, you can connect to any existing database. If this parameter is not specified in the command line, the PGDATABASE environment variable, or the pg_probackup.conf configuration file, gs_probackup attempts to obtain the value from the PGUSER environment variable. If the PGUSER variable is not set, the value is obtained from the current user name.
System environment variable: $PGDATABASE
- -h hostname, -pghost=hostname
Specifies the host name of the system on which the server is running. If the value begins with a slash (/), it is used as the directory for the UNIX domain socket.
System environment variable: $PGHOST
Default value: local socket
- -p port, -pgport=port
Specifies the TCP port or local Unix domain socket file name extension on which the server is listening for connections.
System environment variable: $PGPORT
Default value: 5432
- -U username, -pguser=username
Specifies the username of the host to be connected.
System environment variable: $PGUSER
- -w, -no-password
Never issues a password prompt. The connection attempt fails if the host requires password verification and the password is not provided in other ways. This parameter is useful in batch jobs and the scripts that require no user password.
- -W password, -password=password
User password for database connection. If the host uses the trust authentication policy, the administrator does not need to enter the -W parameter. If the -W parameter is not provided and you are not a system administrator, the system will ask you to enter a password.
Compression-related parameters (compression_options)
NOTE: The following parameters can be used together with the backup command.
- -compress-algorithm=compress-algorithm
Specifies the algorithm used to compress data file.
The value can be zlib, pglz, or none. If zlib or pglz is set, compression is enabled. By default, the compression function is disabled.
Default value: none
- -compress-level=compress-level
Specifies the compression level. Value range: 0-9
- 0 indicates no compression.
- 1 indicates that the compression ratio is the lowest and processing speed the fastest.
- 9 indicates that the compression ratio is the highest and processing speed the slowest.
- This parameter can be used together with -compress-algorithm.
Default value: 1
- -compress
Compresses with -compress-algorithm=zlib and -compress-level=1.
Remote mode-related parameters (remote_options)
NOTE: The following are parameters that remotely run gs_probackup through SSH, and can be used together with the add-instance, set-config, backup, and restore commands.
- -remote-proto=protocol
Specifies the protocol used for remote operations. Currently, only the SSH protocol is supported. Valid value:
ssh: enables the remote backup mode through SSH. This is the default.
none: The remote mode is disabled explicitly.
If -remote-host is specified, this parameter can be omitted.
- -remote-host=destination
Specifies the IP address or host name of the remote host to be connected.
- -remote-port=port
Specifies the port number of the remote host to be connected.
Default value: 22
- -remote-user=username
Specifies the remote host user for SSH connection. If this parameter is not specified, the user who initiates the SSH connection is used.
Default value: the current user.
- -remote-path=path
Specifies the installation directory of gs_probackup in the remote system.
Default value: current path
- -ssh-options=ssh_options
Specifies the character string of the SSH command line parameter.
Example: -ssh-options='-c cipher_spec -F configfile'
Backup Process
-
Initialize the backup directory. Create the backups/ and wal/ subdirectories in the specified directory to store backup files and WAL files respectively.
gs_probackup init -B backup_dir
-
Add a new backup instance. gs_probackup can store backups of multiple database instances in the same backup directory.
gs_probackup add-instance -B backup_dir -D data_dir -instance instance_name
-
Create a backup for a specified database instance. Before performing an incremental backup, you must create at least one full backup.
gs_probackup backup -B backup_dir -instance instance_name -b backup_mode
-
Restore data from the backup of a specified DB instance.
gs_probackup restore -B backup_dir -instance instance_name -D pgdata-path -i backup_id
Troubleshooting
Problem Description | Cause and Solution |
---|---|
ERROR: query failed: ERROR: canceling statement due to conflict with recovery |
Cause: The operation performed on the standby node is accessing the storage row. The corresponding row is modified or deleted on the primary node, and the Xlog is replayed on the standby node. As a result, the operation is canceled on the standby node. Solution: 1. Increase the values of the following parameters: max_standby_archive_delay max_standby_streaming_delay 2. Add the following configuration item: hot_standby_feedback = on |
PITR Recovery
Background
When a database breaks down or needs to be rolled back to a previous state, the point-in-time recovery (PITR) function of MogDB can be used to restore the database to any point in time after the backup and archive data is generated.
NOTE:
- PITR can only be restored to a point in time after the physical backup data is generated.
- Only the primary node can be restored using PITR. The standby node needs to be fully built to synchronize data with the primary node.
Prerequisites
- Full data files have been physically backed up.
- WAL log files have been archived.
PITR Recovery Process
- Replace the target database directory with the physical backup files.
- Delete all files in the database directory pg_xlog/.
- the archived WAL log file to the pg_xlog file. (Or you can configure restore_command in the recovery.conf file to skip this step.)
- Create the recovery command file recovery.conf in the database directory and specify the database recovery degree.
- Start the database.
- Connect to the database and check whether the database is recovered to the expected status.
- If the expected status is reached, run the pg_xlog_replay_resume() command so that the primary node can provide services externally.
Configuring the recovery.conf File
Archive Recovery Configuration
- restore_command = string
The shell command is used to obtain the archived WAL files among the WAL file series. Any %f in the string is replaced by the name of the file to retrieve from the archive, and any %p is replaced by the path name to it to on the server. Any %r is replaced by the name of the file containing the last valid restart point.
For example:
restore_command = 'cp /mnt/server/archivedir/%f %p'
- archive_cleanup_command = string
This option parameter declares a shell command that is executed each time the system is restarted. archive_cleanup_command provides a mechanism for deleting unnecessary archived WAL files from the standby database. Any %r is replaced by the name of the file containing the last valid restart point. That is the earliest file that must be kept to allow recovery to be restartable, so all files older than %r can be safely removed.
For example:
archive_cleanup_command = 'pg_archivecleanup /mnt/server/archivedir %r'
If multiple standby servers need to be recovered from the same archive path, ensure that WAL files are not deleted from any standby server before the recovery.
- recovery_end_command = string
This parameter is optional and is used to declare a shell command that is executed only when the recovery is complete. recovery_end_command provides a cleanup mechanism for future replication and recovery.
Recovery Object Configuration
- recovery_target_name = string
This parameter declares that the name is recovered to a recovery point created using pg_create_restore_point().
For example:
recovery_target_name = 'restore_point_1'
- recovery_target_time = timestamp
This parameter declares that the name is recovered to a specified timestamp.
For example:
recovery_target_time = '2020-01-01 12:00:00'
- recovery_target_xid = string
This parameter declares that the name is recovered to a transaction ID.
For example:
recovery_target_xid = '3000'
- recovery_target_lsn = string
This parameter declares that the name is recovered to the LSN specified by log.
For example:
recovery_target_lsn = '0/0FFFFFF'
- recovery_target_inclusive = boolean
This parameter declares whether to stop the recovery after the recovery target is specified (true) or before the recovery target is specified (false). This declaration supports only the recovery targets recovery_target_time, recovery_target_xid, and recovery_target_lsn.
For example:
recovery_target_inclusive = true
NOTE:
- Only one of the four configuration items recovery_target_name, recovery_target_time, recovery_target_xid, and recovery_target_lsn can be used at a time.
- If no recovery targets are configured or the configured target does not exist, data is recovered to the latest WAL log point by default.