Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

VirtualBox - Connect from host as "system" works, but "sys as sysdba" doesn't.

Daniel NadlerMay 14 2021

Hello,
I use a Mac as my host. I installed VirtualBox, Developer Day package on the VM. I setup the tnsnames.ora file on my Mac. I can connect using "sqlplus system/oracle@orcl" successfully.. But once I am in, I try "conn sys as sysdba" and it fails from the host (Mac). I get the following ORA error.

client_hostname.local:/Users/user1 $ sqlplus system/oracle@orcl

SQL*Plus: Release 19.0.0.0.0 - Production on Fri May 14 14:04:55 2021
Version 19.8.0.0.0

Copyright (c) 1982, 2020, Oracle. All rights reserved.

Last Successful login time: Fri May 14 2021 14:03:48 -05:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> conn sys as sysdba;
Enter password:
ERROR:
ORA-12545: Connect failed because target host or object does not exist


Warning: You are no longer connected to ORACLE.
SQL>

From the VM, everything works... I connect as system first, once in, I "conn sys as sysdba" and it connects successfully. I can also "sqlplus sys as sysdba" and it works fine from the VM machine.

[oracle@dragonvm ~]$ sqlplus system/oracle@orcl

SQL*Plus: Release 19.0.0.0.0 - Production on Fri May 14 15:13:45 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle. All rights reserved.

Last Successful login time: Fri May 14 2021 15:04:55 -04:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> conn sys as sysdba;
Enter password:
Connected.
SQL>

I have included the tnsnames.ora information below from both the host and the VM. The listener from the VM also.
MAC HOST tnsnames.ora file

cat $TNS_ADMIN/tnsnames.ora

ORCLCDB=db_hostname:1521/orclcdb
ORCL=
 (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = db_hostname)(PORT = 1521))
  (CONNECT_DATA =
   (SERVER = DEDICATED)
   (SERVICE_NAME = orcl)
  )
 )

VM tnsnames.ora file (default, unchanged)

cat $TNS_ADMIN/tnsnames.ora

ORCLCDB=localhost:1521/orclcdb
ORCL=
 (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
  (CONNECT_DATA =
   (SERVER = DEDICATED)
   (SERVICE_NAME = orcl)
  )
 )

I have instantclient_19_8 installed on my Mac, but there is no "tnsping" to test with... standard "ping" works when pinging the hostname of the VM from the HOST.

client_hostname.local:/Users/user1 $ ping db_hostname
PING dragonvm (192.168.56.103): 56 data bytes
64 bytes from 192.168.56.103: icmp_seq=0 ttl=64 time=0.479 ms
64 bytes from 192.168.56.103: icmp_seq=1 ttl=64 time=0.516 ms
64 bytes from 192.168.56.103: icmp_seq=2 ttl=64 time=0.300 ms
64 bytes from 192.168.56.103: icmp_seq=3 ttl=64 time=0.346 ms
64 bytes from 192.168.56.103: icmp_seq=4 ttl=64 time=0.556 ms
64 bytes from 192.168.56.103: icmp_seq=5 ttl=64 time=0.641 ms
64 bytes from 192.168.56.103: icmp_seq=6 ttl=64 time=0.412 ms
^C
--- dragonvm ping statistics ---
7 packets transmitted, 7 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.300/0.464/0.641/0.111 ms
client_hostname.local:/Users/user1 $

The VM listener is configured as... this is how it was by default.

[oracle@db_hostname ~]$ cat $TNS_ADMIN/listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
  (SID_DESC =
  (GLOBAL_DBNAME = orclcdb)
  (SID_NAME = orclcdb)
  (ORACLE_HOME = /u01/app/oracle/product/version/db_1)
  )
  )

LISTENER =
  (DESCRIPTION_LIST =
  (DESCRIPTION =
  (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
  (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
  )
  )

#HOSTNAME by pluggable not working rstriction or configuration error.
DEFAULT_SERVICE_LISTENER = (orclcdb)

[oracle@db_hostname ~]$

The VM machine IP address.

[oracle@db_hostname ~]$ nmcli -p

eth1: connected to Wired connection 1
  "Intel 82540EM"
  ethernet (e1000), xx:xx:xx:xx:xx:xx, hw, mtu 1500
  inet4 192.168.56.103/24
  route4 192.168.56.0/24
  route6 fe80::/64


I set the hostname of the VM machine to "db_hostname".

h[oracle@db_hostname ~]$ cat /etc/hostname
db_hostname
[oracle@db_hostname ~]$

[oracle@db_hostname ~]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

127.0.0.1 vbgeneric vbgeneric.localdomain
127.0.0.1 db_hostname

The HOST /etc/hosts file... setting the VM hostname to it's IP address.

client_hostname.local:/Users/user1 $ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1	localhost
192.168.56.103	db_hostname
client_hostname.local:/Users/user1 $

I'm sure it something simple, I am just not seeing it and I've spent hours on this trying to get this to work.
If there is any other information to help in resolving this, please let me know.
Thank you,
Daniel

This post has been answered by The Real Rob the Relic on May 15 2021
Jump to Answer
Comments
Post Details
Added on May 14 2021
6 comments
952 views