Unable to connect to Oracle database with provider on MWAA - oracle

I am currently using MWAA (Airflow version: 2.0.2) to build the data pipeline. cx_Oracle throws the exception while I am trying to connect to Oracle database (Oracle 10g) with the provider.
Execute after install apache-airflow[oracle]==2.0.2
cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory"
Upload plugins.zip with instant_client_12_1 directory within, and overwrite the get_conn function of OracleHook to execute init_oracle_client function that specify the directory of instant client
cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libmql1.so: cannot open shared object file: No such file or directory"
but the file do exist under the folder (as below)
-rw-rw-r-- 1 martin martin 29404 Jun 23 07:30 adrci
-rw-rw-r-- 1 martin martin 450 Jun 23 07:30 BASIC_LITE_README
-rw-rw-r-- 1 martin martin 43944 Jun 23 07:30 genezi
lrwxrwxrwx 1 martin martin 21 Jun 23 07:35 libclntshcore.so -> libclntshcore.so.12.1
-rw-rw-r-- 1 martin martin 6990875 Jun 23 07:30 libclntshcore.so.12.1
lrwxrwxrwx 1 martin martin 17 Jun 23 07:35 libclntsh.so -> libclntsh.so.12.1
-rw-rw-r-- 1 martin martin 58793741 Jun 23 07:30 libclntsh.so.12.1
-rw-rw-r-- 1 martin martin 1768370 Jun 23 07:30 libipc1.so
-rw-rw-r-- 1 martin martin 544150 Jun 23 07:30 libmql1.so
-rw-rw-r-- 1 martin martin 6213011 Jun 23 07:30 libnnz12.so
lrwxrwxrwx 1 martin martin 15 Jun 23 07:35 libocci.so -> libocci.so.12.1
-rw-rw-r-- 1 martin martin 2576030 Jun 23 07:30 libocci.so.12.1
-rw-rw-r-- 1 martin martin 6005681 Jun 23 07:30 libociicus.so
-rw-rw-r-- 1 martin martin 156353 Jun 23 07:30 libocijdbc12.so
-rw-rw-r-- 1 martin martin 337137 Jun 23 07:30 libons.so
-rw-rw-r-- 1 martin martin 118491 Jun 23 07:30 liboramysql12.so
-rw-rw-r-- 1 martin martin 3692096 Jun 23 07:30 ojdbc6.jar
-rw-rw-r-- 1 martin martin 3698857 Jun 23 07:30 ojdbc7.jar
-rw-rw-r-- 1 martin martin 227410 Jun 23 07:30 uidrvci
-rw-rw-r-- 1 martin martin 71202 Jun 23 07:30 xstreams.jar
I don't think it is possible to update environment variables like LD_LIBRARY_PATH on MWAA, any ideas? Thanks.

I have solved the issue by following this instruction
Download Oracle instant client and put it into plugins folder.
Execute following Docker commands (I was using Docker Desktop on Windows)
docker pull amazonlinux
docker run -it amazonlinux:latest /bin/bash
yum -y install libaio
cd /lib64
rm libaio.so.1
ln -s ./libaio.so.1.0.1 libaio.so.1 # This is critical for me to change the symbol link to relative path
Execute the following commands from Powershell (as I was using Docker Desktop on Windows)
docker container ls # copy the container ID that you created on step#2
docker cp {docker ID}:/lib64/libaio.so.1 C:\dir\of\oracle\instant\client\under\plugins
docker cp {docker ID}:/lib64/libaio.so.1.0.0 C:\dir\of\oracle\instant\client\under\plugins
docker cp {docker ID}:/lib64/libaio.so.1.0.1 C:\dir\of\oracle\instant\client\under\plugins
Create __ init __.py under plugins folder, or append following codes if you already have one
from airflow.plugins_manager import AirflowPlugin
import os
# the [instantclient] below depends on your folder structure
os.environ["LD_LIBRARY_PATH"]='/usr/local/airflow/plugins/instantclient'
os.environ["DPI_DEBUG_LEVEL"]="64"
class EnvVarPlugin(AirflowPlugin):
name = 'env_var_plugin'
Zip the plugins to plugins.zip
Upload plugins.zip to S3
Update MWAA to use the updated plugins.zip
DONE~

