Oracle Networking ( How to connect to Oracle Database through Different Machine)

ORACLE NETWORKING

This article will tell you how to connect to an Oracle database through Different server Or Different Machine

For this Scenario I used VMWare Work Station ACE Edition.

1) First Install Linux and then ORACLE 10g R2 on VMware Machine.
  (clickhere  to know How to Install Linux on VMWare)
  (clickhere to know how to Install Oracle10g on Linux)


Note:  While Installing Oracle Software. You will find option like Install Software only. Click On it.  We will create Database later.


2)  In this case I created Linux server called Primary




Note: IP Address of Primary Machine is 192.168.2.151 and in active mode And host name is Primary.dbasagar.com, use same IP address and hostname at the time of  installing linux , only if you are using Bridged network

3)Now goto VMware storage location on your host (C:\Users\Administrator\Documents\Virtual Machine)
You will find folder called Primary ( Since my machine name is Primary)
Create a folder called Standby


4) Copy all files on Primary folder and paste those into Standby
5) Open standby folder and open vmware configuration file as shown in fugure
     find line name DisplayName, Chang primary to Standby


6) Now Go to VMware press ALT+F and the click on open. Go to Standby local open vmdk file as shown      
     in figure



Now you have a two virtual machines called Primary and standby. Then Power on Standby Machine and leave Primary Power off. we need to change certain parameters
And log in as root user



7) Go to Applications --> system settings --> Network




a) Double click on eth0
     A new window will open - change IP address 192.168.2.151 to 192.168.2.152 ( Since we just copied
     whole content of Primary to standby)


b)  on same window you have tab called Hardware Device as show in figure, click on in and click Probe for
     once to change MAC address finally click OK


c) Now click on DNS tab on Main window as show in figure and change Host name from 
    Primary.dbasagar.com to Standby.dbasagar.com 




d) Now click on Devices tab and finally click on activate and then YES and  click on OK






Your eth0 device is now active mode. Close Net configuration window and log off and log in again as root user


8) Open Terminal and issue following commands


     # hostname
     #vi /etc/hosts
make entries as show in figure




9) Now power on Primary Machine and log in as root user and  Open Terminal and issue following 
    commands
     # hostname
     #vi /etc/hosts
     make entries as show in figure




10) Now  log out of Root user and log in as oracle on both Machines
        Create database called PROD using DBCA tools (on Primary Machine)
       (Clickhere to know how to create database using DBCA)

11) Connect to database as sysdba (on Primary Machine)



12) Open another Terminal
      Is below command as shown in figure
       $ netca

 Listener Configuration --> Add --> Listener Name [ PROD ] --> TCP --> PORT 1521 --> Next --> Finish




13) Now Issues netmgr command to make entries on tnsname.ora
   
     $netmgr
     click on listeners --> PROD --> Database services -->
     add database make entires PROD and PROD --> again click on add database --> Save and EXIT






14)  Again issue netca

Local Net service configuration --> add --> Name --> PROD --> TCP -->  Host Name and  PORT 1521 --> YES, Perform test --> test successful--> NEXT --> Finish







15) Now Ping TNS using below command

      $tnsping PROD



 16)  Go to Directory $ORACLE_HOME/network/admin
       edit tnsnames.ora as show in figure



copy selected content and past it into Standby machine tnsnames.ora file and save it





17) Now Ping TNS using below command

      $tnsping PROD



We are all set. Now testing

18) Go to Primary machine

 log In as as sysdba

create a user called sagar and grant roles as shown in figure



19)  Now go to Standby and log In sagar user

$ sqlplus sagar/sagar@PROD


Yes... Now you are connected to Database PROD which is located at Primary Machine through Standby Machine

20) create a table called test and insert some records in it and issue commit;



21) Now go to Primary Machine. check that records are stored are not as a sys user or Sagar user



In this way we can connect to database as remotely. In this way only developers will connect to database

Thanks
Sagar