Search Blog Post

Saturday, October 12, 2013

Startup Fails With ORA-01012: Not Logged On

Problem Description
Users cant able to login to database server. Though it allow sysdba to login, it does not allow to run any query. Sometimes it will show database is connected to an idle instance. But when we startup database it shall throw error ORA-01081: cannot start already-running ORACLE - shut it down first.

 $ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.3.0 Production on Sat Oct 12 07:53:11 2013

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

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 instance_name,status from v$instance;
ERROR at line 1:
ORA-01012: not logged on
SQL> desc v$instance
ERROR:
ORA-01012: not logged on

SQL> startup
ORA-01012: not logged on


Changes
Oracle has been forcefully shutdown at OS level or crashed.

 CAUSE
An orphaned shared memory segment belonging to the ORACLE_SID still exists from a previous instance startup.

The command
ps -ef | grep $ORACLE_SID

shows no processes but with ORACLE_SID set the Oracle 'sysresv' utility shows a shared memory segment for a non-existing instance, e.g.

 $ sysresv

IPC Resources for ORACLE_SID "TEST" :

Shared Memory:
ID              KEY
5963794         0x00000000
5996563         0x00000000
6029332         0xb2e3c9ac

Semaphores:
ID              KEY
No semaphore resources used
Oracle Instance not alive for sid "TEST"


Solution
On OS level, remove the orphaned shared memory segment using:

ipcrm -m <problem shared memory id>

$ ipcrm -m 5963794
$ ipcrm -m 5996563
$ ipcrm -m 6029332

$sqlplus '/as sysdba'

Connected to an idle instance.

SQL> startup Oracle instance started
Total System Global Area   10689474560 bytes
Fixed Size                     2237776 bytes
Variable Size               6375344816 bytes
Database Buffers            4294967296 bytes
Redo Buffers                  16924672 bytes
Oracle Instance Started.
Oracle Database Opened.

