このページは、お客様の言語ではご利用いただけません。Huawei Cloudは、より多くの言語バージョンを追加するために懸命に取り組んでいます。ご協力ありがとうございました。

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ GaussDB(DWS)/ User Guide/ GaussDB(DWS) Cluster O&M/ Common O&M Commands of GaussDB(DWS)

Common O&M Commands of GaussDB(DWS)

Updated on 2025-03-03 GMT+08:00

This section lists only common O&M commands. The system objects to be queried can be changed based on the site requirements. For details about the returned fields, see the description of system catalogs, system views, and system functions in the product manualsDeveloper Guide.

Viewing O&M Status

Prerequisites: The GaussDB(DWS) cluster has been connected.

  • View the overall running status of the current service.
    1
    select coorname, usename, client_addr, sysdate-query_start as duration, state, enqueue,waiting, pid, query_id, substr(query,1,60) from pgxc_stat_activity where usename != 'Ruby' and usename != 'omm' and state = 'active' order by duration desc;
    
  • View the overall concurrency of the current service.
    1
    select usename,coorname,enqueue,state,count(*) from pgxc_stat_activity where usename <> 'omm' and usename <> 'Ruby' group by 1,2,3,4 order by 4,5 desc limit 30;
    
  • Check the overall waiting status in the current cluster.
    1
    select wait_status,wait_event,count(*) as cnt from pgxc_thread_wait_status where wait_status <> 'wait cmd' and wait_status <> 'synchronize quit' and wait_status <> 'none' and wait_status <> 'wait stream task' group by 1,2 order by 3 desc limit 50;
    
  • View the service running information of the resource pool in the current cluster (resource management and control scenario).
    1
    select s.resource_pool as rpname, count(1) as session_cnt,sum(case when a.state = 'active' then 1 else 0 end) as active_cnt,sum(case when s.enqueue ='global' then 1 else 0 end) as global_wait,sum(case when s.lane = 'fast' and s.status = 'running' then 1 else 0 end) as fast_run,sum(case when s.lane = 'fast' and s.status = 'pending' and s.enqueue not in ('global','none') then 1 else 0 end) as fast_wait,sum(case when s.lane = 'slow' and s.status = 'running' then 1 else 0 end) as slow_run,sum(case when s.lane = 'slow' and s.status = 'pending' and s.enqueue not in ('global','none') then 1 else 0 end) as slow_wait,sum(case when s.status = 'running' then s.statement_mem else 0 end) as est_mem from pg_catalog.pgxc_session_wlmstat s,pg_catalog.pgxc_stat_activity a where s.threadid=a.pid(+) and s.attribute != 'internal' and s.resource_pool != 'root' group by 1;
    
  • Check the dynamic memory watermark of the current cluster.
    1
    select a.nodename,a.memorymbytes as dynamic_used_memory,b.memorymbytes as max_dynamic_memory, dynamic_used_memory/max_dynamic_memory*100 as used_rate  from pgxc_total_memory_detail a join pgxc_total_memory_detail b on a.nodename=b.nodename  where a.memorytype = 'dynamic_used_memory' and b.memorytype = 'max_dynamic_memory' order by a.memorymbytes desc;
    
  • Check the memory usage of each thread. (Check the dynamic memory watermark of the current cluster. Connect to the CN/DN node with high dynamic memory usage that we found to retrieve the information.)
    1
    select b.state, sum(totalsize) as totalsize, sum(freesize) as freesize, sum(usedsize) as usedsize from pv_session_memory_detail a , pg_stat_activity b where split_part(a.sessid,'.',2) = b.pid group by b.state order by totalsize desc limit 20;
    
  • Check the memory used by each session in the current instance. (Check the dynamic memory watermark of the current cluster. Connect to the CN/DN node with high dynamic memory usage that we found to retrieve the information.)
    1
    select split_part(pv_session_memory_detail.sessid,'.',2) pid,pg_size_pretty(sum(totalsize)) total_size,count(*) context_count from pv_session_memory_detail group by pid order by sum(totalsize) desc;
    
  • Check the memory used by each SQL statement in the current instance. (Check the dynamic memory watermark of the current cluster. Connect to the CN/DN node with high dynamic memory usage that we found to retrieve the information.)
    1
    select sessid, contextname, level,parent, pg_size_pretty(totalsize) as total ,pg_size_pretty(freesize) as freesize, pg_size_pretty(usedsize) as usedsize, datname,query_id, query from pv_session_memory_detail a , pg_stat_activity b where split_part(a.sessid,'.',2) = b.pid order by totalsize desc limit 100;
    

