Wednesday, November 25, 2009

EMCA fails with ORA-06502 PL/SQL: numeric or value error: character string buffer too small


Problem Description
While configuring dbconsole using following command,
emca -config dbcontrol db -repos create


It shows following messages
.
.

Do you wish to continue? [yes(Y)/no(N)]: yes
Do you wish to continue? [yes(Y)/no(N)]: yes
Nov 25, 2009 9:21:10 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /opt/oracle/app/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/emca/EAIAPP/emca_2009-11-25_09-18-57-AM.log.
Nov 25, 2009 9:21:13 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
.
.
Do you wish to continue? [yes(Y)/no(N)]: yes
Do you wish to continue? [yes(Y)/no(N)]: yes
Nov 25, 2009 9:21:10 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /opt/oracle/app/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/emca/EAIAPP/emca_2009-11-25_09-18-57-AM.log.
Nov 25, 2009 9:21:13 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Do you wish to continue? [yes(Y)/no(N)]: yes
Nov 25, 2009 9:21:10 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /opt/oracle/app/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/emca/EAIAPP/emca_2009-11-25_09-18-57-AM.log.
Nov 25, 2009 9:21:13 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Nov 25, 2009 9:26:30 AM oracle.sysman.emcp.EMReposConfig invoke
SEVERE: Error creating the repository
Nov 25, 2009 9:26:30 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Refer to the log file at /opt/oracle/app/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/emca/EAIAPP/emca_repos_create_.log for more details.
Nov 25, 2009 9:26:30 AM oracle.sysman.emcp.EMConfig perform
SEVERE: Error creating the repository
Refer to the log file at /opt/oracle/app/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/emca/EAIAPP/emca_2009-11-25_09-18-57-AM.log for more details.
Could not complete the configuration. Refer to the log file at /opt/oracle/app/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/emca/EAIAPP/emca_2009-11-25_09-18-57-AM.log for more details.


And fails with above error message.

From the logfile it shows followings, /opt/oracle/app/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/emca/EAIAPP/emca_2009-11-25_09-18-57-AM.log  it shows followings.


CONFIG: Setting param: RMI_PORT_EAIAPP value: 5520
Nov 25, 2009 9:21:12 AM oracle.sysman.emcp.EMDBPreConfig getFreePorts
CONFIG: Ports assigned for SID: EAIAPP : {DBCONTROL_HTTP_PORT=1158, RMI_PORT=5520, JMS_PORT=5540, AGENT_PORT=3938}
Nov 25, 2009 9:21:12 AM oracle.sysman.emcp.util.GeneralUtil initSQLEngine
CONFIG: SQLEngine connecting with SID: EAIAPP, oracleHome: /opt/oracle/app/oracle/oracle/product/10.2.0/db_1, and user: SYS
Nov 25, 2009 9:21:13 AM oracle.sysman.emcp.util.GeneralUtil initSQLEngine
CONFIG: SQLEngine created successfully and connected
Nov 25, 2009 9:21:13 AM oracle.sysman.emcp.EMReposConfig createRepository
CONFIG: Spooling to /opt/oracle/app/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/emca/EAIAPP/emca_repos_create_2009-11-25_09-21-13-AM.log
Nov 25, 2009 9:21:13 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Nov 25, 2009 9:26:30 AM oracle.sysman.emcp.EMReposConfig createRepository
CONFIG: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 259
CONFIG: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 259