79 comments:

  1. Thank you. You saved me with this one.

    ReplyDelete
  2. Glad to know this helped you..!!

    ReplyDelete
  3. just login with user / as sysdba
    then shutdown abort
    then startup database
    thats it

    ReplyDelete
    Replies
    1. This one actually helped

      Delete
    2. Thank you. For once, a simple solution for a problem. I hate it when people just go on stroking their egos by describing hard to understand terminologies where just one simple solution or command would do the trick. Once again, thank you very much.

      Delete
    3. Excellent. Simple way to handle...

      Delete
    4. You rock man.. This one actually worked. Thanks a lot..!!

      Delete
    5. you are the best men ... ty ... saludos desde Peru

      Delete
    6. Thank you, this was way simpler than the first option

      Delete
    7. This one really worked. Thanks alot.

      Delete
    8. worked like a charm, thank you

      Delete
    9. Thanks Rajesh :) This fix worked like a charm. Unfortunately, i didn't find any OS level orphaned shared memory segment and luckily found your comment. You rock man!!!

      Are you blogger?

      Delete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Thanks you saved me with this one

    ReplyDelete
  6. When i am running this command i am getting the error

    C:\Windows\system32>sqlplus "/as sysdba"

    SQL*Plus: Release 11.2.0.1.0 Production on Tue Oct 14 09:42:01 2014

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

    ERROR:
    ORA-00020: maximum number of processes (150) exceeded


    Enter user-name:

    ===================================
    C:\Windows\system32>sqlplus -prelim "/as sysdba"

    SQL*Plus: Release 11.2.0.1.0 Production on Tue Oct 14 09:33:16 2014

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

    SYS@xyzdb 14-OCT-14>

    SYS@xyzdb 14-OCT-14> SELECT p.spi
    2 b.name "Background Process
    3 s.username "User Name",
    4 s.osuser "OS User",
    5 s.status "STATUS",
    6 s.sid "Session ID",
    7 s.serial# "Serial No.",
    8 s.program "OS Program"
    9 FROM v$process p,
    10 v$bgprocess b,
    11 v$session s
    12 WHERE s.paddr = p.addr
    13 AND b.paddr(+) = p.addr
    14 AND p.spid = 5280;
    SELECT p.spid "Thread ID",
    *
    ERROR at line 1:
    ORA-01012: not logged on
    Process ID: 0
    Session ID: 0 Serial number: 0


    ReplyDelete
    Replies
    1. sqlplus / as sysdba
      alter system register set processes=4000 scope=spfile;
      It is possible that your hostname is not being recognized.
      As root, type: hostname
      As DB user, start listener and then DB. Should be fine

      Delete
  7. Thanks for the post. It quickly got me on my way!

    ReplyDelete
  8. @Rajesh thanks brother, your advice saved me a lot of time & effort, Thanks Ankur for maintaining this blog.

    ReplyDelete
  9. check your hdisk space where it's keep the oradata file

    ReplyDelete
  10. Hi, I am very new to Oracle I have just installed the pre built EBS 12.2 and it was working fine when I restart I face the same error can you please give me the steps to solve this as I am also new to Linux I have only 3 user oracle, root and applmgr How can I do that plz it is urgent Thanks

    ReplyDelete
    Replies
    1. Can you please provide more details on the error message. Also check if you see any defunct processes from oracle, applmgr user.

      Delete
    2. ORA-01081 :can not start already running ORACLE - shut it down first
      Disconnect from oracle Database 11g Enterprise edition Release 11.2.0.4.0 -64 bit production
      with the partitioning,OLAP, Data mining and Real Application Testing options

      addbct1.sh : existing with status 9


      Delete
    3. This comment has been removed by the author.

      Delete
  11. Please check all the processes running from oracle, aplmgr
    ps -ef | grep oracle
    ps -ef | grep applmgr

    Kill all the processes, then do "ipcs -b" to find the remaining IPC facilities, owned by the same user, and remove them.

    Another possible option is to issue the command 'shutdown abort' or'startup force' when connected thru sqlplus.

    ReplyDelete
    Replies
    1. hai,
      is there UTLMONTR.SQL script in oracle 11g windows ,iam not able to find this script.
      please help me out on this.

      Delete
  12. Hi
    Thanks, this work, but now I am getting new error
    When I Started Database Listener i.e
    addlnctl. sh exits with status 1

    ReplyDelete
  13. Please check the listener config. files under $TNS_ADMIN (ORACLE_HOME/network/admin)

    ReplyDelete
    Replies
    1. Thanks, Now everything is working fine

      Thanks a lot

      Delete
  14. This comment has been removed by the author.

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. usorisa0csms01:CSMS:$ sqlplus / as sysdba

    SQL*Plus: Release 11.2.0.4.0 Production on Tue Mar 17 10:40:49 2015

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

    Connected to an idle instance.

    SQL> shutdown immediate
    ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Linux-x86_64 Error: 2: No such file or directory
    SQL> startup
    ORACLE instance started.

    Total System Global Area 3340451840 bytes
    Fixed Size 2257840 bytes
    Variable Size 1828719696 bytes
    Database Buffers 1493172224 bytes
    Redo Buffers 16302080 bytes
    ORA-01102: cannot mount database in EXCLUSIVE mode


    SQL> select name, open_mode from v$database;
    select name, open_mode from v$database
    *
    ERROR at line 1:
    ORA-01507: database not mounted

    ReplyDelete
  17. usorisa0csms01:CSMS:$ sqlplus / as sysdba

    SQL*Plus: Release 11.2.0.4.0 Production on Tue Mar 17 10:40:49 2015

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

    Connected to an idle instance.

    SQL> shutdown immediate
    ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Linux-x86_64 Error: 2: No such file or directory
    SQL> startup
    ORACLE instance started.

    Total System Global Area 3340451840 bytes
    Fixed Size 2257840 bytes
    Variable Size 1828719696 bytes
    Database Buffers 1493172224 bytes
    Redo Buffers 16302080 bytes
    ORA-01102: cannot mount database in EXCLUSIVE mode


    SQL> select name, open_mode from v$database;
    select name, open_mode from v$database
    *
    ERROR at line 1:
    ORA-01507: database not mounted

    ReplyDelete
  18. Great post it fixed my database.

    ReplyDelete
  19. Helped me as well, thanks! I would never suspect such thing :-)

    ReplyDelete
  20. Nice & great post, helped me fixing my issue.

    ReplyDelete
  21. This is great solution, It worked for me, Thanks a lot Ankur

    ReplyDelete
  22. I have still got same error for dbconnection(ORA-01012: not logged on. I am not able to connect database using pro*c.

    here is he piece of code :


    #include
    #include
    #include

    EXEC SQL INCLUDE sqlca;

    /* SQL and C shared variable declarations */
    EXEC SQL BEGIN DECLARE SECTION;
    char username[10] = "ad";
    char password[10] = "ad";
    char db_string[50] = "DV13ER";

    EXEC SQL END DECLARE SECTION;

    int oracle_connect();
    void SQLerror();
    main(){

    printf("sql connection code=%d",sqlca.sqlcode);
    return(sqlca.sqlcode);
    }
    int a;
    /* ... */
    EXEC SQL SELECT COUNT(*) INTO :a
    FROM dual;
    /* ... */
    printf("The salary is %d\n", a);
    //exit(0);

    }
    int oracle_connect(){
    EXEC SQL CONNECT :username IDENTIFIED BY :password
    AT DB_NAME USING :db_string;

    printf("sql connection code=%d",sqlca.sqlcode);
    return(sqlca.sqlcode);
    }
    void SQLerror()
    {
    /* Debugger */
    /* fprintf(stderr,"SQLerror called\n");*/

    fprintf(stderr,"\nORACLE error detected:\n");
    fprintf(stderr,"% .70s \n", sqlca.sqlerrm.sqlerrmc);
    fprintf(stderr,"Exiting...\n");

    EXEC SQL ROLLBACK;
    // Delete_Screen_Parms();
    exit(207);
    }

    there is no IPC resource for oracle_sid

    ReplyDelete
  23. Thank's a lot Brother....Nice post and worked for me

    ReplyDelete
  24. Thank you Ankur. Great post and helped me.

    ReplyDelete
  25. Ankur, I was struggling from morning, I was about to restart the box but your post has saved.
    excellent.

    Thank you

    --Dev

    ReplyDelete
  26. Big THANKs, ITs was very helpful

    ReplyDelete
  27. I am unable to fix the issue.Could u give me any suggestion.(I have tried using command prompt).

    ReplyDelete
  28. HEllo ANKUR,
    FIRST of all thank u for maintain this BLOG.
    well I am trying to connect my database getting this error ORA-01012
    in windows7(32-bit pc)
    how to solve this
    and also i am trying to shutdown no action is there
    ERROR LIke
    sql>sqlplus / as sysdba
    connected
    sql>
    sql>select name from v$database;
    error
    ORA-01012: not logged on
    session id:0, process id :0,
    serial no: 0
    can u pls find this

    ReplyDelete
  29. U just saved me... Thanks a lot .

    ReplyDelete
  30. Thanks a lot...it has resolved my issue .
    Pradeep Vyas

    ReplyDelete
  31. Thanks..!! Worked!!

    ReplyDelete
  32. Fantastic. Saved me today.

    ReplyDelete
  33. Thanks a lot. It worked for me.

    ReplyDelete
  34. Thank you! This worked for me!

    ReplyDelete
  35. Perfect solution by command sysresv and ipcrm -m , issue got resolved. Thanks.

    ReplyDelete
  36. First month at new job, ran into this one after patching oracle home. THANKS!!! You saved me :=)

    ReplyDelete
  37. Thank you so much, you saved me..

    ReplyDelete
  38. Good one !! Thanks

    ReplyDelete
  39. Thanks buddy.. Please guide me how to fix this issue permanently.....my setup is active passive. Wherever I'm switch over DB12c one node to second node that time i facing this issue.
    Please help me

    ReplyDelete
  40. Thank you....you helped a brother

    ReplyDelete
  41. i had this same error..ORA-01012: not logged on

    i did this $ sysresv, but noticed my oracle instance is alive,
    do i still
    ipcrm -m

    ***************** End of Resource Limits Dump ******************
    Total /dev/shm size: 1762906112 bytes, used: 1720320 bytes
    Shared Memory:
    ID KEY
    364347401 0x00000000
    364380170 0x00000000
    364314631 0x00000000
    364412940 0x97883768
    Semaphores:
    ID KEY
    12976128 0xa75179ec
    13008897 0xa75179ed
    13041666 0xa75179ee
    Oracle Instance alive for sid "orcl"


    ReplyDelete
  42. Hi all

    ORA-01012: not logged on
    session id:0, process id :0,
    serial no: 0
    This error has been a problem in my Windows environment. Any suggestions how I can overcome this challenge?

    ReplyDelete
  43. Thanks and I have a neat proposal: How To Budget House Renovation cost to gut and renovate a house

    ReplyDelete