When trying to connect to an ORACLE user via TOAD (Quest Software) or any other means (Oracle Enterprise Manager) I get this error:
ORA-011033: ORACLE initialization or shutdown in progress
After some googling, I found the advice to do the following, and it worked:
SQL> startup mount
ORACLE Instance started
SQL> recover database
Media recovery complete
SQL> alter database open;
Database altered
Here is my solution to this issue:
SQL> Startup mount
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown abort
ORACLE instance shut down.
SQL>
SQL> startup mount
ORACLE instance started.
Total System Global Area 1904054272 bytes
Fixed Size 2404024 bytes
Variable Size 570425672 bytes
Database Buffers 1325400064 bytes
Redo Buffers 5824512 bytes
Database mounted.
SQL> Show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string C:\APP\USER\ORADATA\ORACLEDB\C
ONTROL01.CTL, C:\APP\USER\FAST
_RECOVERY_AREA\ORACLEDB\CONTRO
L02.CTL
SQL> select a.member,a.group#,b.status from v$logfile a ,v$log b where a.group#=
b.group# and b.status='CURRENT'
2
SQL> select a.member,a.group#,b.status from v$logfile a ,v$log b where a.group#=
b.group# and b.status='CURRENT';
MEMBER
--------------------------------------------------------------------------------
GROUP# STATUS
---------- ----------------
C:\APP\USER\ORADATA\ORACLEDB\REDO03.LOG
3 CURRENT
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1904054272 bytes
Fixed Size 2404024 bytes
Variable Size 570425672 bytes
Database Buffers 1325400064 bytes
Redo Buffers 5824512 bytes
Database mounted.
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 4234808 generated at 01/21/2014 18:31:05 needed for thread 1
ORA-00289: suggestion :
C:\APP\USER\FAST_RECOVERY_AREA\ORACLEDB\ARCHIVELOG\2014_01_22\O1_MF_1_108_%U_.AR
C
ORA-00280: change 4234808 for thread 1 is in sequence #108
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
C:\APP\USER\ORADATA\ORACLEDB\REDO03.LOG
Log applied.
Media recovery complete.
SQL> alter database open resetlogs;
Database altered.
And it worked:
I had a similar problem when I had installed the 12c database as per Oracle's tutorial . The instruction instructs reader to create a PLUGGABLE DATABASE (pdb).
The problem
sqlplus hr/hr#pdborcl would result in ORACLE initialization or shutdown in progress.
The solution
Login as SYSDBA to the dabase :
sqlplus SYS/Oracle_1#pdborcl AS SYSDBA
Alter database:
alter pluggable database pdborcl open read write;
Login again:
sqlplus hr/hr#pdborcl
That worked for me
Some documentation here
This error can also occur in the normal situation when a database is starting or stopping. Normally on startup you can wait until the startup completes, then connect as usual. If the error persists, the service (on a Windows box) may be started without the database being started. This may be due to startup issues, or because the service is not configured to automatically start the database. In this case you will have to connect as sysdba and physically start the database using the "startup" command.
I used a combination of the answers from rohancragg, Mukul Goel, and NullSoulException from above. However I had an additional error:
ORA-01157: cannot identify/lock data file string - see DBWR trace file
To which I found the answer here: http://nimishgarg.blogspot.com/2014/01/ora-01157-cannot-identifylock-data-file.html
Incase the above post gets deleted I am including the commands here as well.
C:\>sqlplus sys/sys as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Apr 30 19:07:16 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 778387456 bytes
Fixed Size 1384856 bytes
Variable Size 520097384 bytes
Database Buffers 251658240 bytes
Redo Buffers 5246976 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 11 – see DBWR trace file
ORA-01110: data file 16: 'E:\oracle\app\nimish.garg\oradata\orcl\test_ts.dbf'
SQL> select NAME from v$datafile where file#=16;
NAME
--------------------------------------------------------------------------------
E:\ORACLE\APP\NIMISH.GARG\ORADATA\ORCL\TEST_TS.DBF
SQL> alter database datafile 16 OFFLINE DROP;
Database altered.
SQL> alter database open;
Database altered.
Thanks everyone you saved my day!
Fissh
The issue can also be due to lack of hard drive space. The installation will succeed but on startup, oracle won't be able to create the required files and will fail with the same above error message.
I hope this will help somebody, I solved the problem like this
There was a problem because the database was not open.
Command startup opens the database.
This you can solve with command alter database open
in some case with alter database open resetlogs
$ sqlplus / sysdba
SQL> startup
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 8628936 bytes
Variable Size 624952632 bytes
Database Buffers 436207616 bytes
Redo Buffers 3952640 bytes
Database mounted.
Database opened.
SQL> conn user/pass123
Connected.
I faced the same problem. I restarted the oracle service for that DB instance and the error is gone.
What worked for me is that i hadn't set the local_listener, to see if the local listener is set login to sqlplus / as sysdba, make sure the database is open and run the following command
show parameter local_listener, if the value is empty, then you will have to set the local_listener with the following SQL command ALTER SYSTEM SET LOCAL_LISTENER='<LISTENER_NAME_GOES_HERE>'
Related
I have a SQL server database that has been running perfectly fine on my machine for about 6 months, a couple days ago out of nowhere it was inaccessible (Pending Recovery).
I did a bunch of Googling and have tried the following things to fix the issue but thus far restoring it from a previous backup is the only thing that seems to work.
I have tried (From SMS and SQLCMD):
ALTER DATABASE mydatabase SET EMERGENCY
ALTER DATABASE mydatabase set single_user
DBCC CHECKDB (mydatabase, REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS;
ALTER DATABASE mydatabase set multi_user
Step #3 errors out with: "cannot open mydatabase is already open and can only have one user at a time"
Second try:
EXEC sp_resetstatus 'mydatabase';
ALTER DATABASE mydatabase SET EMERGENCY
DBCC CHECKDB ('mydatabase')
ALTER DATABASE mydatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CHECKDB ('mydatabase', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE mydatabase SET MULTI_USER
Step #5 errors out with the same error.
My question is what could be causing this in the first place and how can I fix it properly without having to do a restore twice a day.
Database is already open and can only have one user at a time, this is error number 924. The complete error message looks like this:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Msg 924, Level 14, State 1, Line 1 Database ‘db_name’ is already open and can only have one user at a time.
The level 14 belongs to security level errors like a permission denied. It means that it cannot be open because someone is using it.
Use the sp_who or sp_who2 stored procedures. You can also use the kill command to kill the processes that are active in the database.
I also found this thread useful: How to fix Recovery Pending State in SQL Server Database?
what could be causing this in the first place and how can I fix it properly without having to do a restore
The most likely cause is a a hardware or driver problem with your hard disk.
In my case, I had databases set up on my local machine but on an external drive mapped to my hard drive. I have the external drive connected to my docking station all the time but I had to disconnect the hard drive and after I connected it again - the databases that are restored on the external drive went into Recover Pending mode.
In my case what helped me was to set the database offline in Microsoft SQL Server Management Studio by right clicking on the database - Tasks - Take Offline. The status of the database changes to Offline. After that bring the database online again by right clicking on the database - Tasks - Bring online.
The database was successfully recovered without any issues. But if the cause is different these steps may not help.
Take the database offline
Bring the database back online
I have developed an Oracle pro*C/C++ library that provides an API to other applications to read data from database tables and insert/update data in the tables. Recently a customer reported that the API did not return any error when underlying file systems (ASM) that hold tables spaces went down for a few days! This must be due to caching data by Oracle instance.
My question is this: Can we make Oracle return error, without affecting its caching scheme, for any read/write access to a table immediately after its table space is found to be not accessible due to corruption or any disk related errors?
I did a small experiment to simulate the customer's problem. I have created a new directory on my Linux system. Created a table space in it and created a table to use the table space. Inserted a few rows using sqlplus and fetched rows from the table and verified results. They are OK. Then I renamed table space file to some other file to simulate missing/corruption of the table space. Oracle still returned rows even though physical table space was missing. I could even insert a few rows successfully and commit went through without any error(probably this may fail for large number of inserts). However, I could not shut down the database instance. Once I aborted the instance, start up failed with an error saying the table space could not be identified/locked. After that sqlplus could not connect to the database. But my requirement is to get an error for any DML operation if the table space file found to be missing or corrupted.
Following is my experiment:
Created a directory for a new tablespace
[root#mvsLTOraLin u01]# mkdir /orats
[root#mvsLTOraLin u01]# chown oracle /orats
[root#mvsLTOraLin u01]# chgrp oinstall /orats
Created a table space using sysdba user as following:
SQL> create tablespace orats datafile '/orats/ots1.dbf' size 5M;
Tablespace created.
[root#mvsLTOraLin orats]# pwd
/orats
[root#mvsLTOraLin orats]# ls -l
total 5128
-rw-r-----. 1 oracle oinstall 5251072 Jul 11 17:53 ots1.dbf
Created a table in the table space using fis_admin user and inserted 3 rows:
-bash-4.1$ sqlplus fis_admin/fis_admin#fisdb
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 11 17:56:50 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table tbl1(c1 int not null primary key, c2 varchar2(100)) tablespace orats;
Table created.
SQL> insert into tbl1 values(1, 'one');
1 row created.
SQL> insert into tbl1 values(2, 'two');
1 row created.
SQL> insert into tbl1 values(3, 'three');
1 row created.
SQL> select * from tbl1;
C1
----------
C2
--------------------------------------------------------------------------------
1
one
2
two
3
three
Renamed table space file from ots1.dbf to gone.dbf to simulate corruption of the table space.
[root#mvsLTOraLin orats]# date
Sat Jul 11 18:03:00 IST 2015
[root#mvsLTOraLin orats]# mv ots1.dbf gone.dbf
[root#mvsLTOraLin orats]# ls -l
total 5128
-rw-r-----. 1 oracle oinstall 5251072 Jul 11 17:53 gone.dbf
Selected data from sqlplus which is still connected
SQL> select c1, current_timestamp from tbl1;
C1
----------
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
1
11-JUL-15 06.05.20.525276 PM +05:30
2
11-JUL-15 06.05.20.525276 PM +05:30
3
11-JUL-15 06.05.20.525276 PM +05:30
Retrieved data even though table-space disappeared.
This shows Oracle is returning from its cache.
Restarted sqlplus and queried. Still server did not realise that its table space is missing!
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-bash-4.1$
-bash-4.1$ sqlplus fis_admin/fis_admin#fisdb
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 11 18:07:24 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select c1, current_timestamp from tbl1;
C1
----------
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
1
11-JUL-15 06.07.42.014083 PM +05:30
2
11-JUL-15 06.07.42.014083 PM +05:30
3
11-JUL-15 06.07.42.014083 PM +05:30
Tried to shutdown the instance
-bash-4.1$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 11 18:08:42 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/orats/ots1.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL>
It failed as expected.
Tried to insert a row.
SQL> insert into tbl1 values(4, 'four');
1 row created.
Surprise! The insert was successful. It must may fail for many inserts.
Forced shutdown
SQL> shutdown
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/orats/ots1.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL> shutdown immediate
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/orats/ots1.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
ORACLE instance shut down.
SQL> quit
Restarted instance
SQL> startup;
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 742395736 bytes
Database Buffers 318767104 bytes
Redo Buffers 5554176 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/orats/ots1.dbf'
Error is shown as expected.
Tried access to tbl1:
SQL> select c1, current_timestamp from tbl1;
select c1, current_timestamp from tbl1
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
Failed as expected.
So, is there a way to make Oracle return error on next access to the table for reading or writing even though data may be returned from cache?
I am unable to login to 'postgres' database as 'postgres' user.
OS : REHL Server release 6.3
Postgresql version: 8.4
There is a Database 'jiradb' which is used as a Backend for JIRA 6.0.8.
When I give the command
[root ~]#psql postgres postgres
Password for user postgres: *******
psql: FATAL: could not open relation with OID 2696
How do I fix this error and login to 'postgres' database. Please ask me if you need more details. I am new to postgres DB.
Thanks.
Your postgres database is damaged. oid 2696 is a system reserved oid, so it's a system table, and their oids are stable across databases and across versions. Looking it up on my 9.4, it's:
regress=> select relname from pg_class where oid = 2696;
relname
----------------------------------
pg_statistic_relid_att_inh_index
(1 row)
regress=> \d pg_statistic_relid_att_inh_index
Index "pg_catalog.pg_statistic_relid_att_inh_index"
Column | Type | Definition
------------+----------+------------
starelid | oid | starelid
staattnum | smallint | staattnum
stainherit | boolean | stainherit
unique, btree, for table "pg_catalog.pg_statistic"
so you have a missing file in the data directory for the index pg_statistic_relid_att_inh_index on the system table pg_catalog.pg_statistic.
This should not happen. You have at lest limited data corruption in your datadir.
Your first action should be to stop the database and make a full filesystem-level copy of the entire data directory, per PostgreSQL wiki - corruption.
Then check for possible causes. Recent disk issues? Unexpected/sudden shutdowns followed by fsck, possibly on a system with a non-crashsafe file system, unsafe mount options (e.g. ext3/ext4 data=writeback), unsafe configurations like ext[34]-on-LVM-on-md with barriers on older kernels, etc. Also make sure you're on the latest 8.4 point release.
Only once you have made a full file system level copy of the data directory to safe read-only storage, start the database back up (but not the applications that use it) and see if you can connect to jiradb e.g. psql jiradb. If you can, promptly perform a pg_dump of jiradb and any other databases with data of value.
Do not keep on using the damaged data directory. Now is a good time to do a dump and reload - do a pg_dumpall --globals-only, a pg_dump -Fc of each database, then move the datadir aside, re-initdb, and start back up with a clean install. You might even want to upgrade to a less ancient PostgreSQL at the same time.
Note that it is generally possible to fix issues like this in-place. In this case, if your damaged database wasn't the unimportant-and-usually-empty postgres database, you could start PostgreSQL up in single-user mode with system indexes disabled, then REINDEX the damaged index.
Basically Im trying to get the output of 'DESC HR.EMPLOYEES' via command line.
I have created a file called 'file.sql'
DESC hr.employees;
exit;
Then I execute this on unix command line:
sqlplus username/password #file.sql
My output looks like this, however I want to eliminate all extra messages and want to see only the relevant query result. Any way this is possible? Basically someway to do a silent login / logoff.
SQL*Plus: Release 12.1.0.1.0 Production on Mon Sep 15 19:04:53 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-28002: the password will expire within 7 days
Last Successful login time: Mon Sep 15 2014 19:04:06 -04:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
I used the -s option with sqlplus. and that eliminated most of the unwanted messages. But I still get ERROR: ORA-28002: the password will expire within 7 days
You do clearly need to change the password, but if you have a scenario where you need to be able to run a particular script in the meantime, it is possible to hide that message; but you have to move the credentials into the file. (Supplying them on the command line is insecure anyway). So file.sql would become:
set termout off
connect username/password
set termout on
desc hr.employees;
exit;
And you'd run it as:
sqlplus -s /nolog #file
The /nolog means it won't automatically attempt to connect, and when it does so from within the script the output from the connection command is hidden.
Of course, this would hide any other messages related to the account or database availability which would make understanding a failure hard; and you probably really want to be told about the pending expiry so you can change the password - otherwise you'll come to run this a week later and find the account is actually expired, which isn't something you can fix yourself. (Since your example is from the 15th, your account may already have expired, or had its password reset, of course).
Another minor wrinkle with this is that any SQL commands in your login.sql or glogin.sql will show an SP2-0640 error as they will try to run before you are connected.
Just because something is possible doesn't mean it's a good idea, and the potential issues almost certainly outweigh any advantages. So really, when you see the warning, change the password.
This error message ...
ORA-28002: the password will expire within 7 days
...means what it says. The account's password is set to expire and that user will not be able to login within the next week.
You want to get rid of the message? Simple: change the password.
If that solution is undesirable for any reason (I don't know how you use the account) you will need to persuade the DBA to unexpire it. That is probably less simple.
If you want to get rid off the PASSWORD EXPIRY message, then you can set the PASSWORD_LIFE_TIME limit to unlimited. Follow these steps :
SQL> SELECT PROFILE FROM DBA_USERS WHERE USERNAME='SCOTT'
2 /
PROFILE
------------------------------
DEFAULT
SQL>
SQL> SELECT RESOURCE_NAME,
2 LIMIT
3 FROM DBA_PROFILES
4 WHERE PROFILE ='DEFAULT'
5 AND RESOURCE_NAME='PASSWORD_LIFE_TIME'
6 /
RESOURCE_NAME LIMIT
------------------------------ ------------------------------
PASSWORD_LIFE_TIME 180
For your profile, execute :
alter profile <profile_name> limit password_life_time UNLIMITED;
You shouldn't be getting the message again.
Adding -S flag worked for me.
sqlplus -S username/pass#server #sample.sql
I am stuck with a little Oracle problem. My PC was shut down improperly after my graphics card freaked out, which caused Oracle 11g Express to not properly close down. This means that I get the above error when I try to connect. My PC has been on for 3 hours, and I still get the error, so it is safe to assume that there's something wrong.
The usual way of remedying the problem is to use the following sequence of commands from the command line:
sqlplus /nolog
SQL> connect / as sysdba
SQL> shutdown abort
SQL> startup nomount
SQL> alter database mount;
SQL> alter database open;
However, when I give the shutdown command, I get the error
ORA-12560: TNS:protocol adapter error
So now, I can't mount my db. ANy help would be appreciated.
This worked for me:
Open the Start menu --> All Programs
Open folder "Oracle Database 11g Express Edition"
Choose "Start Database"
Wait until you get "C:\Windows\system32"
Open "Run SQL Command Line" and connect to your database
This is probably not necessary or even possible in all cases, but I ended up uninstalling and reinstalling Oracle because I get paid per hour and I'd rather spend that time producing code than wrestling with Oracle.
My guess would be that your listener service is not running.
You can check this by openening the services screen by (in Win7) searching for "services". In the list you should find an Oracle Listener service with status Started.