Emergency Recovery

CAUTION:

Always confirm emergency operations that may impact services with the customer before proceeding. Never attempt to perform these operations independently.

Prerequisites: The GaussDB(DWS) cluster has been connected.

  • View the overall running status of the current service. Obtain the PID of the statement to be scanned.
    1
    2
    execute direct on(cn_name) 'select pg_cancel_backend(PID of the scanned statement)';
    execute direct on(cn_name) 'select pg_terminate_backend(PID of the scanned statement)';
    
  • Group scan statements together in batches, without executing the scan command.
    1
    select 'execute direct on(' || coorname || ') ''select pg_terminate_backend(' || pid || ')'';',sysdate-query_start as dur, substr(query,1,60) from pgxc_stat_activity where usename != 'omm' and usename != 'Ruby' and state = 'active' order by dur desc limit 30;
    
  • Clear idle connections.
    1
    2
    clean connection to all for database xxx;    --Clear idle connections.
    select * from pgxc_clean_free_conn();        --Clear pooler cache connections.
    
  • Fix the CCN count by connecting to the CCN.
    1
    2
    select * from pg_stat_get_workload_struct_info();  --Retain the CCN information.
    select gs_wlm_node_recover(true);  --Repair CCNs.
    
  • Lock abnormal users.
    1
    2
    alter user usename account lock;    --Lock a user.
    alter user usename account unlock;   --Unlock a user.
    
  • Add a service to the blacklist.
    1
    2
    3
    select * from gs_append_blocklist(unique_sql_id);   --Add a service to the blacklist.
    select * from gs_blocklist_query;   --Query the existing blacklist.
    select gs_remove_blocklist(unique_sql_id);  --Remove the blacklist.
    

Service Analysis

Prerequisites: The GaussDB(DWS) cluster has been connected.

  • View the waiting status of the currently executing SQL statement. Run the statement user for viewing the overall running status of the current service and obtain the value of the query_id field, which can be used as the Actual query ID in the following statement.
    1
    select * from pgxc_thread_wait_status where query_id = Actual query ID order by node_name,wait_status,wait_event;
    
  • View the running process information of the running SQL statement. Run the statement user for viewing the overall running status of the current service and obtain the value of the query_id field, which can be used as the Actual query ID in the following statement.
    1
    select * from pgxc_wlm_session_statistics where queryid = Actual query ID;
    
  • View the running information of historical SQL statements. Run the statement used for viewing the overall running status of the current service and obtain the value of the query_id field, which can be used as the Actual query ID in the following statement.
    1
    select * from pgxc_wlm_session_info where queryid = Actual query ID;
    
  • View the skew information of a single table.
    1
    select * from table_distribution('schema_name','table_name');
    
  • View the dirty page rate of a single table.
    1
    select c.oid AS relid, n.nspname AS schemaname, c.relname, pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, pg_stat_get_tuples_updated(c.oid) AS n_tup_upd, pg_stat_get_tuples_deleted(c.oid) AS n_tup_del, pg_stat_get_live_tuples(c.oid) AS n_live_tup, pg_stat_get_dead_tuples(c.oid) AS n_dead_tup, cast( (n_dead_tup / (n_live_tup + n_dead_tup + 0.0001) * 100) AS numeric(5,2)) AS dirty_page_rate from pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace where c.oid = 'schema_name.table_name'::regclass::oid;
    
  • View the table definition and index information.
    1
    select pg_get_tabledef('schema_name.table_name');
    
  • Check the table size.
    1
    select pg_size_pretty(pg_table_size('schema_name.table_name'));
    
  • View the creation time, modification time, and last analysis time of the table.
    1
    select * from pg_object where object_oid='schema_name.table_name'::regclass;
    
  • View details about dirty data.
    1
    2
    3
    4
    5
    6
    7
    start transaction read only;
    set enable_show_any_tuples = true;
    set enable_indexscan = off;
    set enable_bitmapscan = off;
    select ctid,xmin,xmax,pgxc_is_committed(xmin),pgxc_is_committed(xmax),oid,* from schema_name.table_name;
    select xmin,xmax,ctid, * from pgxc_node;
    rollback;
    

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback