Labels

Monday, 28 August 2017

Cluster resource 'SQL Server' in clustered service or application 'SQL Group' failed.

We got this error while doing fail over or fail back in cluster environment. Unfortunately we didn't find any accurate information in cluster event log or in window event log.

I have used the below approach to find out the root cause of failure.

Start SQL Service via Net Start NOT via Failover cluster Manager.

Ex : net start MSSQL$SQL2014

Friday, 25 August 2017

How to fix log cannot be rebuilt the database because the database was not cleanly shut down

Requirement : I got few mdf and ldf files from client and requested to restore the databases on production environment. I got the below error for one of the database during mdf and ldf attachment.

"File activation failure. The physical file name "G:\MS SQL Server 2005 Data Files\MSSQL.1\MSSQL\DATA\TEST.ldf" may be incorrect.
The log cannot be rebuilt because the database was not cleanly shut down."

Resolution :

I have used the below command to fix the issue.
CREATE DATABASE TEST ON (FILENAME = 'R:\SQL Data\TEST.mdf')
FOR ATTACH_FORCE_REBUILD_LOG

Note : Make sure service account or your user has the proper access to place the files in respective drive.

Saturday, 5 August 2017

ORA-01219: database not open: queries allowed on fixed tables/views only

Error : ORA-01219: database not open: queries allowed on fixed tables/views only

I got this error when I tried to startup the database.






Possibilities : System files might be corrupted or lost.

Resolution :

1. SQL> recover datafile 1;
2.SQL> alter database open;
2.SQL> select * from tab;

unable to take database online in ORACLE 11g

Error : ORA-01113: file 4 needs media recovery

I got the below error during database recovery (after performing the database backup using HOT backup method .)
 alter database datafile '/disk1/dev/data/users01.dbf' online;

ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: '/disk1/dev/data/users01.dbf'

Resolution 

In order to make the database online you have to follow the below steps

1. alter database datafile  '/disk1/dev/data/users01.dbf' offline;
2. cp users01.dbf /disk1/dev/data/ # From hot backup location.
3. recover datafile '/disk1/dev/data/user01.dbf';
4.alter database datafile 'disk1/dev/data/users01.dbf' online;

How to fix data file (ORA-01110: data file 4: '/disk1/dev/data/users01.dbf') missing issue in oracle.

I got the below error when I am trying to start up the data base in oracle 11g.

ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/disk1/dev/data/users01.dbf'

Error screen : 

















In order to fix the above error. We just need to copy the users01.dbf file from missing location.

Resolution :

In my case the backup file is located in disk2/coldbackup so I have copied this file to the target location i.e /disk1/dev/data/




Thursday, 3 August 2017

Startup and shutdown Methods in Oracle

When startup command is issued, Oracle looks for the parameter file in following order.

1. Spfile<SID>.ora
2. init<SID>.ora

Oracle look for the parameter file in $ORACLE_HOME/dbs

We can startup the database instance with following options.

1. startup
2. startup nomount
3. Startup mount
startup pfile=’/location/filename’
4. startup upgrade
5. startup mount restrict

1. Startup:-

ü  It will read the parameter file.
ü  It will start the background processes and allocate memory (SGA). – Instance started.
ü  It reads the controlfile. –Instance mounted.
ü  Physically checks the datafiles and redolog files.
ü  Checks the SCN number of the datafiles and controlfiles.
ü  It is used in normal situations.
ü  If the SCNs in the control files don’t match some of the SCNs in the data files headers—the background process (smon) will automatically perform an instance recovery before opening the database.

2. Startup mount:--

ü  It will read the parameter file.
ü  It will start the background processes and allocate memory (SGA). – Instance started.
ü  It reads the controlfile. –Instance mounted.
ü  Can be used when:-- Recovery is needed for the entire database, Flashback is to be performed, any feature like archive log is to be enabled or disabled.


3. startup nomount:--

ü  It will read the parameter file.
ü  It will start the background processes and allocate memory (SGA). – Instance started
ü  Can be used when:-- Creating database and creating controlfile.

4. startup upgrade:--

ü  It will do 1 to 5 and
ü   Give the option of upgrading database.
ü  Users cannot connect to the database.
ü  Can be used to upgrade the database dictionary
ü  Database must be shutdown and restarted for users to connect.

5. startup mount restrict:--

ü  It will read 1, 2 and 3.
ü  It will not read 4 and 5.
ü  Used when the database is dropped.

Changing the status:--

Alter database mount;

This command can be used when database is in nomount state, this will read the controlfiles and mount the database.

Alter database open;

This command can be used when database is mounted.
This will read the datafiles and redolog file and will check if the datafiles are consistent. Allows the users to connect to the database,

Alter database close;

This command can be used when database open. This will release the datafiles and redolog files.
User connections will not be allowed. Status will change to mount.

Alter database dismount;

This command can be used when database is at mount state. This will release the control file and change the status to nomount.

The database can be shutdown with the following options:--

Shutdown:--

No new user connections can be made to the database once the command is issued. Oracle waits for all users to exit their sessions before shutting down the database. No instance recovery is needed when you restart database, it will be consistent when it’s shut down in this way. Oracle closes the data files and terminates the background processes. Oracle’s SGA is deallocated.

Shutdown transactional:--

No new user connections are permitted once the command is issued. Existing users can’t start a new transaction and will be disconnected. If a user has a transaction in progress, oracle will wait until the transaction is completed before disconnecting the user. After all existing transactions are completed. Oracle shuts down the instance and deallocates memory. Oracle writes all redo log buffers and data block buffers to disk. No instance recovery is needed because the database is consistent.
BEGIN
  DBMS_LOCK.sleep(seconds => 60.01);
END;
/


Shutdown immediate:--
No new user connections are allowed once the command is issued. Oracle immediately disconnects all users. Oracle terminates all currently executing transactions. For all transactions terminated midway, oracle will perform a rollback so that database ends up consistent. Sometimes oracle may be busy rolling back the transactions it just terminated. Oracle terminates the background processes and deallocates memory. No instance recovery is needed upon starting up the database because it is consistent when shut down.

Shutdown  abort:--
No new connections are permitted once the command is issued. Existing sessions are terminated, regardless of whether they have an active transaction or not. Oracle doesn’t roll back the terminated transactions. Oracle doesn’t write the redo log buffers and data buffers to disk. Oracle terminates the background processes, de allocates memory immediately, and shutdown. Upon restarting, oracle will perform an automatic instance recovery, because the database isn’t guaranteed to be consistent when shut down.