Oracle Connection String for RAC Environment? - oracle

I have got an ORACLE RAC Environment access .The details are
Database Name: orcl
Service Name: orcl
IP Address: 192.168.1.1 and 192.168.1.2
SQL> host srvctl status database -d orcl
Instance orcl1 is running on node orclnode1
Instance orcl2 is running on node orclnode2
My concern is my connection, which is being established using
(DESCRIPTION=(ADDRESS=
(PROTOCOL=TCP)(HOST=192.168.1.1) (PORT=1521)
)(CONNECT_DATA=(SID=orcl1)))
But the provider wants it to be connected via the orcl service name .
I don`t have any other info related to this. Am I connecting correctly or I need hostname or IP address for orcl service name.

Your connection string is referencing one instance on one server/node. You should be using the common service name instead, and identifying all the servers it is available on.
The equivalent for you would be something like this (line breaks just for clarity here):
(DESCRIPTION=(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.1)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.2)(PORT=1521))
)(CONNECT_DATA=(SERVICE_NAME=orcl)))
As long as it is resolvable, it shouldn't matter whether you use the DNS names or the IP addresses for the HOST parameters.
You may also need the LOAD_BALANCE or FAILOVER parameters; see the docs.

Related

How to connect to an Oracle Database running on Amazon AWS EC2?

I have an Oracle Database instance running in Amazon AWS EC2 service. (it is not RDS Relational Database Services).
How can I configure my Oracle SQl Developer to to access this remote databse in AWS EC2?
By checking AWS documentation I found only references to connect to Oracle databse running in RDS services.
I apreciate your help.
Thanks
In AWS, edit the Security Group for your instance to add a rule (if one doesn't already exist).
Inbound
Type = SSH
Protocol = TCP
Port Range = 22
Source = "My IP", or "Custom" (as you wish)
In SQL Developer, open View -> SSH.
Right-click "SSH Hosts", New SSH Host.
Name = whatever you like
Host = your server's IPv4 Public IP address
Port = 22 (default)
Username = root or ec2-user, whichever is appropriate for the linux AMI you used
Use key file = tick this and select your key file for your instance
Add a Local Port Forward = tick this and accept the defaults (localhost, port 1521)
Edit the properties of your SQL Developer Database Connection
Connection Type = SSH
Port Forward = the name of the SSH Host you created earlier
SID / Service name = whatever SID or Service name you need
If you want to add another layer of security. SSH or DMZ + Load Balancing is the way to go. If not Make sure the following are all open for the IP. firewall, VPC Network, AWS inbound outbound rules.

tnsconnect shows operation timeout

Here is my use case:
We are using virtual machine. Couple of days ago I have created new Oracle database. I cloned this machine and it got different IP address.
Today I wanted to connect to the database using SQLPlus but I go connection timeout. I have tried tnsping command and here is the output of that command:
C:\Users\Administrator>tnsping clm
TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 09-JAN-2
014 08:36:31
Copyright (c) 1997, 2010, Oracle. All rights reserved.
Used parameter files:
C:\app\Administrator\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
Used EZCONNECT adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTO
COL=TCP)(HOST=9.142.60.187)(PORT=1521)))
TNS-12535: TNS:operation timed out
What is weird, that the current database address is different than 9.142.60.187. sqlnet.ora also does not contain any interesting data:
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
?
ADR_BASE = C:\app\Administrator\product\11.2.0\dbhome_1\log
How can I make my connection to sqlplus available?
What is interesting, I am able to connect to the database using jdbc driver and it works fine.
Your sqlnet.ora is configured to first try to use TNSNAMES (tnsnames.ora in your TNS_ADMIN directed folder as defined in registry, environment variable or taken from default location) to resolve clm to a path through your network mapping SQL*Net to TCP/IP and possibly others.
From your tnsping that seems not to resolve. Therefore, SQL*Net tries the second one: EZCONNECT. See Oracle docs on that one.
Probably you are using somewhere an EZCONNECT connection string like user/pwd#//9.142.60.187 without service name and port. Or my knowledge of EZCONNECT is too simple; somehow it seems to translate clm into //9.142.60.187. That might be explained by the answer to the following question: Do you have a hostname clm in DNS or hosts file mapping to 9.142.60.187?
I do not recommend using EZCONNECT, I always like to have tnsnames.ora hard coded, specifying everything needed. EZCONNECT can work nonetheless.
Can you include IP address of clone in your sample?
Can you include outcome of ping clm and nslookup clm in your sample?
Change the ip address in (HOST=9.142.60.187) to the current ip address of server. May be in the JDBC driver you are using host name instead of ip address and that's why it is working. You can also try giving host name in (HOST=9.142.60.187), e.g if host name is ora_server then change it to (HOST=ora_server)
Since tnsping clm is using EZConnect, your tnsnames.ora does not have an connection alias called CLM, but clm is being resolved as a host name to 9.142.60.187. It's using port 1521 by default as it has no instructions to use a specific port. The connection to that address, or at least that port, is then timing out - it might not exist, it might route somewhere unreachable, or it might be blocked by a firewall.
ping clm should show the same address, and will probably also time out. That host may exist in your hosts file, or is being resolved by DNS, possible with a default domain appended, which ping would also show. If it is the name of your old server, you might need to update your hosts file, which might magically make it start working.
If your database is actually called CLM then you can create an entry in your tnsnames.ora that points to the correct IP address for your listener, which your JDBC connection is already using. Or you can use the EZConnect format as your connect string; something like sqlplus user/password#//<your IP>:1521/<your service name>. You can use lsnrctl services to check the IP address, port and service name if you aren't sure.
If you're on the same host as the database then you don't need to do either; presumably you're currently trying sqlplus user/password#clm, but if ORACLE_SID is set you can just do sqlplus user/password and it will not trouble the listener.

JDBC connection string for clustered environment

I have 2 nodes sql server 2012 installed and clustered and configured Always On feature with Synchronized option.
Clustername: Cluster1
node 1 name: db1
node 2 name: db2
SQL Availability group name: AVG1 has 2 IP address( 10.X.30.7 and 10.X.31.7)
N0w i need to connect to the database from the application( using tomcat 7). Could you please let me know the jdbc syntax how to connect to the database ?
What would be the SQL server name i have to mention in my application?
And Could you please share JDBC connection example string with the above data?
Let me know for more details
So, if you have created an availability group listener, then that is the server name that you have to reference as this is the name that the windows cluster keeps online as a resource so that the servername never changes no matter what replica the availability group is running on.
The connection string also depends on what port you set the listener up on too, but I'm going to assume that you are using a default instance, your listener is called AG-Listener and it is running on port 1433:
jdbc:sqlserver://AG-Listener:1433;databaseName=YourDB;user=MyUserName;password=*****;
You can find many more examples of JDBC connection strings here:
Building the Connection URL

how to connect to oracle rac in asp.net

We just set up the Oracle RAC environment today and we use the single oracle database instance before.
Now we have four nodes in the RAC whose physical IPs are :
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
Also the there are four virtual IPs:
192.168.1.11
192.168.1.22
192.168.1.33
192.168.1.44
And we can connect 192.168.1.1 to use the oracle EM Database Console.
Now I do not know how to set the connection string in my web.config of the asp.net application.
Since when we use the single instance we just set the string like this:
provider=MSDAORA;data source=ORCL;user id=xx;password=xx
The "ORCL" here is the local net service name which can be found in the tnsnames.ora(the machine on which the IIS work).
Any idea?
UPDATE:
I use the oledb api.
You didn't make mention of SCAN address, so, I assume you're not on 11gR2.
Since your OLE data source makes reference to the ORCL connection identifier, that's where you'll want to configure your RAC load balancing and failover, in the tnsnames.ora definition of 'ORCL'.
Something like this ought to do it:
ORCL=
(DESCRIPTION=
(LOAD_BALANCE=ON)
(FAILOVER=ON)
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.11)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.22)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.33)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.44)(PORT=1521))
)
(CONNECT_DATA=(FAILOVER_MODE=(TYPE=SELECT)
(METHOD=BASIC)
)
(SERVICE_NAME=ORCL)
)
)
Hope that helps.

How do I change the IP address on Oracle 10g

What steps do I need to take to change an IP address for Oracle 10g? I cannot connect to the database after going from a dhcp address to a static IP and a reboot.
If the server's IP address changed, these are the first things I would look at:
The TNSNAMES.ORA file on the client -- does it have the IP address hardcoded? If so, change it. Does it use the machine name? If so, does the machine name resolve to the correct IP address on your client machine?
The LISTENER.ORA file on the server -- does it explicitly specify the old IP address as its listening address?
More info please. Do you mean that you have changed the ip address of the host that the database is on and now you have to connect to it from a different macine, or are you having trouble starting the database after the ip change?
... and what error message do you receive?
Most obvious files to check are:
$ORACLE_HOME/network/admin/tnsnames.ora
$ORACLE_HOME/network/admin/listener.ora
Other than that we'd need more info...
I presume you mean the Oracle 10g DB and not the Oracle 10g Application Server?
Does the database start ok?
Is there anything in the database alert log?
Are the error(s) connecting from a client or the server?
What error message(s) do you get?
Can you ping the machine on it's new address (by both name + IP address) From both client + server?
Does a TNSPING work?
Can you connect using SQL*Plus on the server?
What other tool(s) have you tried connecting with?
Update after comment
Please can you post...
Your old ip address (if you know it)
Your new ip address
Your FQDN (e.g. machine.domain.com)
The output of "ipconfig/all" (or equivalent)
Your listener.ora file
The output of "$ORACLE_HOME/bin/lsnrctl start"
The output of "$ORACLE_HOME/bin/lsnrctl status"
Check that LOCAL_LISTENER is not defined (or defined correctly) in the database - it may not be registering correctly because of an incorrect entry here. Also try 'ALTER SYSTEM REGISTER' to attempt to register with the listener (rather than waiting up to 3 minutes for an auto-register). Examine the listener.log to see the instance registered (service_update * ) and 'lsnrctl status' to see if it is there.
Did you change the hostname in DNS? Can you ping the hostname from another machine?

Resources