GI creation fails because sqlplus cannot connect to the database, error ORA-12547: TNS:lost contact
Scenario
Create Oracle RMAN GI
When the GI is being built, it fails with
[2023-08-03 15:10:42.524] [INFO] GI Agent artifactVersion=19.0.0, buildNumber=24
[2023-08-03 15:10:42.529] [INFO] Start RMAN-dump procedure.
[2023-08-03 15:10:42.589] [INFO] Run pre-launch checks on DB (cluster type and ARCHIVELOG mode) using script : db19
[2023-08-03 15:10:42.591] [INFO] Execute bash script: sudo ORACLE_SID=db19 ORACLE_HOME=/data1/home/oracle/product/19 -Eu oracle bash -c '/tmp/00000078.sh db19 /data1/home/oracle/product/19'
[2023-08-03 15:10:45.652] [INFO] Script output:
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Aug 3 15:10:45 2023
Version 19.17.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
ERROR:
ORA-12547: TNS:lost contact
Enter user-name: SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
where <logon> ::= <username>[/<password>][@<connect_identifier>]
<proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
Enter user-name: SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
where <logon> ::= <username>[/<password>][@<connect_identifier>]
<proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
[2023-08-03 15:10:45.696] [INFO] Removed 1 temporary files.
[2023-08-03 15:10:45.702] [ERROR] Oracle errors during pre-launch checks : ORA-12547: TNS:lost contact
[2023-08-03 15:10:45.708] [DEBUG] Failed to unmount file system - umount: /main_pool/aCkEstuO: no mount point specified.
[2023-08-03 15:10:45.710] [INFO] Executing get own process ID by open TCP port 8080 using command line: lsof -i tcp:8080 -t
[2023-08-03 15:10:45.937] [INFO] Executing get lists of processes from open files /main_pool/aCkEstuO, using command line: lsof -t /main_pool/aCkEstuO
[2023-08-03 15:10:45.995] [ERROR] Oracle errors during pre-launch checks : ORA-12547: TNS:lost contact
Cause
This issue occured due to cloning of oracle home and not adjusting ORACLE_BASE directory in ORACLE_HOME/install/orabasetab
#orabasetab file is used to track Oracle Home associated with Oracle Base
/data/home/oracle/product/19:/home/oracle:OraDB19Home1:N:In this example, we may see that oracle home was moved to /data/home/oracle/product/19
but ORACLE_BASE was pointing to incorrect directory /home/oracle
Solution
Need to adjust the file to (/data/home/oracle)
#orabasetab file is used to track Oracle Home associated with Oracle Base
/data/home/oracle/product/19:/data/home/oracle:OraDB19Home1:N:Need to use correct environment variables in a session:
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH