• 热门标签

当前位置: 主页 > 航空资料 > 国外资料 >

时间:2010-08-19 10:44来源:蓝天飞行翻译 作者:admin
曝光台 注意防骗 网曝天猫店富美金盛家居专营店坑蒙拐骗欺诈消费者

Configure Oracle Net Service for External Procedures
An external procedure is a procedure called from another program, but written in a
different language. In this example it is a PL/SQL program calling one or more C
programs that are required for complete client notification. In order to properly
Fast-Start Failover – Oracle Data Guard 10g Release 2 Page 19
call external programs via a trigger, external procedures must be configured within
the Oracle Net components in addition to database libraries and wrapper scripts.
1. On all primary hosts and standby hosts setup network files to make use of
external procedures. An example of the changes needed to be made on each host
are:
listener.ora:
LISTENER =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
halinux03)(PORT = 1521))
(ADDRESS= (PROTOCOL= IPC)(KEY=external)))
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/10.2.0)
(global_dbname=STELLA_DGMGRL)
(SID_NAME = STELLA1))
(SID_DESC =
(SID_NAME = external)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0)
(PROGRAM = /u01/app/oracle/product/10.2.0
/bin/extproc)))
tnsnames.ora:
extproc_connection_data =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = external))
(CONNECT_DATA = (SID = external)(SERVER=
DEDICATED)))
For further information reference the Oracle® Database Net Services
Administrator's Guide Chapter 13 [6].
2. In order to facilitate calling external programs from a database trigger create a
file called shell.c with the following contents:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void sh(char *);
void sh( char *cmd )
{
Fast-Start Failover – Oracle Data Guard 10g Release 2 Page 20
int num;
num = system(cmd);
}
3. Compile the above program with the following command:
$ make -f demo_rdbms.mk extproc_nocallback \
SHARED_LIBNAME=shell.so OBJS=shell.o
4. Move the resulting .so file to $ORACLE_HOME/bin on both the primary and
standby hosts. Note that so file must be in the same location all primary hosts as
well as the standby host.
5. Create a library on the primary database.
SQL> create library shell_lib is
'/u01/app/oracle/product/10.2.0/bin/shell.so';
6. Create a wrapper pl/sql procedure on the primary database:
SQL> create or replace procedure shell(cmd IN char)
as external
name "sh"
library shell_lib
language C
parameters (cmd string);
/
Create necessary support files for LDAP modification
In this example clients connect to the primary database using a service that is only
available on the primary database and which is resolved via LDAP directory
naming. When a failover occurs and the standby becomes the new primary then
the primary specific service in the LDAP directory must be altered to point the
new primary host. This can be accomplished via the ldapmodify command which
will be included in the DB_ROLE_CHANGE trigger in a later step.
The ldif file should reside in the same directory structure on all hosts. In addition,
the value for the host= parameter must the hostname of the current host or if
RAC it must be the value of each primary node VIP addresses. For example:
dn: cn=sales,cn=OracleContext,dc=netfl-labsun1,dc=com
changetype: modify
replace: orclNetDescString
orclNetDescString:
Fast-Start Failover – Oracle Data Guard 10g Release 2 Page 21
(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=
halinux03vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=ha
linux04vip)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=sale
s)))
The ldapmodify that will be called from the DB_ROLE_CHANGE trigger will be:
ldapmodify -D "cn=orcladmin" -w welcome1 -h netfllabsun1
-p 3061 -v –f /u01/app/oracle/product/10.2.0/
change.ldif
Define a middle tier / application restart script
As noted earlier, in a complete primary site outage it is likely FAN ONS clients (as
well as non FAN ONS JDBC clients), such as middle tier applications, will not be
notified of the primary site failure. In order to break the FAN ONS clients out of
the TCP timeout a script is defined which will remotely login to the middle tier
hosts and restart the middle tier processes or client application. In this example
the script that is created is called “restart_app”. Such a script will vary depending
upon environment and requirements. A representative example of the logic
implemented by such a script is as follows:
----------------------------------------------------------------------
 
中国航空网 www.aero.cn
航空翻译 www.aviation.cn
本文链接地址:航空资料22(61)