Greenplum定期vacuum系统表以及定期删除日志


1.系统表定期vacuum,重建索引

建议定期vacuum系统表并重建索引,以下脚本可以定期执行
#!/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 --system -d $DBNAME

analyzedb -s pg_catalog -d $DBNAME

2.数据库日志文件管理
greenplum日志存放在pg_log下,master节点和每个segment节点都会有,格式为gpdb-YYYY-MM-DD_hhmmss.cs
需要我们定期清理

定期清理master节点的日志,保留最近8天的日志

find master日志目录  -type f -name "gpdb-*.csv" -ctime +8 -exec rm {} \;


平时如果gp有问题,也可以查看相关日志,日志格式见下表

Table 3. Greenplum Database Server Log Format
# Field Name Data Type Description
1 event_time timestamp with time zone 时间戳
2 user_name varchar(100) 数据库用户名
3 database_name varchar(100) 数据库名
4 process_id varchar(10) 系统进程ID
5 thread_id varchar(50) The thread count (prefixed with "th")
6 remote_host varchar(100) 主机名或者地址
7 remote_port varchar(10) master或者segment的端口
8 session_start_time timestamp with time zone session打开时间
9 transaction_id int Top-level transaction ID on the master. This ID is the parent of any subtransactions.
10 gp_session_id text Session identifier number (prefixed with "con")
11 gp_command_count text The command number within a session (prefixed with "cmd")
12 gp_segment text The segment content identifier (prefixed with "seg" for primaries or "mir" for mirrors). The master always has a content ID of -1.
13 slice_id text The slice ID (portion of the query plan being executed)
14 distr_tranx_id text Distributed transaction ID
15 local_tranx_id text Local transaction ID
16 sub_tranx_id text Subtransaction ID
17 event_severity varchar(10) Values include: LOG, ERROR, FATAL, PANIC, DEBUG1, DEBUG2
18 sql_state_code varchar(10) SQL state code associated with the log message
19 event_message text Log or error message text
20 event_detail text Detail message text associated with an error or warning message
21 event_hint text Hint message text associated with an error or warning message
22 internal_query text The internally-generated query text
23 internal_query_pos int The cursor index into the internally-generated query text
24 event_context text The context in which this message gets generated
25 debug_query_string text User-supplied query string with full detail for debugging. This string can be modified for internal use.
26 error_cursor_pos int The cursor index into the query string
27 func_name text The function in which this message is generated
28 file_name text The internal code file where the message originated
29 file_line int The line of the code file where the message originated
30 stack_trace text Stack trace text associated with this message


查看日志:
gplogfilter -n 3 输出最后3行日志
如果想查看segment节点的日志,那么可以执行以下命令

gpssh -f seg_hosts  #seg_hosts为segment节点的主机列表
=>source /usr/local/greenplum-db/greenplum_path.sh
=>gplogfilter -n 3 /data01/gpadmin/gpdata/primary/gpseg*/pg_log/gpdb*.log  #segment节点的日志目录

gplogfilter具体使用可看--help
除了数据库日志,还有管理日志在~/gpAdminLogs下面,可以到相关目录查看




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值