Tuesday, 14 April 2015

Create and configure yum on red hat linux

If you are using VMware then first make the redhat iso connected to the guest. On the other hand if you have the dvd just insert it to your dvd drive.

Log in as root

mkdir /mnt/dvd/

mount /dev/cdrom /mnt/dvd/

cd /mnt

find /mnt -iname 'createrepo*'

rpm -ivh /mnt/dvd/Server/createrepo-0.4.11-3.el5.noarch.rpm

createrepo .

cat  > /etc/yum.repos.d/dvdiso.repo <<EOF
[MailRepo]
name=MailRepo
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF



# yum clean all
# yum list

# yum install -y rpmname.rpm 

Find the video of this here 



Hope this helps

Thanks
Subhajit

How to identify controlfile backup piece while using NOCATALOG mode

http://letstalkoracle.blogspot.in/2015/03/restore-controlfile-in-nocatalog-mode.html

In the above article I mentioned that you can mention the backup piece name under the backup location path to restore the controlfile in NOCATALOG mode.

So the question is you may have a lot of backup pieces in that location. How do you identify the controlfile backup piece?

Let's consider 2 scenarios.

1. Your controlfile is lost, now you are trying to restore
2. You have just completed a backup of the controlfile and now you want to identify the backup peice corresponding to it.

Now for  scenario 1:

There is only one way. Go to your backup location. Find out the last backup pieces you did according by time and date. You can do this both accessing through PuTTY or GUI.

Now check the size of each piece using du -h piecename command.

The piece that contains the least amount of memory is your controlfile backup piece. Don't worry about getting confused with the spfile backup piece, in case you took a backup of spfile separately, as spfile backup piece will be in KB.

Now for scenario 2:

On the SQL prompt issue this

SQL> select output from v$rman_output;

You will get the backup piece name against your backup command in the output. You can note the name from there.

My  recommendation is to always use a log clause including the log file name while calling RMAN from OS prompt like this

$ rman log logfilename or $ rman log /path/logfilename  then followed by connect target.

If you go the logfile location and view it you will find all the rman outputs in the logfile and you can identify each backup piece.

Hope this helps.

Thanks
Subhajit

Friday, 10 April 2015

How to create database manually in oracle without dbca

We need these resources

1. A sample pfile
2. A database creation sql script

You can create pfile from spfile if you already have a database created, using

SQL> create pfile from spfile;


Now you can check that a pfile has been created in $ORACLE_HOME/dbs with the name format such as initSID.ora

Make a copy of this pfile using your SID. In my case it is newdb. So I have copied in that location using
cp -p initprod.ora initnewdb.ora (we are using prod's pfile)


Or else you can use the sample pfile of mine. You can download it from here http://www.mediafire.com/download/34j4ekqx8jcohdh/initprod.ora

Also you can download the database creation sql script from here http://www.mediafire.com/view/379b73qmvv735wc/db_creation_script.sql

If you download the pfile then don't forget to place it inside $ORACLE_HOME/dbs and change the SID in the name initSID.ora to what you want. In my case it is newdb. So the name will be initnewdb.ora

You can place the database creation script anywhere like I have placed it on /home/oracle/Desktop

I have used PuTTY to connect to my host to give you a real industry feeling, you can do the same or you can use the terminal on your host directly. As you wish.

Go to your $ORACLE_HOME/dbs location such

>cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs

>Open the pfile initnewdb.ora and edit it using 
vim initnewdb.ora

>Type 

 :%s/prod/newdb/g to replace the old with new.

>Then :wq 

>Now open it using 

cat initnewdb.ora

Now find the directories that you have to create 

> Create those directories such as

mkdir -p /u01/app/oracle/admin/newdb/adump

mkdir -p /u02/data/newdb


mkdir -p /u02/fast_recovery_area/newdb


Basically you need create the adump location, the controlfiles location and the fast recovery area location. So create these according to your present mount point structure.

Now time edit the sql script 

go to the location where you have placed the database creation sql script. 

cd /home/oracle/Desktop

vim db_creation_script.sql

Replace the database name and locations with yours. When you are done use :wq to write and quit the vim editor.

Then open the oratab file using

vim /etc/oratab

And make an entry for your SID with home such as 

newdb:/u01/app/oracle/product/11.2.0/dbhome_1:N and then :wq

Now set the SID using . oraenv

Then open sqlplus '/as sysdba'

SQL> startup nomount

Then run the db_creation_script using 

SQL> @/home/oracle/Desktop/db_creation_script.sql

If we haven't done any mistake, we should see 

"Database created." in a while

Now we have run these two scripts one after another 

SQL> @/$ORACLE_HOME/rdbms/admin/catalog.sql

SQL> @/$ORACLE_HOME/rdbms/admin/catproc.sql


The 2nd script takes too long. After both these get completed use this to verify

SQL> select open_mode from v$database;


You will get READ WRITE as output.


You can find the video here for this 




 That's all

Thanks
Subhajit