• PG数据库预防事务年龄过大处理


    PG数据库预防事务年龄过大处理

    PSQL_BIN_DIR=/home/postgres/pgsql/bin
    $PSQL_BIN_DIR/psql -d postgres -U postgres  -q -At -c "select datname from pg_database where datname not in('template0','template1','postgres') order by datname;"  >${DBNAMEFILE}
    while read -r line
    do
    	DB_NAME=${line}
    	$PSQL_BIN_DIR/psql   -U postgres   -d ${DB_NAME} -q -At -c "select relname  from pg_class where  age(relfrozenxid) >= 1000000000 and age(relfrozenxid) <> 2147483647 and relkind='r' "  > ${old_age_tables}
    	
    	for line in `cat ${old_age_tables}`
    	do
    		table_name="`echo $line`"
    		echo  "${table_name} is being freezed ! ! ! " >>  ${AUTOVACUUM_LOGFILE}
    		if [ -n "${table_name}" ];then
    	$PSQL_BIN_DIR/psql -d ${DB_NAME} -U postgres -c "d $table_name"
    	if [ $? -eq 0 ];then
    			$PSQL_BIN_DIR/vacuumdb  -z  -e -v  -F --username=$DBUSER -h ${MY_PGHOST} -t ${table_name} -d ${DB_NAME} >>${AUTOVACUUM_LOGFILE}    2>&1
    	fi
    		fi
    	done
    
    done < ${DBNAME}
    
  • 相关阅读:
    Java中的IO基本用法
    Java中的字符串
    centos
    Linux 常用命令
    rand随机
    auto.js 学习
    毕业了!!!
    论文的查找
    kill的使用
    安装交叉编译工具arm-linux-gcc-4.3.2 并且修改环境变量
  • 原文地址:https://www.cnblogs.com/yldf/p/11899986.html
Copyright © 2020-2023  润新知