Este post também está disponível em:
English

When you try to connect to sqlplus / as sysdba you get the error ORA-12547: TNS:lost contact. Below are a few fixes that have happened to me.
oracle@orcleserver [scprbr07] /home/oracle> sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Dec 2 01:54:17 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-12547: TNS:lost contact
Enter user-name: ^C
oracle@orcleserver [scprbr07] /home/oracle>
SQLSolution 1:
ORACLE_HOME is configured incorrectly, as you can see below, there is an extra “/” in the line.
oracle@oracleserver [scprbr07] /home/oracle> cat /etc/oratab
#Backup file is /u01/app/oracle/crsdata/oracleserver/output/oratab.bak.oracleserver.oracle line added by Agent
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
+ASM:/u01/app/19.0.0.0/grid:N
scprbr07:/u01/app/oracle/product/19.3.0.0/dbhome_1/:N # line added by Agent
BashCorrect the entry in /etc/oratab and try the connection again.
oracle@oracleserver [scprbr07] /home/oracle> . oraenv
ORACLE_SID = [scprbr07] ? scprbr07
The Oracle base remains unchanged with value /u01/app/oracle
oracle@oracleserver [scprbr07] /home/oracle> sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Dec 2 02:06:33 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL>
SQLIf the bank was registered in srvctl, you’ll probably need to correct it there too.
oracle@oracleserver [scprbr07] /u01/app/oracle/diag/rdbms/scprbr07/scprbr07/trace> srvctl config database -d scprbr07
Database unique name: scprbr07
Database name:
Oracle home: /u01/app/oracle/product/19.3.0.0/dbhome_1/
Oracle user: oracle
Spfile: +DATA/SCPRBR07/PARAMETERFILE/spfile.257.1145122115
Password file: +DATA/SCPRBR07/PASSWORD/pwdscprbr07.278.1088971723
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups: DATA
Services: scprbr07_serv
OSDBA group:
OSOPER group:
Database instance: scprbr07
BashMaking the change.
srvctl modify database -d scprbr07 -o /u01/app/oracle/product/19.3.0.0/dbhome_1
BashIf it’s wrong in srvctl, you’ll have to stop / start the database to bring it up with the correct variable.
You can see which variable the database is using with the command below.
ps -ef | grep pmon
oracle 42456 1 0 Dec01 ? 00:00:01 asm_pmon_+ASM
oracle 51812 1 0 02:35 ? 00:00:00 ora_pmon_scprbr07 <<-- pegar o PID
oracle 55320 43687 0 02:42 pts/0 00:00:00 grep --color=auto pmon
xargs -0 -L1 -a /proc/51812/environ | grep ORACLE_HOME <<<--- usar o PID aqui
ORACLE_HOME=/u01/app/oracle/product/19.3.0.0/dbhome_1/
BashSolução 2:
The permissions on the oracle binaries are incorrect.
cd $ORACLE_HOME/bin
ls -ltr oracle
-rwxr-xr-x 1 oracle oinstall 441253104 Dec 2 02:03 oracle
BashChange the permissions of the oracle file as shown below.
chmod 6751 oracle
ls -ltr oracle
-rwsr-s--x 1 oracle oinstall 441253104 Dec 2 02:03 oracle
Bash