Monday, August 12, 2013

ORA-4031: unable to allocate 32 bytes of shared memory | Sun Solaris


Environment Details:
OS: Sun Solaris 5.10
Database Version: 11gR2
User: oracle

Issue: When we try to create a database using dbca in Sun Solaris Server we get an ORA Error 
ORA-00604: Error occurred at recursive SQL level 1 
ORA-4031: unable to allocate 32 bytes of shared memory("shared pool","select obj#,type#,ctime,mtim...,","SQLA","tmp")




This issue is related to the amount of privileged memory allocated for use to the Oracle user, if the memory required exceeds the privileged limit, oracle throws error

Solution: To resolve this use the following

Login as oracle user on the server and issue the command (id -p)

bash-3.00$ id -p
uid=555(oracle) gid=1000(oinstall) projid=100(user.oracle)

Login as root/sudo to the server and check the memory allocated to the user.oracle project

# prctl -n project.max-shm-memory -i project user.oracle
project: 100: user.oracle
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
project.max-shm-memory
        privileged       2.0GB      -   deny                                 -
        system          16.0EB    max   deny                                 -

Increase the memory of by issuing the below command

# prctl -n project.max-shm-memory -r -v 4G -i project user.oracle

Verify the memory changes

# prctl -n project.max-shm-memory -i project user.oracle
project: 100: user.oracle
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
project.max-shm-memory
        privileged       4.0GB      -   deny                                 -
        system          16.0EB    max   deny                                 -

Now try to create the database it will go through.

Wednesday, August 7, 2013

Oracle Quiesce Database


If we want only DBA transactions to be allowed in the database for certain important activities, we QUIESCE a database by issuing the command ALETR SYSTEM QUIESCE DATABASE. The advantage of this command is, it will not terminate the sessions of non DBA users and if there are any active transactions for any user those will continue to run until they are completed but once those transaction becomes inactive, it will appear that the sessions are hung and will not allow any transactions at that point of time, only the DBAs can run the transactions. Once the session is UNQUIESCE by issuing the command ALTER SYSTEM UNQUIESCE, the normal users will be able to do the transactions.

In the example below, we have logged into a server and verified that we are able to query from a user called test before quiescing , and when we quiesce database, the session seems to be hung and as soon as we unquiesce the database, the command gets executed successfully.



Querying from test(non DBA user) users schema, since we have not quiesce the database the query ran successfully.

Now we have quiesced the database and tried to run a query from test users, here the sessions seems to be hung for the test users query.

Now we unquiesced the database and the query completed successfully.
Note: Utmost care should be taken while using quiesce/unquiesce since it will prevent any other users transactions.


Wednesday, July 31, 2013

ORA-12547: TNS:lost contact error

Issue: When trying to connect to the database we are getting the ORA-12547: TNS:lost contact error.

[oraem@linux01 ~]$ export ORACLE_SID=orcl
[oraem@linux01 ~]$ export ORACLE_HOME=/u01/app/oracle/product/112030/dbhome_1
[oraem@linux01 ~]$ export PATH=$ORACLE_HOME/bin:$PATH
[oraem@linux01 ~]$ sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 31 04:43:52 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter password: 
ERROR:
ORA-12547: TNS:lost contact

Tried a lot of scenarios by changing the listener.ora, sqlnet.ora & tnsnames.ora files but still the issue was not resolved.
Finally checked the ORACLE_HOME/bin, there was file permission issues for oracle binary file

-rwxr-x--x 1 oraem   dba 232399123 Jul 29 09:20 oracle

As per Oracle the file permission should be 6751 for oracle binary file, so changed the permission of that file

[oraem@linux01 bin]$ chmod 6751 oracle
[oraem@linux01 bin]$ ls -lrt oracle
-rwsr-s--x 1 oraem dba 232399123 Jul 29 09:20 oracle

Tried to login to the database and it was success.