The problem can be solved by building airflow docker with oracle client. Please check the thread

Related

Gradle is changing my zip file from resources

Welcome,
I would like to add custom resources - a zip file to my project
Gradle is somehow changing my zip file and I don't know how and why
Sources:
total 11576
drwxr-xr-x 5 user staff 160 Nov 1 00:39 .
drwxr-xr-x 7 user staff 224 Oct 31 14:17 ..
-rw-r--r-- 1 user staff 5900938 Oct 31 15:33 Custom.zip
-rw-r--r-- 1 user staff 16452 Nov 1 00:35 swagger.yaml.zip
-rw-r--r-- 1 user staff 12 Nov 1 00:39 test.txt
Build directory
total 20880
drwxr-xr-x 5 user staff 160 Nov 1 00:39 .
drwxr-xr-x 7 user staff 224 Nov 1 00:39 ..
-rw-r--r-- 1 user staff 10652091 Nov 1 00:39 Custom.zip
-rw-r--r-- 1 user staff 29355 Nov 1 00:39 swagger.yaml.zip
-rw-r--r-- 1 user staff 12 Nov 1 00:39 test.txt
Zip files in build resources have more bytes and are not valid zips anymore, simple text file is not changed
Environment
Gradle 7.5
------------------------------------------------------------
Build time: 2022-07-14 12:48:15 UTC
Revision: c7db7b958189ad2b0c1472b6fe663e6d654a5103
Kotlin: 1.6.21
Groovy: 3.0.10
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.4.1 (Azul Systems, Inc. 17.0.4.1+1-LTS)
OS: Mac OS X 12.6 aarch64

BPF SDK path does not exist

I'm following the Anchor docs here, but I keep getting this error...
BPF SDK path does not exist: /Users/herbie/.cargo/bin/sdk/bpf: No such file or directory (os error 2)
I ran ls -al /Users/herbie/.cargo/bin and got this output:
total 239152
drwxr-xr-x 17 herbie staff 544 31 Jan 16:55 .
drwxr-xr-x 9 herbie staff 288 13 Dec 11:58 ..
-rwxr-xr-x 1 herbie staff 12574724 31 Jan 16:49 anchor
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 cargo
-rwxr-xr-x 1 herbie staff 7578989 14 Dec 14:05 cargo-build-bpf
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 cargo-clippy
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 cargo-fmt
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 cargo-miri
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 clippy-driver
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 rls
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 rust-gdb
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 rust-lldb
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 rustc
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 rustdoc
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 rustfmt
-rwxr-xr-x 12 herbie staff 8521112 31 Jan 16:55 rustup
Haven't found much online, and have never heard of BPF before...
It's unclear when you're getting the error during the installation, but here's a few things to try:
be sure that you're using an up-to-date version of Rust stable with rustup update stable
check that you're using the Solana CLI version designated in the docs using solana -V
run cargo build-bpf on the hello world Rust application: https://github.com/solana-labs/example-helloworld/tree/master/src/program-rust
For more reference, BPF is the bytecode format used by on-chain programs with Solana. You can find some more info at the links contained within https://docs.solana.com/developing/on-chain-programs/overview#berkeley-packet-filter-bpf
Try removing the solana cache before running your code. It worked for me. Basically, the BPF SDK hasn't been installed accurately.
rm -rf ~/.cache/solana/*
After deleting the solana cache run. It should download the BPF SDK again
solana build

Native library lz4 not available for Spark

How do I add the lz4 native libraries for use by Spark workers?
I have tried to add them via both LD_LIBRARY_PATH and ( as shown - but no accepted or even upvoted answer - in Apache Spark Native Libraries ) - in SPARK_LIBRARY_PATH. They are not working: we get:
java.lang.RuntimeException: native lz4 library not available
at org.apache.hadoop.io.compress.Lz4Codec.getCompressorType(Lz4Codec.java:125)
at org.apache.hadoop.io.compress.CodecPool.getCompressor(CodecPool.java:150)
at org.apache.hadoop.io.compress.CodecPool.getCompressor(CodecPool.java:165)
at org.apache.hadoop.io.SequenceFile$Writer.init(SequenceFile.java:1201)
at org.apache.hadoop.io.SequenceFile$Writer.<init>(SequenceFile.java:1094)
at org.apache.hadoop.io.SequenceFile$BlockCompressWriter.<init>(SequenceFile.java:1444)
at org.apache.hadoop.io.SequenceFile.createWriter(SequenceFile.java:277)
at BIDMat.HDFSIO.writeThing(HDFSIO.scala:96)
Here is the LD_LIBRARY_PATH
$echo $LD_LIBRARY_PATH
/usr/local/Cellar/lz4/r131/lib:/usr/local/Cellar/hadoop/2.7.2/libexec/lib:
12:15:35/BIDMach_Spark $ll /usr/local/Cellar/lz4/r131/lib
and the contents of the lz4 related entry:
$ll /usr/local/Cellar/lz4/r131/lib
total 528
-r--r--r-- 1 macuser admin 71144 Sep 21 2015 liblz4.a
drwxr-xr-x 7 macuser admin 238 Sep 21 2015 .
drwxr-xr-x 3 macuser admin 102 Jun 13 10:41 pkgconfig
-r--r--r-- 1 macuser admin 64120 Jun 13 10:41 liblz4.dylib
-r--r--r-- 1 macuser admin 64120 Jun 13 10:41 liblz4.1.dylib
-r--r--r-- 1 macuser admin 64120 Jun 13 10:41 liblz4.1.7.1.dylib
Update your hadoop jars and should work perfectly fine.

How do I import an existing Liferay project into the Liferay Developer Studio

I am using Liferay Developer Studio
Version: 2.2.2.201504240205-ga3a, and
I have an existing Liferay project that
is made up of multiple portlets. I have
the SDK installed, and I have deployed
some test portlets (with Maven/Ant). How
do I create 1 war file that deploys
the portlets correctly?
If your existing project is an SDK project (e.g. utilizes Ant), it's probably contained in an SDK folder. Use "Window/Preferences/Liferay/Installed Plugin SDKs" to make this SDK known to Liferay. Then just use "File/Import/Liferay Projects from Plugins SDK" to import your project.
If it's a maven plugin try if it's "File/Import/Liferay Project from existing source" or just a plain import of a maven project.
You can also download the plugins(which has many plugins and examples) source code, stick the code in the plugins folder of the source. This will make the parent in the ant task the sdk, then import the project, so your projects folder will be next to other plugins.
/Liferays/plugins-src/liferay-plugins-6.2.0-ga1/portlets$ ls -la
total 408
drwxr-xr-x 96 jimmy jimmy 4096 Nov 2 16:00 .
drwxr-xr-x 14 jimmy jimmy 4096 May 23 2014 ..
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 akismet-portlet
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 ams-portlet
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 analog-clock-portlet
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 bible-gateway-portlet
-rw-r--r-- 1 jimmy jimmy 730 Nov 1 2013 build-common-portlet.xml
-rw-r--r-- 1 jimmy jimmy 8926 Nov 1 2013 build.xml
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 calendar-portlet
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 chat-portlet
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 chat-video-portlet
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 contacts-portlet
-rw-r--r-- 1 jimmy jimmy 922 Nov 1 2013 create.bat
-rwxr-xr-x 1 jimmy jimmy 778 Nov 1 2013 create.sh
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 ddl-form-portlet
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 events-display-portlet
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 flash-portlet
drwxr-xr-x 4 jimmy jimmy 4096 May 23 2014 google-adsense-portlet
place the folder that contains the code here.

Error using DBD::Oracle with instantclient 11.2

I Want to use perl module DBD::Oracle on Mac OS X 10.8.
I installed DBI through CPAN.
Downloaded the Oracle instant client 11.2 (basic, sqlplus and jdk).
Extracted it to /usr/local/oracle.
$ ls /usr/local/oracle/instantclient_11_2/
BASIC_README libnnz11.dylib ojdbc6.jar
SQLPLUS_README libocci.dylib.11.1 sdk
adrci libociei.dylib sqlplus
genezi libocijdbc11.dylib uidrvci
glogin.sql libsqlplus.dylib xstreams.jar
libclntsh.dylib libsqlplusic.dylib
libclntsh.dylib.11.1 ojdbc5.jar
Then installed DBD::Oracle.
Now when I want to use DBD::Oracle it gives an error.
install_driver(Oracle) failed: Can't load '/Library/Perl/5.12/darwin-thread-multi-
2level/auto/DBD/Oracle/Oracle.bundle' for module DBD::Oracle:
dlopen(/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/Oracle/Oracle.bundle, 1):
Library not loaded: /ade/b/2649109290/oracle/rdbms/lib/libclntsh.dylib.11.1
Referenced from: /Library/Perl/5.12/darwin-thread-multi-
2level/auto/DBD/Oracle/Oracle.bundle
Reason: image not found at /System/Library/Perl/5.12/darwin-thread-multi-
2level/DynaLoader.pm line 204.
I have DYLD_LIBRARY_PATH=/usr/local/oracle/instaclient_11_2
I have not a clue what I am doing wrong.
SOLVED:
I got the same error when trying to run sqlplus. I added my oracle client directory to my global PATH variable and it is working now.
Saw they did the same in this tutorial: http://www.janhellevik.no/?p=521
Check this one out: perl DBD::Oracle Module installtion
Above information is about Linux Environment. But you might get some clues on how to go about configuring DBD::Oracle on MAC OSX.
On linux, you need "Basic, SQLPLUS and Devel" binaries of the oracle instant client. Here is the directory listing on my Linux box:
# pwd
/usr/lib/oracle/11.2/client64/lib
# ls -l
total 185232
-rw-r--r-- 1 root root 368 Sep 17 2011 glogin.sql
lrwxrwxrwx 1 root root 17 Jul 9 2012 libclntsh.so -> libclntsh.so.11.1
-rw-r--r-- 1 root root 52761218 Sep 17 2011 libclntsh.so.11.1
-rw-r--r-- 1 root root 7955322 Sep 17 2011 libnnz11.so
lrwxrwxrwx 1 root root 15 Jul 9 2012 libocci.so -> libocci.so.11.1
-rw-r--r-- 1 root root 1971762 Sep 17 2011 libocci.so.11.1
-rw-r--r-- 1 root root 118408281 Sep 17 2011 libociei.so
-rw-r--r-- 1 root root 164836 Sep 17 2011 libocijdbc11.so
-rw-r--r-- 1 root root 1503303 Sep 17 2011 libsqlplusic.so
-rw-r--r-- 1 root root 1477446 Sep 17 2011 libsqlplus.so
-rw-r--r-- 1 root root 2095661 Sep 17 2011 ojdbc5.jar
-rw-r--r-- 1 root root 2714016 Sep 17 2011 ojdbc6.jar
-rw-r--r-- 1 root root 300666 Sep 17 2011 ottclasses.zip
-rw-r--r-- 1 root root 66779 Sep 17 2011 xstreams.jar
and here is the list of oracle instant client RPMs that I installed:
# rpm -qa | grep -i oracle
oracle-instantclient11.2-basic-11.2.0.3.0-1
oracle-instantclient11.2-devel-11.2.0.3.0-1
oracle-instantclient11.2-sqlplus-11.2.0.3.0-1
Hope this helps.

Resources