KingbaseES R6 集群测试job管理测试
案例说明:
本案例参考《Job And Schedule (V8R6C4)》(https://www.cnblogs.com/kingbase/p/15194227.html)单实例环境下的job管理案例。
本案例重点是在测试集群切换后在新的主库下,job任务是否能正常被执行。
测试数据库版本:
prod=# select version();
version
----------------------------------------------------------------------------------------------------------
KingbaseES V008R006C005B0023 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit
(1 row)
集群架构:
[kingbase@node3 bin]$ ./repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+-------------------
1 | node243 | primary | * running | | default | 100 | 1 | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node248 | standby | running | node243 | default | 100 | 1 | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
一、配置job
1、配置kb_schedule extension (所有节点)
[kingbase@node3 data]$ cat kingbase.conf |grep schedule
shared_preload_libraries = 'repmgr,liboracle_parser, synonym, plsql, force_view, kdb_flashback,plugin_debugger, plsql_plugin_debugger, plsql_plprofiler, ora_commands,kdb_ora_expr, sepapower, dblink, sys_kwr, sys_ksh, sys_spacequota, sys_stat_statements, backtrace, kdb_utils_function,kdb_schedule'
prod=# select name from sys_available_extensions where name like '%schedule%';
name
--------------
kdb_schedule
(1 row)
2、所有节点配置job_queue_processes
prod=# show job_queue_processes;
job_queue_processes
---------------------
0
(1 row)
prod=# alter system set job_queue_processes=5;
ALTER SYSTEM
prod=# select sys_reload_conf();
sys_reload_conf
-----------------
t
(1 row)
注意: 配置完成后,重启集群。
# 主备库:
test=# show job_queue_processes;
job_queue_processes
---------------------
5
(1 row)
3、测试job管理
主库执行:
1)创建测试表
prod=# create table d_test(tid varchar2(64), insdate date);
CREATE TABLE
2)创建测试procedure
prod=# \set SQLTERM /
prod=#
prod=# create or replace procedure p_test() as
prod-# begin
prod-# insert into d_test values(to_char(sysdate, 'yyyymmddhh24miss'), sysdate);
prod-# commit;
prod-# end;
prod-# /
CREATE PROCEDURE
\set SQLTERM ;
3)创建job
prod=# \set SQLTERM ;
prod=#
prod=# \set SQLTERM /
prod=# DECLARE
prod-# v_jobid NUMBER;
prod-# BEGIN
prod-# dbms_job.submit(v_jobid, 'call p_test()', now(), 'Freq=Minutely;Interval=1');
prod-# COMMIT;
prod-# END;
prod-# /
\set SQLTERM ;ANONYMOUS BLOCK
prod=# \set SQLTERM ;
prod=# call dbms_job.instance(1, 'user=system dbname=prod port=54321 password=123456ab');
CALL
4)主备库查询
prod=# select jobid,jobname,jobenabled,joblastrun,jobnextrun,jobrepeattimes from kdb_job;
jobid | jobname | jobenabled | joblastrun | jobnextrun | jobrepeattimes
-------+---------------------------------------------+------------+------------+---------------------------
1 | internal_job1:2021-03-01 16:52:12.416076+08 | f | | 2021-03-01 16:52:12.416076+08 | 0
(1 row)
主库执行:
5)启用job
prod=# call dbms_job.broken(1,false);
CALL
主备库查询:
prod=# select jobid,jobname,jobenabled,joblastrun,jobnextrun,jobrepeattimes from kdb_job;
jobid | jobname | jobenabled | joblastrun | jobnextrun | jobrepeattimes
-------+---------------------------------------------+------------+------------+--------------------------
1 | internal_job1:2021-03-01 16:52:12.416076+08 | t | | 2021-03-01 16:52:12.416076+08 | 0
(1 row)
prod=# select * from kdb_schedule.kdb_schedule;
scid | scname | scdesc | scenabled | scstart | scend | screpeat_interval
------+--------+--------+-----------+----------------------------+-------+--------------------------
1 | | | t | 2021-03-01 16:52:12.416076 | | Freq=Minutely;Interval=1
(1 row)
prod=# select * from kdb_schedule.kdb_schedule_job;
sjid | sjscid | sjjobid | sjstatus | sjlasttime | sjnexttime
------+--------+---------+----------+------------+-------------------------------
1 | 1 | 1 | s | | 2021-03-01 16:52:12.416076+08
(1 row)
6)查看job执行情况
# 主备库查询:
prod=# select * from d_test;
tid | insdate
----------------+---------------------
20210301170529 | 2021-03-01 17:05:29
20210301171623 | 2021-03-01 17:16:23
20210301172126 | 2021-03-01 17:21:26
20210301172216 | 2021-03-01 17:22:16
20210301172316 | 2021-03-01 17:23:16
20210301172416 | 2021-03-01 17:24:16
(6 rows)
二、主备切换测试
1、switchover切换
# 执行switchover
[kingbase@node1 bin]$ ./repmgr standby switchover -h 192.168.7.243 -U esrep -d esrep --dry-run
WARNING: following problems with command line parameters detected:
database connection parameters not required when executing UNKNOWN ACTION
NOTICE: checking switchover on node "node248" (ID: 2) in --dry-run mode
INFO: ES connection to host "192.168.7.243" succeeded
INFO: able to execute "repmgr" on remote host "localhost"
INFO: 1 walsenders required, 32 available
INFO: demotion candidate is able to make replication connection to promotion candidate
INFO: 0 pending archive files
INFO: replication lag on this standby is 0 seconds
INFO: 1 replication slots required, 32 available
INFO: would pause repmgrd on node "node243" (ID 1)
INFO: would pause repmgrd on node "node248" (ID 2)
NOTICE: local node "node248" (ID: 2) would be promoted to primary; current primary "node243" (ID: 1) would be demoted to standby
INFO: following shutdown command would be run on node "node243":
"/home/kingbase/cluster/R6C5/R6C5R/kingbase/bin/sys_ctl -D '/home/kingbase/cluster/R6C5/R6C5R/kingbase/data' -l /home/kingbase/cluster/R6C5/R6C5R/kingbase/bin/logfile -W -m fast stop"
INFO: prerequisites for executing STANDBY SWITCHOVER are met
[kingbase@node1 bin]$ ./repmgr standby switchover -h 192.168.7.243 -U esrep -d esrep
WARNING: following problems with command line parameters detected:
database connection parameters not required when executing UNKNOWN ACTION
NOTICE: executing switchover on node "node248" (ID: 2)
INFO: pausing repmgrd on node "node243" (ID 1)
INFO: pausing repmgrd on node "node248" (ID 2)
NOTICE: local node "node248" (ID: 2) will be promoted to primary; current primary "node243" (ID: 1) will be demoted to standby
NOTICE: stopping current primary node "node243" (ID: 1)
NOTICE: issuing CHECKPOINT
NOTICE: node (ID: 1) release the virtual ip 192.168.7.241/24 success
DETAIL: executing server command "/home/kingbase/cluster/R6C5/R6C5R/kingbase/bin/sys_ctl -D '/home/kingbase/cluster/R6C5/R6C5R/kingbase/data' -l /home/kingbase/cluster/R6C5/R6C5R/kingbase/bin/logfile -W -m fast stop"
INFO: checking for primary shutdown; 1 of 60 attempts ("shutdown_check_timeout")
INFO: checking for primary shutdown; 2 of 60 attempts ("shutdown_check_timeout")
INFO: checking for primary shutdown; 3 of 60 attempts ("shutdown_check_timeout")
INFO: checking for primary shutdown; 4 of 60 attempts ("shutdown_check_timeout")
INFO: checking for primary shutdown; 5 of 60 attempts ("shutdown_check_timeout")
NOTICE: current primary has been cleanly shut down at location 0/8000028
NOTICE: PING 192.168.7.241 (192.168.7.241) 56(84) bytes of data.
--- 192.168.7.241 ping statistics ---
2 packets transmitted, 0 received, +1 errors, 100% packet loss, time 1003ms
WARNING: ping host"192.168.7.241" failed
DETAIL: average RTT value is not greater than zero
INFO: loadvip result: 1, arping result: 1
NOTICE: new primary node (ID: 2) acquire the virtual ip 192.168.7.241/24 success
NOTICE: promoting standby to primary
DETAIL: promoting server "node248" (ID: 2) using sys_promote()
NOTICE: waiting up to 60 seconds (parameter "promote_check_timeout") for promotion to complete
NOTICE: STANDBY PROMOTE successful
DETAIL: server "node248" (ID: 2) was successfully promoted to primary
NOTICE: issuing CHECKPOINT
INFO: local node 1 can attach to rejoin target node 2
DETAIL: local node's recovery point: 0/8000028; rejoin target node's fork point: 0/80000A0
NOTICE: setting node 1's upstream to node 2
WARNING: unable to ping "host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3"
DETAIL: PQping() returned "PQPING_NO_RESPONSE"
NOTICE: begin to start server at 2021-03-01 17:26:43.843581
NOTICE: starting server using "/home/kingbase/cluster/R6C5/R6C5R/kingbase/bin/sys_ctl -w -t 90 -D '/home/kingbase/cluster/R6C5/R6C5R/kingbase/data' -l /home/kingbase/cluster/R6C5/R6C5R/kingbase/bin/logfile start"
NOTICE: start server finish at 2021-03-01 17:26:44.055041
NOTICE: replication slot "repmgr_slot_2" deleted on node 1
NOTICE: NODE REJOIN successful
DETAIL: node 1 is now attached to node 2
NOTICE: switchover was successful
DETAIL: node "node248" is now primary and node "node243" is attached as standby
INFO: unpausing repmgrd on node "node243" (ID 1)
INFO: unpause node "node243" (ID 1) successfully
INFO: unpausing repmgrd on node "node248" (ID 2)
INFO: unpause node "node248" (ID 2) successfully
NOTICE: STANDBY SWITCHOVER has completed successfully
# 切换后集群状态:
[kingbase@node1 bin]$ ./repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
1 | node243 | standby | running | node248 | default | 100 | 1 | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node248 | primary | * running | | default | 100 | 2 | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
INFO: 1 replication slots required, 32 available
# job正常被执行:
prod=# select * from d_test;
tid | insdate
----------------+---------------------
20210301170529 | 2021-03-01 17:05:29
20210301171623 | 2021-03-01 17:16:23
20210301172126 | 2021-03-01 17:21:26
20210301172216 | 2021-03-01 17:22:16
20210301172316 | 2021-03-01 17:23:16
20210301172416 | 2021-03-01 17:24:16
20210301172516 | 2021-03-01 17:25:16
20210301172616 | 2021-03-01 17:26:16
20210301172908 | 2021-03-01 17:29:08
20210301172918 | 2021-03-01 17:29:18
2、failover 切换测试
# 执行failover切换
# 停止主库数据库服务
[kingbase@node1 bin]$ ./sys_ctl stop -D ../data
waiting for server to shut down........ done
server stopped
# failover切换完成:
[kingbase@node1 bin]$ ./repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+------------------
1 | node243 | primary | * running | | default | 100 | 3 | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node248 | standby | running | node243 | default | 100 | 2 | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
#查看job执行:
prod=# select * from d_test;
tid | insdate
----------------+---------------------
20210301170529 | 2021-03-01 17:05:29
20210301171623 | 2021-03-01 17:16:23
20210301172126 | 2021-03-01 17:21:26
20210301172216 | 2021-03-01 17:22:16
20210301172316 | 2021-03-01 17:23:16
20210301172416 | 2021-03-01 17:24:16
20210301172516 | 2021-03-01 17:25:16
20210301172616 | 2021-03-01 17:26:16
20210301172908 | 2021-03-01 17:29:08
20210301172918 | 2021-03-01 17:29:18
20210301173018 | 2021-03-01 17:30:18
20210301173118 | 2021-03-01 17:31:18
20210301173218 | 2021-03-01 17:32:18
20210301173318 | 2021-03-01 17:33:18
20210301173418 | 2021-03-01 17:34:18
20210301173518 | 2021-03-01 17:35:18
20210301173820 | 2021-03-01 17:38:20
20210301173920 | 2021-03-01 17:39:20
20210301174017 | 2021-03-01 17:40:17
20210301174117 | 2021-03-01 17:41:17
(20 rows)
删除job:
prod=# call dbms_job.remove(1);
CALL
prod=# select * from kdb_schedule.kdb_schedule_job;
sjid | sjscid | sjjobid | sjstatus | sjlasttime | sjnexttime
------+--------+---------+----------+------------+------------
(0 rows)
三、总结
通过以上案例说明,在集群环境下job的管理和单实例环境下配置基本一致,集群主备切换后,主库上的job任务亦可以正常被执行。
KingbaseES R6 集群测试job管理测试的更多相关文章
- KingbaseES R6 集群主库网卡down测试案例
数据库版本: test=# select version(); version ------------------------------------------------------------ ...
- KingbaseES R6 集群repmgr.conf参数'recovery'测试案例(一)
KingbaseES R6集群repmgr.conf参数'recovery'测试案例(一) 案例说明: 在KingbaseES R6集群中,主库节点出现宕机(如重启或关机),会产生主备切换,但是当主库 ...
- KingbaseES R6 集群 recovery 参数对切换的影响
案例说明:在KingbaseES R6集群中,主库节点出现宕机(如重启或关机),会产生主备切换,但是当主库节点系统恢复正常后,如何对原主库节点进行处理,保证集群数据的一致性和安全,可以通过对repmg ...
- KingbaseES R6 集群修改物理IP和VIP案例
在用户的实际环境里,可能有时需要修改主机的IP,这就涉及到集群的配置修改.以下以例子的方式,介绍下KingbaseES R6集群如何修改IP. 一.案例测试环境 操作系统: [KINGBASE@nod ...
- KingbaseES R6 集群修改data目录
案例说明: 本案例是在部署完成KingbaseES R6集群后,由于业务的需求,集群需要修改data(数据存储)目录的测试.本案例分两种修改方式,第一种是离线修改data目录,即关闭整个集群后,修改数 ...
- KingbaseES R6 集群sys_monitor.sh change_password一键修改集群用户密码
案例说明: kingbaseES R6集群用户密码修改,需要修改两处: 1)修改数据库用户密码(alter user): 2)修改.encpwd文件中用户密码: 可以通过sys_monitor.sh ...
- KingbaseES R6 集群创建流复制只读副本库案例
一.环境概述 [kingbase@node2 bin]$ ./ksql -U system test ksql (V8.0) Type "help" for help. test= ...
- KingbaseES R6 集群通过备库clone在线添加新节点
案例说明: KingbaseES R6集群可以通过图形化方式在线添加新节点,但是在添加新节点clone环节时,是从主库copy数据到新的节点,这样在生产环境,如果数据量大,将会对主库的网络I/O造成压 ...
- KingbaseES R6 集群启动‘incorrect command permissions for the virtual ip’故障案例
案例说明: KingbaseES R6集群启动时,出现"incorrect command permissions for the virtual ip"故障,本案例介绍了如何分析 ...
- kingbaseES R3 集群修改data路径测试案例
案例说明: 默认KingbaseES R3集群部署后,数据存储目录(data)在/home/kingbase下,部署时不能更改:本案例是在部署完成后,迁移data目录到其他指定的存储位置. 数据库版本 ...
随机推荐
- 关于android里activity之间利用button组件使用intent跳转页面
在需要跳转的activity 中 添加 Button button = findViewById(R.id.login);button.setOnClickListener(new View.OnCl ...
- RPA应用场景-日终清算操作
场景概述 日终清算操作 所涉系统名称 登记过户管理系统(TA),投资交易系统(032) 人工操作(时间/次) 60-80分钟 所涉人工数量 2 操作频率 每日 场景流程 这两个流程一般在晚上8-9点开 ...
- python写个前端,这不是轻轻松松~
前端除了用js++css+html,还有没有其它办法?其实python也可以 1. 安装与基本流程 Python学习交流Q群:660193417### 安装 PyWebIO 和其他的第三方库一样使用p ...
- 常见的git命令和git->github错误
相关命令 git remote git remote add origin xxx (xxx为仓库链接) 给这个链接取一个名字,为origin git pull git pull <远程主机名& ...
- java中的变量及命名
变量 变量顾名思义就是可以变化的量 因为java是强类型语言,所以每个变量都必须声明其类型 java变量是最基本的存储单元,要素包括变量名称,变量类型和作用域. 目录 变量 1.常用的变量创建 2.变 ...
- ArrayList集合概述和基本使用和ArrayList集合的常用方法和遍历
什么是ArrayList类 java.util.ArrayList 是大小可变的数组的实现,存储在内的数据称为元素.此类提供一些方法来操作内部存储 的元素. ArrayList 中可不断添加元素,其大 ...
- java 九九乘法表(for循环)
package study5ran2yl.study; public class ForDemo01 { public static void main(String[] args) { int h; ...
- Qt+ECharts开发笔记(三):ECharts的柱状图介绍、基础使用和Qt封装Demo
前言 上一篇成功是EChart随着Qt窗口变化而变化,本篇将开始正式介绍柱状图介绍.基础使用,并将其封装一层Qt. 本篇的demo实现了隐藏js代码的方式,实现了一个条形图的基本交互方式,即Qt ...
- day08 集合API | 遍历_ | 泛型 |增强For循环
集合(续) 集合间的操作 集合提供了如取并集,删交集,判断包含子集等操作 package collection; import java.util.ArrayList; import java.uti ...
- day03_3_流程控制练习题
# 流程控制练习题 # 一.编程题 1.实现一个课程名称和课程代号的转换器:输入下表中的课程代号,输出课程的名称.用户可以循环进行输入,如果输入0就退出系统.(**使用****switch +whil ...