I setup an EC2 instance and RDS instance. Then installed oracle instance client on EC2 instance. After that I managed to do sqlplus and connect with database from EC2 instance. To do that I created a tnsnames.ora file and enter the service details of the database.
I can do,
sqlplus user/password@db_alias
But I cannot do, (This gives ERROR: ORA-12154: TNS:could not resolve the connect identifier specified)
ssh username@ip sqlplus user/password@db_alias
Password less ssh also configured. And I'm doing the ssh to the current machine itself. Any thought would be helpful.
Addition to the details. Since I installed oracle instance client, tnsping command is not available. I achieve this by adding following function to the .profile file.
whence tnsping >/dev/null 2>&1 ||
tnsping() {
sqlplus -L -s x/x@$1 </dev/null |
grep ORA- |
(grep -v ORA-01017 || echo OK)
}
tnsnames.ora? Your environment may be missing a$TNS_ADMINvariable pointing to its location when you ssh in like that, though it seems to have the$PATHand other Oracle variables already. - Alex PooleTNS_ADMIN- manually in your shell before you callssh? Or in an environment file (.bashrc, .prifle etc.) so it is picked up by the new session thatsqlplusis being run in? - Alex Poole.profilehas an entry to source.bashrcand.bashrchas those records. I cannot think a reason for not setting the environment variables. - Amith Chinthaka