참고자료
http://www.dator.co.kr/hjklab/textyle/241888
http://www.idevelopment.info/data/Oracle/DBA_tips/PL_SQL/PLSQL_17.shtml
http://www.dbforums.com/oracle/997254-ora-28575-unable-open-rpc-connection-external-procedure-agent.html
public static String getStr( ){
return "good";
}
}
{CODE}
{CODE:SQL}
ora10g@orastage admin$ javac TestExE.java
ora10g@orastage admin$
ora10g@orastage admin$ ls -l
total 44
-rwxrwxr-x 1 ora10g oinstall 271 Mar 23 18:15 TestExE.classrw-rr- 1 ora10g oinstall 84 Mar 23 18:13 TestExE.javarw-r
loadjava -user ua/ko0919@luxtv TestExE.javac -- 컴파일된 소스만 올림
loadjava -user ua/ko0919@luxtv -resolve -v TestExE.java --소스 및 컴파일 소스까지 올림
ora10g@orastage admin$ loadjava -user ua/ko0919@luxtv -resolve -v TestExE.java
arguments: '-user' 'ua/ko0919@luxtv' '-resolve' '-v' 'TestExE.java'
creating : source TestExE
loading : source TestExE
resolving: source TestExE
Classes Loaded: 0
Resources Loaded: 0
Sources Loaded: 1
Published Interfaces: 0
Classes generated: 0
Classes skipped: 0
Synonyms Created: 0
Errors: 0
ora10g@orastage admin$
ora10g@orastage admin$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on 금 3월 23 18:17:31 2012
Copyright © 1982, 2005, Oracle. All rights reserved.
SQL>
SQL>
SQL> conn ua/ko0919
연결되었습니다.
SQL>
SQL> CREATE OR REPLACE FUNCTION getString
2 RETURN VARCHAR2 IS
3 LANGUAGE JAVA
4 NAME 'TestExE.getStr() return java.lang.String';
5 /
함수가 생성되었습니다.
SQL> SELECT getString FROM DUAL
2 ;
GETSTRING
SQL> COLUMN OBJECT_NAME FORMAT A10;
SQL> COLUMN OBJECT_TYPE FORMAT A15;
SQL> COLUMN STATUS FORMAT A10;
SQL> SELECT OBJECT_NAME, OBJECT_TYPE, STATUS FROM user_objects
2 WHERE object_type like 'JAVA%';
OBJECT_NAM OBJECT_TYPE STATUS
--그냥 바로 만드는게 편하다.
DROP JAVA SOURCE UA."TestExE";
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED UA."TestExE"
as
public class TestExE {
public static String getStr( ){
return "good";
}
}
/
CREATE OR REPLACE FUNCTION getString
RETURN VARCHAR2 IS
LANGUAGE JAVA
NAME 'TestExE.getStr() return java.lang.String';
/
{CODE}
{CODE:SQL}
SID_LIST_LISTENER_LUXTV =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /usr/local/ora10g/product/10.2.0)
(SID_NAME = LUXTV)
)
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/local/ora10g/product/10.2.0)
(PROGRAM = extproc)
(ENVS="EXTPROC_DLLS=ANY")
)
)
LISTENER_LUXTV =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ??????????)(PORT = 1520)(QUEUESIZE = 32))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0 ))
)
)
INBOUND_CONNECT_TIMEOUT_LISTENER_LUXTV = 0
ADR_BASE_LISTENER_LUXTV = /uar/local/ora10g/product/10.2.0
DIAG_ADR_ENABLED_LISTENER_LUXTV = OFF
{CODE}
{CODE:SQL}
LUXTV =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ??????????)(PORT = 1520))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = luxtv)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
{CODE}
{CODE:sql}
/*
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void mailx(char *to, char *subject, char *message) {
int num;
char command[50000];
strcpy(command, "echo \"");
strcat(command, message);
strcat(command, "\" | mailx -s \"");
strcat(command, subject);
strcat(command, "\" ");
strcat(command, to);
num = system(command);
}
void sh(char *command) {
int num;
num = system(command);
}
{CODE}
{CODE:SQL}
-bash-3.00$ gcc -m64 -fPIC -c shell.c
-bash-3.00$ gcc -m64 -shared -static-libgcc -o shell.so shell.o
-bash-3.00$ chmod 775 shell.so
or
-bash-3.00$ gcc -G -c shell.c
-bash-3.00$ ld -r -o shell.so shell.o
-bash-3.00$ chmod 775 shell.so
{CODE}
{CODE:SQL}
ora10g@orastage admin$ ls -l
total 48
-rwxrwxr-x 1 ora10g oinstall 271 Mar 23 18:15 TestExE.classrw-rr- 1 ora10g oinstall 84 Mar 23 18:13 TestExE.javarw-r
{CODE}
{CODE:SQL}
-bash-3.00$ make -f demo_rdbms.mk extproc_nocallback SHARED_LIBNAME=shell.so OBJS=shell.o
{CODE}
{CODE:SQL}
ora10g@orastage admin$ make -f /usr/local/ora10g/product/10.2.0/rdbms/demo/demo_rdbms.mk extproc_no_context SHARED_LIBNAME=shell.so OBJS=shell.o
/usr/bin/gcc -shared -L/usr/local/ora10g/product/10.2.0/lib -o shell.so shell.o
ora10g@orastage admin$ ls -l
total 60
-rwxrwxr-x 1 ora10g oinstall 271 Mar 23 18:15 TestExE.classrw-rr- 1 ora10g oinstall 84 Mar 23 18:13 TestExE.javarw-r
{CODE}
{CODE:SQL}
SQL> CREATE LIBRARY shell_lib is '/usr/local/ora10g/product/10.2.0/network/admin/shell.so';
2 /
라이브러리가 생성되었습니다.
{CODE}
{CODE:SQL}
SQL> CREATE OR REPLACE PROCEDURE shell(command IN char)
2 AS EXTERNAL
3 NAME "sh"
4 LIBRARY shell_lib
5 LANGUAGE C
6 PARAMETERS (command string);
7 /
프로시저가 생성되었습니다.
SQL> CREATE OR REPLACE PROCEDURE mailx(send_to IN char, subject IN char, message IN char)
2 AS EXTERNAL
3 NAME "mailx"
4 LIBRARY shell_lib
5 LANGUAGE C
6 PARAMETERS (send_to string, subject string, message string);
7 /
프로시저가 생성되었습니다.
{CODE}
{CODE:SQL}
SQL> SHOW PARAMETER USER
NAME TYPE VALUE
SQL> exec shell('ls /usr/local/ora10g/admin/LUXTV/udump > /usr/local/ora10g/product/10.2.0/network/admin/myoutput.txt');
BEGIN shell('ls /usr/local/ora10g/admin/LUXTV/udump > /usr/local/ora10g/product/10.2.0/network/admin/myoutput.txt'); END;
*
1행에 오류:
ORA-28575: 외부 프로시저 대리 프로세스로 연결하기 위한 RPC을 열 수 없습니다
ORA-06512: "UA.SHELL", 줄 1에서
ORA-06512: 줄 1에서
{CODE}
{CODE:SQL}
SID_LIST_LISTENER_LUXTV =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /usr/local/ora10g/product/10.2.0)
(SID_NAME = LUXTV)
)
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/local/ora10g/product/10.2.0)
(PROGRAM = extproc)
(ENVS="EXTPROC_DLLS=ANY")
)
)
LISTENER_LUXTV =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ??????????)(PORT = 1520)(QUEUESIZE = 32))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTERNAL )) <-- 설마했다. ㅋㅋ
)
)
INBOUND_CONNECT_TIMEOUT_LISTENER_LUXTV = 0
ADR_BASE_LISTENER_LUXTV = /uar/local/ora10g/product/10.2.0
DIAG_ADR_ENABLED_LISTENER_LUXTV = OFF
{CODE}
{CODE:SQL}
LUXTV =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ??????????)(PORT = 1520))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = luxtv)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTERNAL)) <-- 설마했다. ㅋㅋ
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
{CODE}
{CODE:SQL}
SQL> CREATE OR REPLACE PROCEDURE shell(command IN char)
2 AS EXTERNAL
3 NAME "sh"
4 LIBRARY shell_lib
5 LANGUAGE C
6 PARAMETERS (command string);
7 /
프로시저가 생성되었습니다.
-- ㅋㅋㅋ
SQL> exec shell('ls /usr/local/ora10g/admin/LUXTV/udump > /usr/local/ora10g/product/10.2.0/network/admin/myoutput.txt')
PL/SQL 처리가 정상적으로 완료되었습니다.
{CODE}
{CODE:SQL}
ora10g@orastage admin$ vi /usr/local/ora10g/product/10.2.0/network/admin/myoutput.txt
ccf.sql
luxtv_ora_1072.trc
luxtv_ora_1163.trc
luxtv_ora_1178.trc
luxtv_ora_1199.trc
luxtv_ora_1235.trc
luxtv_ora_1275.trc
luxtv_ora_1304.trc
luxtv_ora_13293.trc
luxtv_ora_13369.trc
luxtv_ora_13398.trc
luxtv_ora_13427.trc
luxtv_ora_13434.trc
luxtv_ora_13463.trc
luxtv_ora_19828.trc
luxtv_ora_23102.trc
luxtv_ora_23109.trc
luxtv_ora_23140.trc
luxtv_ora_31135.trc
luxtv_ora_31172.trc
oratest_ora_10049.trc
oratest_ora_10078.trc
oratest_ora_12919.trc
oratest_ora_12946.trc
oratest_ora_12975.trc
oratest_ora_22451.trc
oratest_ora_26701.trc
oratest_ora_26708.trc
oratest_ora_26741.trc
oratest_ora_26805.trc
oratest_ora_27582.trc
oratest_ora_27617.trc
oratest_ora_27623.trc
oratest_ora_27650.trc
oratest_ora_27674.trc
oratest_ora_27693.trc
oratest_ora_27722.trc
oratest_ora_29279.trc
oratest_ora_29784.trc
oratest_ora_29950.trc
oratest_ora_29979.trc
oratest_ora_29999.trc
oratest_ora_30030.trc
oratest_ora_339.trc
oratest_ora_386.trc
oratest_ora_387.trc
oratest_ora_842.trc
oratest_ora_9204.trc
oratest_ora_9247.trc
oratest_ora_9276.trc
oratest_ora_9592.trc
oratest_ora_9605.trc
oratest_ora_9634.trc
oratest_ora_9677.trc
oratest_ora_9706.trc
oratest_ora_9979.trc
~
~
<l/ora10g/product/10.2.0/network/admin/myoutput.txt" 56L, 1156C 1,1
{CODE}
{CODE:SQL}
SID : ORA02
oracle@orastage ~$ lsnrctl status listener_ora02
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-MAR-2012 14:56:48
Copyright © 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=??????????)(PORT=1521)(QUEUESIZE=32)))
STATUS of the LISTENER
LISTENER_ORA02 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ??????????)(PORT=1521)(QUEUESIZE = 32))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
SID_LIST_LISTENER_ORA02 = (SID_LIST =
ADR_BASE_LISTENER_ORA02 = /usr/local/oracle/product/11.2.0/db_1
DIAG_ADR_ENABLED_LISTENER_ORA02 = OFF
ora10g@orastage ~$ lsnrctl status listener_luxtv
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-3월 -2012 14:58:17
Copyright © 1991, 2005, Oracle. All rights reserved.
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=??????????)(PORT=1520)(QUEUESIZE=32)))에 연결되었습니다
리스너의 상태
SID_LIST_LISTENER_LUXTV =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /usr/local/ora10g/product/10.2.0)
(SID_NAME = LUXTV)
)
)
LISTENER_LUXTV =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ??????????)(PORT = 1520)(QUEUESIZE = 32))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1 ))
)
)
ADR_BASE_LISTENER_LUXTV = /uar/local/ora10g/product/10.2.0
DIAG_ADR_ENABLED_LISTENER_LUXTV = OFF
ora10g@orastage ~$ lsnrctl stop listener_luxtv
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-3월 -2012 15:00:49
Copyright © 1991, 2005, Oracle. All rights reserved.
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=??????????)(PORT=1520)(QUEUESIZE=32)))에 연결되었습니다
명령이 성공적으로 수행되었습니다
ora10g@orastage ~$
ora10g@orastage ~$ lsnrctl status listener_luxtv
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-3월 -2012 15:01:05
Copyright © 1991, 2005, Oracle. All rights reserved.
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=??????????)(PORT=1520)(QUEUESIZE=32)))에 연결되었습니다
TNS-12541: TNS:리스너가 없습니다.
TNS-12560: TNS:프로토콜 어댑터 오류
TNS-00511: 리스너가 없습니다.
Linux Error: 111: Connection refused
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))에 연결되었습니다
TNS-12541: TNS:리스너가 없습니다.
TNS-12560: TNS:프로토콜 어댑터 오류
TNS-00511: 리스너가 없습니다.
Linux Error: 2: No such file or directory
ora10g@orastage ~$
ora10g@orastage ~$ vi /usr/local/ora10g/product/10.2.0/network/admin/listener.ora
SID_LIST_LISTENER_LUXTV =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /usr/local/ora10g/product/10.2.0)
(SID_NAME = LUXTV)
)
)
LISTENER_LUXTV =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ??????????)(PORT = 1520)(QUEUESIZE = 32))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0 )) <-- 이부분 변경
)
)
ADR_BASE_LISTENER_LUXTV = /uar/local/ora10g/product/10.2.0
DIAG_ADR_ENABLED_LISTENER_LUXTV = OFF
ora10g@orastage ~$ lsnrctl status listener_luxtv
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-3월 -2012 15:02:47
Copyright © 1991, 2005, Oracle. All rights reserved.
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=??????????)(PORT=1520)(QUEUESIZE=32)))에 연결되었습니다
TNS-12541: TNS:리스너가 없습니다.
TNS-12560: TNS:프로토콜 어댑터 오류
TNS-00511: 리스너가 없습니다.
Linux Error: 111: Connection refused
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0)))에 연결되었습니다
리스너의 상태
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-3월 -2012 15:03:39
Copyright © 1991, 2005, Oracle. All rights reserved.
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=??????????)(PORT=1520)(QUEUESIZE=32)))에 연결되었습니다
TNS-12541: TNS:리스너가 없습니다.
TNS-12560: TNS:프로토콜 어댑터 오류
TNS-00511: 리스너가 없습니다.
Linux Error: 111: Connection refused
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0)))에 연결되었습니다
TNS-01190: 해당 사용자는 요청된 리스너 명령을 실행할 권한이 없습니다.
ora10g@orastage ~$
ora10g@orastage ~$ vi /usr/local/ora10g/product/10.2.0/network/admin/listener.ora
SID_LIST_LISTENER_LUXTV =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /usr/local/ora10g/product/10.2.0)
(SID_NAME = LUXTV)
)
)
LISTENER_LUXTV =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ??????????)(PORT = 1520)(QUEUESIZE = 32))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0 )) <-- 수정
)
)
ADR_BASE_LISTENER_LUXTV = /uar/local/ora10g/product/10.2.0
DIAG_ADR_ENABLED_LISTENER_LUXTV = OFF
ora10g@orastage ~$ lsnrctl status listener_luxtv
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-3월 -2012 15:06:03
Copyright © 1991, 2005, Oracle. All rights reserved.
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=??????????)(PORT=1520)(QUEUESIZE=32)))에 연결되었습니다
TNS-12541: TNS:리스너가 없습니다.
TNS-12560: TNS:프로토콜 어댑터 오류
TNS-00511: 리스너가 없습니다.
Linux Error: 111: Connection refused
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))에 연결되었습니다
TNS-12541: TNS:리스너가 없습니다.
TNS-12560: TNS:프로토콜 어댑터 오류
TNS-00511: 리스너가 없습니다.
Linux Error: 2: No such file or directory
ora10g@orastage ~$
ora10g@orastage ~$ lsnrctl start listener_luxtv
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-3월 -2012 15:06:23
Copyright © 1991, 2005, Oracle. All rights reserved.
시작 /usr/local/ora10g/product/10.2.0/bin/tnslsnr: 잠시만 기다리세요...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
시스템 매개변수 파일은 /usr/local/ora10g/product/10.2.0/network/admin/listener.ora 입니다
/usr/local/ora10g/product/10.2.0/network/log/listener_luxtv.log (으)로 로그 메시지를 기록했습니다
리스닝이: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=??????????)(PORT=1520)))
리스닝이: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=??????????)(PORT=1520)(QUEUESIZE=32)))에 연결되었습니다
리스너의 상태