zoukankan      html  css  js  c++  java
  • gp日志查看

    笔记:之前登录master节点看pg_log目录下的文件,后面每次这样看感觉挺不方便的,查了一下文档

    select ma.logtime at time zone 'CST' as logtime,ma.loguser,ma.logpid,ma.loghost,ma.logstate,ma.logmessage,ma.logdetail from gp_toolkit.gp_log_database ma order by logtime desc limit 200;

    这个就是查的pg_log下的日志文件,只是是外部表形式,所以性能有一些差,只要定时切割pg_log下面的文件就行,还有一个视图 gp_toolkit.gp_log_system, 它与 gp_toolkit.gp_log_database 区别是一个是all,一个是current_database。

    表空间间隙查看方法(膨胀):

    select * from gp_toolkit.gp_log_database;

    表空间间隙收缩方法:

    #!/bin/bash
    DBNAME="<database_name>"
    SYSTABLES="' pg_catalog.' || relname || ';' from pg_class a, pg_namespace b 
    where a.relnamespace=b.oid and b.nspname='pg_catalog' and a.relkind='r'"
    psql -tc "SELECT 'VACUUM' || $SYSTABLES" $DBNAME | psql -a $DBNAME
    reindexdb -s -d $DBNAME
    analyzedb -s pg_catalog -d $DBNAME

    查锁情况:

    SELECT least(query_start,xact_start) + '8 hour' start_time
                 ,pg_locks.pid
                 , pg_database.datname
                 , pg_stat_activity.usename
                 , locktype
                 , mode
                 , pg_stat_activity.application_name
                 , state
                 , CASE WHEN granted='f' THEN 'wait_lock' WHEN granted='t' THEN 'get_lock' END lock_satus
                 , pg_stat_activity.query
                 , count(*)::float
              FROM pg_locks
              JOIN pg_database ON pg_locks.database=pg_database.oid
              JOIN pg_stat_activity on pg_locks.pid=pg_stat_activity.pid
            WHERE NOT pg_locks.pid=pg_backend_pid()
            AND pg_stat_activity.application_name<>'pg_statsinfod'
            GROUP BY pg_locks.pid, pg_database.datname,pg_stat_activity.usename, locktype, mode,
            pg_stat_activity.application_name, state , lock_satus ,pg_stat_activity.query, start_time
            ORDER BY 2 desc;
  • 相关阅读:
    Python中列表
    Python中For循环
    While循环
    python中if else流程判断
    python中get pass用法
    python学习
    Forbidden Attack:7万台web服务器陷入被攻击的险境
    爱恨交织!我们经常抱怨却离不开的7种语言
    玩转大数据,你需要了解这8种项目类型!
    如何用 Python 实现 Web 抓取?
  • 原文地址:https://www.cnblogs.com/5sdba-notes/p/14128324.html
Copyright © 2011-2022 走看看