Thursday, August 11, 2011

sqlplus, ORA-27121 and Linux Error 13

You have an Oracle database running and everything is fine; you can login at the server with sysdba with no problem at all:

oracle@myserver:~$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 9 13:21:46 2011

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

Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

You can also connect to the database using a listener, but problems arise when you try to connect with an unprivileged user:

myuser@myserver:~$ sqlplus myusr/myusr@XE

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 9 13:26:27 2011

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


Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL> exit
Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
myuser@myserver:~$ sqlplus myusr/myusr

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 9 13:19:12 2011

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

ERROR:
ORA-01034: ORACLE not available
ORA-27121: unable to determine size of shared memory segment
Linux Error: 13: Permission denied


Enter user-name:
myuser@myserver:~$ set|grep ORA
ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
ORACLE_SID=XE

What is happening here? The database is up and opened, you can connect with sysdba or using a listener, but you cannot connect to the database with an ordinary user at the server.

The problem is very simple: you have to change the permissions on your $ORACLE_HOME/bin/oracle executable:

oracle@myserver:~$ ls -la $ORACLE_HOME/bin/oracle
-rwxr-x--x 1 oracle dba 74016776 May 24 2006 /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle
oracle@myserver:~$ chmod ug+s $ORACLE_HOME/bin/oracle
oracle@myserver:~$ ls -la $ORACLE_HOME/bin/oracle
-rwsr-s--x 1 oracle dba 74016776 May 24 2006 /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle

Doing so you will be able to connect to the Oracle database at the server with any account:

myuser@myserver:~$ sqlplus myusr/myusr

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 9 15:01:10 2011

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


Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

Another problem that might arise with the same root cause and solution is an ORA-12547 error:

myuser@myserver:~$ sqlplus myusr/myusr

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 9 15:01:10 2011

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

ERROR:
ORA-12547: TNS:lost contact

It would be solved the same way:

oracle@myserver:~$ chmod 6751 $ORACLE_HOME/bin/oracle
oracle@myserver:~$ ls -la $ORACLE_HOME/bin/oracle
-rwsr-s--x 1 oracle dba 74016776 May 24 2006 /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle

More information:

ora- shared memory segment
ORA-12547: TNS:Lost Contact From SqlPlus [ID 422173.1]

No comments:

Post a Comment