Oracle Scheduler是功能强大的定时调度程序,不但能调度job在本地数据库上运行,还能在远程主机上发起这些job,远程主机上不一定要安装Oracle数据库,但必须安装有Scheduler Agent,下面是完整的安装过程
安装过程中涉及到以下两部分操作:
1、对于存放remote job信息、负责发起调度的主数据库进行配置
2、在运行remote job的远程主机上安装Scheduler Agent,如果这台远程主机上不安装Oracle Database,那么仅可以运行remote external job,如果安装了Oracle Database那么还可以运行remote database job
完整的安装过程如下,在11.2.0.3版本下测试通过
============1、对存放remote job信息的主数据库进行配置============
///////////////////////////////////
/// 步骤1:安装XDB组件
///////////////////////////////////
###安装前检测库里是否已经安装过XDB,如果安装过XDB,需要确认XDB的组件是否均处于有效状态;
---以下方法检查XDB组件,如果是VALID那么XDB组件处于正常状态
col comp_name format a30
set linesize 130
select comp_name,status from dba_registry where comp_name='Oracle XML Database';
COMP_NAME STATUS
------------------------------ ----------------------
Oracle XML Database VALID
---如果状态不是VALID,那么需要运行以下脚本,根据脚本的输出来决定是否要重新安装
set serveroutput on
DECLARE
v_xdb_installation_trigger number;
v_dropped_xdb_instll_trigger number;
v_dropped_xdb_instll_tab number;
BEGIN
select count(*) into v_xdb_installation_trigger
from dba_triggers
where trigger_name = 'XDB_INSTALLATION_TRIGGER' and owner = 'SYS';
select count(*) into v_dropped_xdb_instll_trigger
from dba_triggers
where trigger_name = 'DROPPED_XDB_TRIGGER' and owner = 'SYS';
select count(*) into V_dropped_xdb_instll_tab
from dba_tables
where table_name = 'DROPPED_XDB_INSTLL_TAB' and owner = 'SYS';
IF v_xdb_installation_trigger > 0 OR v_dropped_xdb_instll_trigger > 0 OR v_dropped_xdb_instll_tab > 0 then
IF v_xdb_installation_trigger > 0 THEN
dbms_output.put_line('Please proceed to run the command SQL> drop trigger sys.xdb_installation_trigger');
-- drop trigger sys.xdb_installation_trigger;
END IF;
IF v_dropped_xdb_instll_trigger > 0 THEN
dbms_output.put_line('Please proceed to run the command SQL> drop trigger sys.dropped_xdb_instll_trigger');
-- drop trigger sys.dropped_xdb_instll_trigger;
END IF;
IF v_dropped_xdb_instll_tab > 0 THEN
dbms_output.put_line('Please proceed to run the command SQL> drop table sys.dropped_xdb_instll_tab');
-- drop table sys.dropped_xdb_instll_tab;
END IF;
ELSE
dbms_output.put_line('Please proceed to run the XDB install or upgrade');
END IF;
END;
/
###安装XDB的方法归纳如下
---创建XDB专用的表空间,如果要使用SecureFile Lobs必须使用segment space management auto
create tablespace xdbts datafile '/oradata06/testaaaaa/xdbts1.dbf' size 500m extent management local segment space management auto;
---运行@?/rdbms/admin/catqm.sql
参数值含义如下:
:XDB user password
:XDB user default tablespace
:XDB user temporary tablespace
:YES or NO(YES->使用SecureFile lobs;NO->使用BasicFile Lobs)
---运行catqm.sql脚本
spool xdb_install.log
set echo on;
@?/rdbms/admin/catqm.sql asdf3_14 xdbts temp YES
@?/rdbms/admin/utlrp.sql
set echo off;
spool off;
---安装完成后再确认一下XDB组件的状态
col comp_name format a30
set linesize 130
select comp_name,status from dba_registry where comp_name='Oracle XML Database';
COMP_NAME STATUS
------------------------------ ----------------------
Oracle XML Database VALID
///////////////////////////////////
/// 步骤2:安装Oracle Text组
///////////////////////////////////
Oracle Text组件通常在使用dbca建库的时候会自动安装上,但如果是Manual方式建的库,那么需要手动安装。
---使用如下方法确定Oracle Text是否已经安装,如果安装了Oracle Text,那么
col comp_name format a20
set linesize
select comp_name, status, substr(version,1,10) as version from dba_registry where comp_id = 'CONTEXT';
COMP_NAME STATUS VERSION
-------------------- ---------------------- --------------------
Oracle Text VALID 11.2.0.3.0
###如果没有安装Oracle Text,按照以下步骤进行安装
---在database侧安装Oracle Text组件,配置默认语言
sqlplus '/as sysdba'
SQL> @?/ctx/admin/catctx.sql asdf3_14 SYSAUX TEMP NOLOCK ---四个参数依次表示:ctxsys用户的口令、ctxsys用户的默认表空间,ctxsys用户的临时表空间,ctxsys创建完后是否锁定(LOCK:锁定; NOLOCK:不锁定)
---以ctxsys用户登陆配置默认语言为英语
sqlplus ctxsys/asdf3_14
SQL> @?/ctx/admin/defaults/dr0defin.sql "AMERICAN";
---最后为安全起见锁定ctxsys
sqlplus '/as sysdba'
alter user ctxsys account lock password expire;
---在database的OS环境变量中加入$ORACLE_HOME/ctx/lib路径
export LD_LIBRARY_PATH=$ORACLE_HOME/ctx/lib:$LD_LIBRARY_PATH
---验证oracle text组件是否成功安装
SQL> select comp_name, status, substr(version,1,10) as version from dba_registry where comp_id = 'CONTEXT';
COMP_NAME STATUS VERSION
------------------- -------- ----------
Oracle Text VALID 11.2.0.3.0
SQL> select * from ctxsys.ctx_version;
VER_DICT VER_CODE
----------- -----------
11.2.0.3.0 11.2.0.3.0
SQL> select object_name, object_type, status from dba_objects where owner='CTXSYS' and status != 'VALID' order by object_name;
no rows selected
///////////////////////////////////
/// 步骤3:配置remote jobs运行所需的数据库环境
///////////////////////////////////
###配置一个HTTP服务端口,这个端口用于job主数据库服务器和安装有schedule agent的远程服务器间进行通信,定义的端口不要和其它应用重复即可
sqlplus / as sysdba
exec dbms_xdb.sethttpport(30405);
commit;
###db和OS层面检查配置是否生效
select dbms_xdb.GETHTTPPORT() from dual;
DBMS_XDB.GETHTTPPORT()
----------------------
30405
!netstat -an |grep 30405
tcp 0 0 *.30405 *.* LISTEN
###运行prvtrsch.plb脚本,会新建一个名为REMOTE_SCHEDULER_AGENT用户
@?/rdbms/admin/prvtrsch.plb
SQL> select username,account_status from dba_users where username='REMOTE_SCHEDULER_AGENT';
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
REMOTE_SCHEDULER_AGENT EXPIRED & LOCKED
###设置scheduler agent连接到主数据库的口令
exec dbms_scheduler.set_agent_registration_pass(registration_password=>'asdf3_14');
###设置shared_servers为非零,这一步很重要,否则会出现scheduler agent无法注册成功的问题
alter system set shared_servers=1 scope=both;
###job主服务器上的lnsrctl status输出里能看出PORT=30405的正在被侦听
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
Start Date 06-FEB-2015 07:49:08
Uptime 9 days 3 hr. 8 min. 14 sec
Trace Level off
Security ON: Local OS Authentication
SNMP ON
Listener Parameter File /oracle/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /oracle/app/oracle/diag/tnslsnr/jq570322b/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.10.141.209)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=jq570322b)(PORT=30405))(Presentation=HTTP)(Session=RAW))
###/etc/hosts里加入即将安装scheduler agent的remote主机IP地址和主机名映射,这一步能避免后面注册时产生ORA-29257
10.10.141.206 jq570321a
至此job主数据库服务器侧的配置工作完毕
更多详情见请继续阅读下一页的精彩内容: