How to repair these errors related to environment variable? - oracle

I'm trying to migrate an oracle database to postgresql, I run the ora2pg command and i get these errors:
root#ubuntu:~# ora2pg
DBI connect('host=localhost;sid=XE;port=1521','HR',...)
failed: ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var or PATH (Windows)
and or NLS settings, permissions, etc. at /usr/local/share/perl/5.24.1/Ora2Pg.pm
line 1491.
FATAL: -1 ... ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var or PATH
(Windows) and or NLS settings, permissions, etc.
Aborting export...
This step is important to start the migration of the database knowing that I configured ORACLE_HOME variable such as LD_LIBRARY_PATH.

Related

Using DBI to connect to Oracle Database in Perl getting ERROR OCIEnvNlsCreate in Windows

In windows machine, When trying to connect to Oracle Database via Perl (strawberry-perl-5.32.0.1) getting below error.
Error:
failed: ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var or PATH (Windows) and or NLS settings, permissions, etc.
Environment variables ORACLE_HOME & PATH are correctly pointing to oracle insta client 12.2 version.
Code shown below:
my $dbh = DBI->connect('dbi:Oracle:host=hostname;service_name=servicename;port=xxx','username','password');
Issue Resolved. ORACLE_HOME needs to be set at system level environment variable rather than account level environment variable

expdp command gives error on Ubuntu server for Oracle Database

I've been trying to export oracle datadump with "expdp" utility in Oracle 18c. I've set the environment variables under ~/.bashrc as following
export ORACLE_HOME=/home/ubuntu/oracle-database-xe-18c-1.0/opt/oracle/product/18c/dbhomeXE
export ORACLE_SID=ORCL
export ORACLE_BASE=/home/ubuntu/oracle-database-xe-18c-1.0/opt/oracle/product
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin
When I enter the command "expdp" in terminal - it keep saying your ORACLE_HOME is not set
root#ip-172-30-xx-xxx:~# expdp
UDE-00013: Message 13 not found; No message file for product=RDBMS, facility=UDE
UDE-00019: You may need to set ORACLE_HOME to your Oracle software directory
I'm new to Oracle Database at present. What could be the possible issue ? Do I need to set environment variables at some other places too ?
Note that Oracle XE is not really supported on Ubuntu: if you really want to use Oracle, install it on Oracle Linux (freely available): you will never see Oracle Database running in real production on Debian or Ubuntu and you will need to use Oracle Linux or RedHat Linux or Suse Linux.
Do not run Oracle utilities as root: you don't need to and it is generally a bad practice on Linux to use root account when it is not needed. Use a non privileged account to run Oracle utilities like SQL*Plus or Data Pump and make sure that your Oracle settings are run for each shell session: putting them in .bash_profile for the right account should be enough.
For this specific error message just make sure that ORACLE_HOME is correctly set: it is likely that your .bashrc has not been run.

Using Ansible playbook to install Oracle12c

I developed a ansible playbook to automate the installation of Oracle 12c Release 2 on CentOS7 and I get a full install. However I cannot start the database instance with startup, I generate the dbca.rsp from a template using the ansible vars in the template to generate it with the command:
- name: create database
command: '{{ oracle_home }}/bin/dbca -silent -createDatabase -sid {{ oracle_sid }} -templateName General_Purpose.dbc -responseFile {{ installation_folder }}/dbca.rsp'
The expected result would be the normal installation and the creation of the file initSID.ora but I'm only getting the init.ora file which as no SID attached to it with out being in it's core and thus I'm not able to start a instance of the database.
When I use sqlplus / as sysdba to connect as the SYSDBA to have privileges ans use startup or STARTUP PFILE ='/oracle/app/oracle/product/12201/dbhome_1/dbs/init.ora';
I get the errors:
ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated
ORA-01262: Stat failed on a file destination directory
Linux-x86_64 Error: 2: No such file or directory
Creating a new PFILE or SPFILE will return the same errors
I suspect is the dbca.rsp that is not generating a good startup file since the others response files are generating the install setup (db_install.rsp) and the linstener (netca.rsp) and the data on those files are being fullfiled correctly.
Note that the templates that I'm using are extracted from a clean and fresh install from oracle12c Release 2 where only the variables contain as values of the variables from the playbook itself like the SID, install location, inventory location, ...

