在oracle 11g下安装配置scheduler agent
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 pwd> <XDB default tbs> <XDB temporary tbs> <YES or NO>
参数值含义如下:
<XDB pwd>:XDB user password
<XDB default tbs>:XDB user default tablespace
<XDB temporary tbs>:XDB user temporary tablespace
<XDB temporary tbs>: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主数据库服务器侧的配置工作完毕
============2、对即将运行remote jobs的远程主机安装scheduler agent并进行配置============
###scheduler agent安装介质可以从已经安装有oracle database的主机上提取,提取过程如下
cd $ORACLE_HOME\bin
extjobo -createagentzip /tmp/agent_install.zip
###将execution_agent.zip文件复制到准备安装scheduler agent的主机
scp /tmp/agent_install.zip [email protected]:/home/sagent/
###scheduler agent主机侧环境变量配置及目录创建
export ORACLE_HOME=/home/sagent
cd /home/sagent
mkdir scheduler
###scheduler agent主机解压
cd /home/sagent/scheduler/
unzip ../agent_install.zip
###进入scheduler agent所在目录修改schagent.conf文件里的端口号,这个是agent主机上的端口号,通过该端口和job主服务器进行通信
在$ORACLE_HOME/scheduler/execution_agent/schagent.conf文件里加入
PORT=30406
###以root用户执行root.sh
cd $ORACLE_HOME/scheduler/execution_agent/
./root.sh
###将scheduler agent注册到database
cd $ORACLE_HOME/scheduler/execution_agent/bin
./schagent -registerdatabase 10.10.141.209 30405
EXECUTION_AGENT_HOME is /oracle/app/oracle/product/11.2/scheduler/execution_agent
Agent Registration Password ? *********
Oracle Scheduler Agent Registration for 11.2 Agent
Agent Registration Successful!
注:scheduler agent也可以在安装oracle client的过程中选择"Custom"->"Oracle Scheduler Agent"来完成安装,截图如下
============3、在job主服务器上验证scheduler agent安装结果============
###通过dba_scheduler_external_dests视图查看已经注册上来的remote agent信息
col destination_name format a30
col hostname format a30
col ip_address format a20
col enabled format a10
col comments format a50
set linesize 180
select * from dba_scheduler_external_dests;
DESTINATION_NAME HOSTNAME PORT IP_ADDRESS ENABLED COMMENTS
------------------------------ ------------------------------ ---------- -------------------- ---------- --------------------------------------------------
JQ570321A jq570321a 30406 10.10.141.206 TRUE Registered on 15-FEB-15 12.02.50.245870 PM +08:00
###通过GET_AGENT_VERSION探测scheduler agent的版本
set serveroutput on
DECLARE
versionnum VARCHAR2(30);
BEGIN
versionnum := DBMS_SCHEDULER.GET_AGENT_VERSION(‘10.10.141.206‘);
DBMS_OUTPUT.PUT_LINE(versionnum);
END;
/
11.2.0.3.1
PL/SQL procedure successfully completed.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。