oracle.sysman.assistants.util.sqlEngine.SQLFatalErrorException: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 259

        at oracle.sysman.assistants.util.sqlEngine.SQLEngine.executeImpl(SQLEngine.java:1474)
        at oracle.sysman.assistants.util.sqlEngine.SQLEngine.executeScript(SQLEngine.java:848)
        at oracle.sysman.assistants.util.sqlEngine.SQLPlusEngine.executeScript(SQLPlusEngine.java:267)
        at oracle.sysman.assistants.util.sqlEngine.SQLPlusEngine.executeScript(SQLPlusEngine.java:308)
        at oracle.sysman.emcp.EMReposConfig.createRepository(EMReposConfig.java:422)
        at oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:192)
        at oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:134)
        at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:171)
        at oracle.sysman.emcp.EMConfigAssistant.invokeEMCA(EMConfigAssistant.java:486)
        at oracle.sysman.emcp.EMConfigAssistant.performConfiguration(EMConfigAssistant.java:1142)
        at oracle.sysman.emcp.EMConfigAssistant.statusMain(EMConfigAssistant.java:470)
        at oracle.sysman.emcp.EMConfigAssistant.main(EMConfigAssistant.java:419)
Nov 25, 2009 9:26:30 AM oracle.sysman.emcp.EMReposConfig invoke
SEVERE: Error creating the repository
Nov 25, 2009 9:26:30 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Refer to the log file at /opt/oracle/app/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/emca/EAIAPP/emca_repos_create_.log for more details.
Nov 25, 2009 9:26:30 AM oracle.sysman.emcp.EMConfig perform
SEVERE: Error creating the repository
Refer to the log file at /opt/oracle/app/oracle/oracle/product/10.2.0/db_1/cfgtoollogs/emca/EAIAPP/emca_2009-11-25_09-18-57-AM.log for more details.
Nov 25, 2009 9:26:30 AM oracle.sysman.emcp.EMConfig perform
CONFIG: Stack Trace:
oracle.sysman.emcp.exception.EMConfigException: Error creating the repository
        at oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:204)
        at oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:134)
        at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:171)
        at oracle.sysman.emcp.EMConfigAssistant.invokeEMCA(EMConfigAssistant.java:486)
        at oracle.sysman.emcp.EMConfigAssistant.performConfiguration(EMConfigAssistant.java:1142)
        at oracle.sysman.emcp.EMConfigAssistant.statusMain(EMConfigAssistant.java:470)
        at oracle.sysman.emcp.EMConfigAssistant.main(EMConfigAssistant.java:419)





Cause of the Problem
There is a bug during the create of the EM Repository. Somehow terrible oracle bug :).
When hostname exceeds 32 characters emca will fail with 
ORA-06502
 PL/SQL: numeric or value error: character string buffer too small

Now let's verify it. From OS, you can simply do this by issuing hostname.

EAIAPP:/home/oracle>hostname
db1-eai.test1.hrn.eai.clearditlab.com


Unfortunately our database name is more than 32 characters and hence bug fired. You can also check the database hostname and length using following query,

sqlplus / as sysdba
SQL> set line 200
SQL> select host_name,length(host_name),instance_name from v$instance where rownum=1;



By both ways we see that our hostname is more than 32 characters and our bug fired.


Solution of the Problem
In order to avoid the bug you either need to change the hostname of the operating system. In order to change hostname on linux environment you have to look at http://arjudba.blogspot.com/2008/08/how-to-change-hostname-in-linux.html

If you don't want to change hostname you can bypass this bug by  apply the following steps:



1) Drop the repository with emca
emca -deconfig dbcontrol db -repos drop

2) cd to $ORACLE_HOME/sysman/admin/emdrep/sql/core/latest/self_monitor/



cd $ORACLE_HOME/sysman/admin/emdrep/sql/core/latest/self_monitor/

3) Make a copy of self_monitor_post_creation.sql
cp self_monitor_post_creation.sql self_monitor_post_creation.sql.bak

4) Edit the script and change the l_host_name from varchar2(32) to higher varchar2 for example varchar2(128).

 l_host_name varchar2(128)
Note: The l_host_name variable is declared 2 times in the script.

5) Create repository with emca
emca -config dbcontrol db -repos create


And now you are done.


Related Documents
http://arjudba.blogspot.com/2008/04/troubleshooting-dbconsole-error-oc4j.html
http://arjudba.blogspot.com/2008/04/how-to-drop-create-and-recreate-db.html
http://arjudba.blogspot.com/2008/04/stack-of-problems-while-creating.html

No comments:

Post a Comment