[oraem@linux01 bin]$ sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 31 06:39:02 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter password: 

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name, open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
ORCL      READ WRITE

Monday, July 29, 2013

ORA-01506: missing or illegal database name

Sometimes when we try to start a database in windows or other OS platform, we get the error ORA-01506: missing or illegal database name

Environment Details:
OS: Windows Server 2008
Database Version: 11gR2
User: oracle
Oracle Home: E:\oracle\product\11.2.0\dbhome_1
Oracle SID: orcldb

Debugging: 
TNS Ping is working fine
E:\>tnsping orcldb

TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 29-JUL-2013 07:56:32

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

Used parameter files:
E:\oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=winhost1.com)(PORT=1521)) (CONNECT_DATA=(SID=orcldb)))
OK (60 msec)

Listener is also up and running
E:\>lsnrctl status

LSNRCTL for 32-bit Windows: Version 11.2.0.1.0 - Production on 29-JUL-2013 12:37:21

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=winhost1.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version 11.2.0.1.0 - Production
Start Date                29-JUL-2013 07:42:58
Uptime                    0 days 4 hr. 54 min. 23 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   E:\oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
Listener Log File         E:\oracle\diag\tnslsnr\winhost1\listener\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=winhost1.com)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcldb.us.oracle.com" has 1 instance(s).
  Instance "orcldb", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

but if we login & start the database we get error 

E:\>set ORACLE_HOME=E:\oracle\product\11.2.0\dbhome_1
E:\>set PATH=%ORACLE_HOME%\bin;%PATH%
E:\>set ORACLE_SID=orcldb
E:\>sqlplus sys as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Jul 29 12:50:28 2013
Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Enter password:
Connected to an idle instance.

SQL> startup
ORA-01506: missing or illegal database name
SQL> exit
Disconnected


Solution:
Verify the content of parameter file used to start the database especially the db_name parameter. Provide correct name of the database and then start the database
Location of parameter file %ORACLE_HOME%\database
parameter file name: initorcldb.ora

E:\>sqlplus sys as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Jul 29 12:55:28 2013
Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Enter password:
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  518922240 bytes
Fixed Size                  1375676 bytes
Variable Size             159384132 bytes
Database Buffers          352321536 bytes
Redo Buffers                5840896 bytes
Database mounted.
Database opened.

SQL> select name, open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------

ORCLDB    READ WRITE


Wednesday, July 24, 2013

Oracle 11g Installation Error


Issue: 
1. Even if all the oracle software installation pre requisites are met and the DISPLAY variable is set correctly, when running the runInstaller it is throwing error. 

2. When Starting the Listener there is ERROR Linux Error: 29: Illegal seek

Environment Details:
OS: Linux Server 5.8 64bit
Database Version: 11gR2
User: oracle
Software Location: /u01/stage/database

[oracle@linux01 ~]$ cd /u01/stage/database/
[oracle@linux01 database]$ ./runInstaller
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB.   Actual 132493 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 22159 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 65536    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-07-13_09-24-35AM. Please wait ...[oracle@linux01 database]$ #
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGILL (0x4) at pc=0x00000031d8614be0, pid=12186, tid=140422856902346
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.5.0_30-b03 mixed mode)
# Problematic frame:
# C  [ld-linux-x86-64.so.2+0x14be0]
#
# An error report file with more information is saved as hs_err_pid12186.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#


[oracle@linux01 ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 13-JUL-2013 10:34:58

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr: please wait...

TNS-12537: TNS:connection closed
 TNS-12560: TNS:protocol adapter error
  TNS-00507: Connection closed

   Linux Error: 29: Illegal seek

Resolution: set the environment variable LD_BIND_NOW to 1 and then invoke the installer, it will go through. Setting the LD_BIND_NOW force the loader to do the Procedure Linkage Table fixups 

[oracle@linux01 database]$ export LD_BIND_NOW=1
[oracle@linux01 database]$ ./runInstaller