Jenkins - Sqlplus plugin: Cannot connect to oracle database. TNSNAMES.ORA missing

I'm making my way through jenkins but I'm stuck at the moment trying to connect to a remote oracle database in the final step of my job.
Environment vars like ORACLE_HOME and LD_LIBRARY_PATH are ok and sqlplus is running correctly. The connection string seems ok too, I endeed get connected using the same parameters through command line at the same machine, but not inside the job.
Here is the trace:
SQL*Plus: Release 12.2.0.1.0 Production
testing directory /usr/lib/oracle/12.2/client64
--------------------------------------------------------------------------
Using ORACLE_HOME =/usr/lib/oracle/12.2/client64
--------------------------------------------------------------------------
Running defined script on dweb/********#10.10.20.52:1521/*******
Temp script: /tmp/temp-script-15029865208104609348613017529755.sql
--------------------------------------------------------------------------
ORACLE_HOME = /usr/lib/oracle/12.2/client64
LD_LIBRARY_PATH = /usr/lib/oracle/12.2/client64/lib:/usr/lib/oracle/12.2/client64
java.lang.RuntimeException: TNSNAMES.ORA missing!
at org.jenkinsci.plugins.sqlplusscriptrunner.SQLPlusRunner.invoke(SQLPlusRunner.java:231)
at org.jenkinsci.plugins.sqlplusscriptrunner.SQLPlusRunner.invoke(SQLPlusRunner.java:16)
at hudson.FilePath.act(FilePath.java:998)
at hudson.FilePath.act(FilePath.java:976)
at org.jenkinsci.plugins.sqlplusscriptrunner.SQLPlusRunnerBuilder.perform(SQLPlusRunnerBuilder.java:98)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:490)
at hudson.model.Run.execute(Run.java:1735)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
ERROR: TNSNAMES.ORA missing!
Finished: FAILURE
I even tried setting ORACLE_SID environment var with the same result. Any idea?
For the record: Running jenkins from a docker image
https://wiki.jenkins.io/display/JENKINS/SQLPlus+Script+Runner+Plugin
Can it be this plugin (SQLPlusRunner) only supports local naming (TNS)?
In that case, you will have to create a tnsnames.ora file placed in your favorite folder and set export TNS_ADMIN=/my/favorite/folder
cat tnsnames.ora
MY_TNS_ALIAS=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myip)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=MY_SERVICE_NAME)))
Now you can configure the connection
instance: <MY_TNS_ALIAS>
TIP: Make sure you have a succesful connection through sqlplus (CLI) before you continue with jenkins.
For your scenario, I think Oracle Runtime Client would have been a better option to install. Instantclient will work though.
Best of luck!
Bjarte
I know this is an old thread but this may benefit someone. In my case I did need to add the connection string to tnsnames.ora, but not to export TNS_ADMIN.

trying to connect to remote oracle server via cygwin

When I use the command:
sqlplus username#ip_address:1521
I get the error:
ORA-12154: TNS:could not resolve the connect identifier specified
When I set ORACLE_HOME to /cygdrive/c/oracle/product/10.2.0/client_1, I get a different error:
Error 6 initializing SQL*Plus
Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
I can telnet to the server's port 1521.
I also tried the Windows path for ORACLE_HOME but it gives me the same error, also in Cygwin when I change the $PATH = $ORACLE_HOME/bin no command is recognized.
I am able to connect to this database via a excel macro but not using cmd.exe or Cygwin .
If you don't want to use TNSNAMES.ORA to specify the connection parameters you need to provide them on the command line. This works with the widest variety of SQLPlus versions.
sqlplus OraUser/OraPassword#'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=remoteServer)(PORT=1521)))(CONNECT_DATA=(SID=OraSid)))'
Note ' is for Unix and needs to be changed to " for Windows.

Resources