Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >GreenPlum 6.27.0版本新特性及pg_cron模块配置定时任务说明

GreenPlum 6.27.0版本新特性及pg_cron模块配置定时任务说明

作者头像
AiDBA宝典
发布于 2024-04-15 03:01:41
发布于 2024-04-15 03:01:41
20500
代码可运行
举报
运行总次数:0
代码可运行

简介

GreenPlum 6.27.0于2024-04-05已发布,GreenPlum的发布历史请参考:https://www.xmmup.com/greenplumbanbenfabulishi.html

GreenPlum 6.27.0 有以下几个新特性:

Greenplum Database 6.27.0 includes these new and changed features:

  • The gpfdist parallel file distribution utility now supports multi-threaded data compression and transmission.
  • The PgBouncer distributed with Greenplum Database has been updated to version 1.21.0.
  • The gpcheckcat utility now includes a new test -- mix_distribution_policy -- which checks for tables created with legacy and non-legacy hash operations.
  • This release updates the plcontainer version to 2.4.0 and the python3 image version to 2.4.0. Previous image releases cannot be used with the 2.4.0+ plcontainer.
  • The pg_config utility option --version now displays the version of the PostgreSQL backend server, and the new option --gp_version prints the version of Greenplum.
  • VMware Greenplum 6.27.0 introduces the pg_cron module, which provides a cron-based job scheduler that runs inside the database.
  • VMware Greenplum 6.27.0 supports Run-length encoding (RLE) compression with the Zstandard algorith, or zstd for column-oriented tables.
  • The log_checkpoints server configuration parameter is now set to on by default.
  • The gpsupport gp_log_collector tool now supports gathering logs for VMware Greenplum Disaster Recovery, via the new -with-gpdr-primary and -with-gpdr-recovery options.
  • The ip4r module distributed with VMware Greenplum has been updated to version 2.4.2.
  • With the 6.27.0 release, VMware Greenplum now supports the VMware Greenplum Virtual Appliance. The virtual machine appliance contains everything you may need for an easy deploying of VMware Greenplum on vSphere. See VMware Greenplum on vSphere for more details.
  • VMware Greenplum 6.27.0 enhances WAL archive recovery by preventing scanning of nonexistent WAL segment files.
  • You may now pass the -i and --differential in the same gprecoverseg command.

其中,最令我关注的还是pg_cron模块,这个模块可以配置定时任务,接下来着重介绍该特性。

6.27.0测试环境

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
docker rm -f gpdb6270
docker run -itd --name gpdb6270 -h gpdb6270 \
  -p 5627:5432 -p 26270:28080  \
  -v /sys/fs/cgroup:/sys/fs/cgroup \
  --privileged=true lhrbest/greenplum:6.27.0 \
  /usr/sbin/init

docker exec -it gpdb6270 bash

su - gpadmin


gpstart -a
gpcc start



gpcc status
gpstate 

pg_cron模块使用说明

参考:

https://docs.vmware.com/en/VMware-Greenplum/6/greenplum-database/ref_guide-modules-pg_cron.html

https://github.com/citusdata/pg_cron

在启用pg_cron模块后,后台会有一个进程:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
[gpadmin@gpdb6270 ~]$ ps -ef|grep cron | grep post
gpadmin    16678   16660  0 14:02 ?        00:00:00 postgres:  5432, bgworker: pg_cron launcher   
[gpadmin@gpdb6270 ~]$ 

pg_cron的时间配置:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 ┌───────────── min (0 - 59)
 │ ┌────────────── hour (0 - 23)
 │ │ ┌─────────────── day of month (1 - 31) or last day of the month ($)
 │ │ │ ┌──────────────── month (1 - 12)
 │ │ │ │ ┌───────────────── day of week (0 - 6) (0 to 6 are Sunday to
 │ │ │ │ │                  Saturday, or use names; 7 is also Sunday)
 │ │ │ │ │
 │ │ │ │ │
 * * * * *

安装pg_cron

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
-- 1、默认在postgres数据库中,可以通过如下命令修改成其它数据库(可选)
gpconfig -c cron.database_name -v 'db_name' --skipvalidation


-- 2、修改shared_preload_libraries参数,注意该参数之前的值
gpconfig -s shared_preload_libraries

gpconfig -c shared_preload_libraries -v 'metrics_collector,pg_cron'
gpstop -M fast -ar

gpconfig -s shared_preload_libraries


-- 3、只能在第1步中cron.database_name配置的数据库中创建扩展,否则会报错
CREATE EXTENSION pg_cron;
GRANT USAGE ON SCHEMA cron TO user1;

报错:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
ERROR:  can only create extension in database postgres
DETAIL:  Jobs must be scheduled from the database configured in cron.database_name, since the pg_cron background worker reads job descriptions from this database.
HINT:  Add cron.database_name = 'lhrgpdb' in postgresql.conf to use the current database.

升级pg_cron

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
ALTER EXTENSION pg_cron UPDATE TO '1.6.2';

使用pg_cron

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
SELECT cron.schedule('30 3 * * 6', $$DELETE FROM events WHERE event_time < now() - interval '1 week'$$);

-- 更改JOB
UPDATE cron.job SET database = 'database1' WHERE jobid = 106;
SELECT cron.reload_job();


SELECT cron.schedule_in_database('weekly-vacuum', '0 4 * * 0', 'VACUUM', 'some_other_database');



-- Delete old cron.job_run_details records of the current user every day at noon
SELECT  cron.schedule('delete-job-run-details', '0 12 * * *', $$DELETE FROM cron.job_run_details WHERE end_time < now() - interval '7 days'$$);



--2秒执行1SELECT  cron.schedule_in_database('run-select66', '2 seconds', $$SELECT 66$$,'db1');

-- 修改为10UPDATE cron.job SET schedule = '10 seconds' WHERE jobid = 2;
-- 或:SELECT cron.alter_job(2,'20 seconds');
SELECT cron.reload_job();


-- 删除job
SELECT cron.unschedule(1);


-- 禁用或启用某个job
UPDATE cron.job SET active = 'f' WHERE jobid = 2;
SELECT cron.reload_job();



-- 查询
SELECT * from cron.job;
select * from cron.job_run_details order by runid desc limit 100;

参考

https://docs.vmware.com/en/VMware-Greenplum/6/greenplum-database/relnotes-release-notes.html

