!!! Must be executed on each master server of the cluster !!!
Postgres cluster #1:***************************
- db-pgsql01.oracak.ru - master
Postgres cluster #2:
***************************
- db-pgsql03.oracak.ru - master
/****************************
*** wallet ***
****************************/
1. Add the cron_tech user's password to the .pgpass file.
[postgres] >
vi ~/.pgpass
-- for dbquik1 for "db-pgsql01"chmod 600 ~/.pgpass
localhost:5432:dbquik1:cron_tech:***
-- for dbquik2 for "db-pgsql03"
localhost:5432:dbquik2:cron_tech:***
/****************************
*** heartbeat ***
****************************/
1. Creating a task for writing to ggadmin.hb.
[cron_tech] psql>
SELECT cron.schedule('*/10 * * * *', $$insert into ggadmin.hb (INSTANCE_NAME, SRC_TIMESTAMP) values ('OGG', current_timestamp);DELETE FROM ggadmin.hb WHERE id < (SELECT max(id) - 10000 FROM ggadmin.hb);$$);
-- Checking the task's operation.
[cron_tech] psql>
-- pg_cron
select * from cron.job;
select * from cron.job_run_details order by runid desc;
-- HB
select * from ggadmin.hb order by id desc;
select * from ggadmin.hb_target order by dest_timestamp desc;
/****************************
*** profile ***
****************************/
1. Creating a task for writing to the pg_stat_statements snapshot.
[cron_tech] psql>
SELECT cron.schedule('*/1 * * * *', $$select profile.take_sample()$$);
-- Checking the task's operation
[cron_tech] psql>
-- pg_cron
select * from cron.job;
select * from cron.job_run_details order by runid desc;
-- snapshots
select * from profile.samples order by sample_time desc;