https://docs.vmware.com/en/VMware-Greenplum/6/greenplum-database/ref_guide-modules-pg_cron.html

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-04-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 DB宝 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
GreenPlum官方监控工具之GPCC 6.8.3安装配置
GPCC 监控系统性能指标,分析集群健康状况,并使数据库管理员能够在 Greenplum Database 环境中执行管理任务。它提供了一个本地浏览器的 HTML5 图形控制台,用于查看 Greenplum Database 系统指标和执行某些数据库管理任务。
AiDBA宝典
2023/04/27
8790
GreenPlum官方监控工具之GPCC 6.8.3安装配置
GreenPlum 7.1.0新特性介绍
GreenPlum 7.0.0于2023-09-28发布,大约半年后,GreenPlum 7.1.0于2024-02-09发布。
AiDBA宝典
2024/02/26
9831
GreenPlum 7.1.0新特性介绍
Greenplum 7 新特性整理
参考:https://www.xmmup.com/zaidockerzhongkuaisutiyangreenplum-7-0-0.html
AiDBA宝典
2023/10/16
1.4K0
Greenplum 7 新特性整理
GreenPlum 6.26新增gpmt排查工具
在GP 6.26中的新增工具gpmt,GPMT (Greenplum Magic Tool)提供了一套诊断应用工具来排查和解决常见的可支持性问题,并提供了一种一致的方法来收集VMware支持所需的信息。
AiDBA宝典
2023/12/26
2480
GreenPlum 6.26新增gpmt排查工具
在Docker中快速体验GreenPlum 7.0.0和gpcc 7.0.0
GreenPlum 7.0.0正式版已于2023.09.29发布,基于PG 12.12内核版本。
AiDBA宝典
2023/11/16
9510
在Docker中快速体验GreenPlum 7.0.0和gpcc 7.0.0
postgresql 定期任务的 PG_cron
基本上大部分数据库都有定时任务,最近开发问我PostgreSQL 要做定时任务,有的存储过程要在夜间去和financial 的 服务器来交互。我的第一个反应就是用LINUX 的定时任务不就可以了,但这个程序员提出 SQL SERVER ORACLE 都有定时任务,postgresql 也应该有吧。所以就有了这篇文字
AustinDatabases
2020/07/01
2.3K0
greenplum5.7,greenplum-cc-web4.0详细安装配置文档
1、 本安装手册描述适用于Greenplum4.0以上版本的安装Greenplum-cc-web操作
zhangdd
2020/01/02
1.1K0
docker安装Greenplum
Greenplum是业界最快最高性价比的关系型分布式数据库,它在开源的PostgreSQL的基础上采用MPP架构(Massive Parallel Processing,海量并行处理),具有强大的大规模数据分析任务处理能力。
summerking
2022/10/27
2.3K0
docker安装Greenplum
破茧成蝶:PgBouncer在GreenPlum中的部署与优化,携手Prometheus+Grafana构建全方位性能仪表板
PgBouncer工具可以用于PostgreSQL和Greenplum数据库连接的连接池。
AiDBA宝典
2024/04/25
4980
破茧成蝶:PgBouncer在GreenPlum中的部署与优化,携手Prometheus+Grafana构建全方位性能仪表板
Snova运维篇(三):GP数据库备份和恢复
本节主要从gp数据备份和恢复角度深入学习gp数据库。定期执行备份能确保在数据损坏或者系统失效发生时能恢复数据或者重建Greenplum数据库系统。用户还可以使用备份从一个Greenplum数据库系统迁移数据到另一个。
snova-最佳实践
2019/12/26
2K0
Snova运维篇(三):GP数据库备份和恢复
在Docker中快速体验GreenPlum 7.0.0
地址:https://hub.docker.com/r/lhrbest/greenplum/tags
AiDBA宝典
2023/08/10
1.3K0
在Docker中快速体验GreenPlum 7.0.0
Greenplum 6 安装配置详解
114.112.77.199 master、segment 210.73.209.103 standby master、segment 140.210.73.67 segment
用户1148526
2021/12/07
2.2K0
Greenplum编译安装
Greenplum部署手册 一、环境准备 操作系统 ARM-Neokylin7.6-64bit 安装包 greenplum6.9.1(源码) 设置语言 echo "export LANG=en_US.UTF-8" >> /etc/profile source /etc/profile 编译环境 yum install -y curl-devel bzip2-devel python-devel openssl-devel readline-devel perl-ExtUtils-Embed libxml2
shaonbean
2020/09/22
2K0
Snova运维篇(二):GP集群配置和高可用特性
Greenplum数据的配置文件postgresql.conf位于数据库实例的数据目录之下。
snova-最佳实践
2019/12/24
1.4K0
Snova运维篇(二):GP集群配置和高可用特性
进阶数据库系列(二十二):PostgreSQL 数据库作业调度工具 pgAgent
pgAgent 是 Postgres 数据库的作业调度代理,能够运行多步批处理或 shell 脚本以及复杂调度的 SQL 任务。在 pgAdmin v1.9 之前,pgAgent作为 pgAdmin 的一部分提供,从 pgAdmin v1.9 开始,pgAgent作为单独的应用程序提供。
民工哥
2023/08/22
1.2K0
进阶数据库系列(二十二):PostgreSQL 数据库作业调度工具 pgAgent
一文了解GreenPlum
行式数据库是按照行存储的,行存储就是各行放入连续的物理位置,就行我们平时写字一样,一行一行的写,读取的时候也是一行一行的读取。像SQL server,Oracle,mysql等传统的关系型数据库都属于行式数据库范畴。
数据社
2020/06/04
1.5K0
一文了解GreenPlum
golang cron 定时任务
最开始接触定时任务的概念是在大二的一个计算机操作系统设计的实验课上,当时老师给了五个任务要求,自己任选三个小组完成。
李海彬
2019/05/08
12.3K0
GreenPlum 6.19.3 安装部署基础版
Greenplum是一个面向数据仓库应用的关系型数据库,因为有良好的体系结构,所以在数据存储、高并发、高可用、线性扩展、反应速度、易用性和性价比等方面有非常明显的优势。Greenplum是一种基于PostgreSQL的分布式数据库,其采用sharednothing架构,主机、操作系统、内存、存储都是自我控制的,不存在共享。 本质上讲Greenplum是一个关系型数据库集群,它实际上是由数个独立的数据库服务组合成的逻辑数据库。与RAC不同,这种数据库集群采取的是MPP(Massively Parallel Processing)架构。跟MySQL、Oracle 等关系型数据不同,Greenplum可以理解为分布式关系型数据库。 关于Greenplum的更多信息请访问https://greenplum.org/
AiDBA宝典
2023/04/27
1.7K0
GreenPlum 6.19.3 安装部署基础版
GPCC参数metrics_collector配置错误导致GreenPlum启动报错
从启动日志“2023-01-16 12:58:59.465304 CST,,,p8992,th834783360,,,,0,,,seg-1,,,,,"FATAL","58P01","could not access file ""metrics_collector"": No such file or directory",,,,,,,,"internal_load_library","dfmgr.c",202,1 0xbef3fc postgres errstart (elog.c:557)”可以看到应该是metrics_collector的问题,这个值是参数文件postgresql.conf中的shared_preload_libraries的值,用于开启gpcc的指标监控。
AiDBA宝典
2023/04/27
8520
GPCC参数metrics_collector配置错误导致GreenPlum启动报错
在CentOS 8.4中安装GreenPlum 6
https://network.pivotal.io/products/vmware-tanzu-greenplum#/releases/1163282/file_groups/9837
AiDBA宝典
2023/11/22
1.2K0
在CentOS 8.4中安装GreenPlum 6
相关推荐
GreenPlum官方监控工具之GPCC 6.8.3安装配置
更多 >
领券
💥开发者 MCP广场重磅上线!
精选全网热门MCP server,让你的AI更好用 🚀
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验