Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to Oracle database (beta) #394

Closed
9034725985 opened this issue Oct 3, 2018 · 18 comments · Fixed by #452
Closed

Connecting to Oracle database (beta) #394

9034725985 opened this issue Oct 3, 2018 · 18 comments · Fixed by #452

Comments

@9034725985
Copy link
Contributor

ISSUE TYPE

  • Question

SUMMARY

in its default state, I cannot get devilbox to talk to oracle databases out of the box.

I tried adminer from within devilbox but

Looks like some other project has the same open issue?
clue/docker-adminer#15

Goal

I want to connect to oracle from my php code

something like

        $datasource = '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL='.$v_protocol.')(HOST='.$v_host.')(PORT='.$v_port.')))(CONNECT_DATA=(SERVICE_NAME='.$v_server_name.')))';
        $conn = oci_connect("dbadmin", "dbadmin", $datasource);
@cytopia
Copy link
Owner

cytopia commented Oct 4, 2018

Hi @9034725985,

The only missing parts are the PHP modules pdo_oci and/or oci8.

In order to compile them, one must have Oracle Instant Client installed. However, in order to download the Oracle Instant Client, one must manually accept the license first.

I have not enough legal knowledge if this can be bundled inside a Docker container and distributed freely available on Dockerhub.

For that to include in the Devilbox by default, I would require legal advice making it clear that it does not raise any legal issues.


For now, I cannot do much, except keeping this issue open until somebody can point me to a link where the legal implications are clearly stated.

@9034725985
Copy link
Contributor Author

Hi, I couldn't figure out how to install it manually.

I downloaded the zip and placed it in /opt folder on the php container

[email protected] in /shared/httpd $ rsync -av /shared/httpd/instantclient_18_3 /opt/
sending incremental file list
instantclient_18_3/
instantclient_18_3/BASIC_README
instantclient_18_3/adrci
instantclient_18_3/genezi
instantclient_18_3/libclntsh.so -> libclntsh.so.18.1
instantclient_18_3/libclntsh.so.18.1
instantclient_18_3/libclntshcore.so.18.1
instantclient_18_3/libipc1.so
instantclient_18_3/libmql1.so
instantclient_18_3/libnnz18.so
instantclient_18_3/libocci.so -> libocci.so.18.1
instantclient_18_3/libocci.so.18.1
instantclient_18_3/libociei.so
instantclient_18_3/libocijdbc18.so
instantclient_18_3/libons.so
instantclient_18_3/liboramysql18.so
instantclient_18_3/ojdbc8.jar
instantclient_18_3/ucp.jar
instantclient_18_3/uidrvci
instantclient_18_3/xstreams.jar
instantclient_18_3/network/
instantclient_18_3/network/admin/
instantclient_18_3/network/admin/README

sent 232,757,557 bytes received 380 bytes 4,609,068.06 bytes/sec
total size is 232,699,516 speedup is 1.00
[email protected] in /shared/httpd $ ls -a /opt/
./ ../ instantclient_18_3/
[email protected] in /shared/httpd $ ls -a /opt/instantclient_18_3/
./ adrci libclntshcore.so.18.1 libipc1.so libocci.so libocijdbc18.so ojdbc8.jar xstreams.jar
../ BASIC_README libclntsh.so libmql1.so libocci.so.18.1 libons.so ucp.jar
network/ genezi libclntsh.so.18.1 libnnz18.so libocie

libaio1 is already installed

[email protected] in /shared/httpd $ sudo sh -c "echo /opt/oracle/instantclient_18_3 > \

sudo sh -c "echo /opt/oracle/instantclient_18_3 > ^C
[email protected] in /shared/httpd $ sudo sh -c "echo /opt/instantclient_18_3 > /etc/ld.so.conf.d/oracle-instantclient.conf"
[email protected] in /shared/httpd $ sudo ldconfig
[email protected] in /shared/httpd $ exit
exit

I think I am missing something, right?

@cytopia
Copy link
Owner

cytopia commented Oct 5, 2018

You must do the following:

  1. Install the instanclient
  2. Install any other requirements via apt install (until the below line runs without any errors)
  3. Run docker-php-ext-configure oci8 --with-oci8=instantclient,/path/to/instant/client/lib
  4. Run docker-php-ext install oci8

Note: The path in 3. is just an example and must point to the lib dir of the instantclient

@cytopia cytopia self-assigned this Nov 4, 2018
@cytopia
Copy link
Owner

cytopia commented Nov 4, 2018

legal issue

Is anyone able to solve this legal issue and has some reference to backup the claim if this can be bundled or can't be bundled?

@science695
Copy link

I did a quick google search and found a github project, is this related?
https://github.com/oracle/docker-images/tree/master/OracleInstantClient

@cytopia
Copy link
Owner

cytopia commented Nov 17, 2018

@science695 the project als requires you to manually download the OracleInstantClient from the web and then you can proceed building the images: https://github.com/oracle/docker-images/tree/master/OracleInstantClient#building-the-oracle-instant-client-122-image

So I guess I unfortunately cannot ship this here

@science695
Copy link

You could offer instructions on having docker compose use the dockerfile and build the images locally, then if they decided to build the oracle versions, they could accept the EULAs.

@fmanicone
Copy link

i have try to install Instant client but i receve this error

sudo alien -i oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm
Package build failed. Here's the log:
dh_testdir
dh_testdir
dh_testroot
dh_prep
dh_installdirs
dh_installdocs
dh_installchangelogs
find . -maxdepth 1 -mindepth 1 -not -name debian -print0 |
xargs -0 -r -i cp -a {} debian/oracle-instantclient12.1-basiclite
dh_compress
dh_makeshlibs
dh_installdeb
dh_shlibdeps
dpkg-shlibdeps: error: couldn't find library libclntsh.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libocijdbc12.so (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntshcore.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libocijdbc12.so (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: warning: couldn't find library libnnz12.so needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libocijdbc12.so (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntshcore.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libnnz12.so (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: warning: couldn't find library libnnz12.so needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libclntsh.so.12.1 (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntshcore.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libclntsh.so.12.1 (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntsh.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/bin/genezi (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntshcore.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/bin/genezi (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntsh.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/liboramysql12.so (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntshcore.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/liboramysql12.so (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntsh.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libociicus.so (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntshcore.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libociicus.so (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntsh.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/bin/adrci (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: error: couldn't find library libclntshcore.so.12.1 needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/bin/adrci (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: warning: couldn't find library libnnz12.so needed by debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/bin/adrci (ELF format: 'elf64-x86-64'; RPATH: '')
dpkg-shlibdeps: warning: debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libocci.so.12.1 contains an unresolvable reference to symbol OCITypeByRef: it's probably a plugin
dpkg-shlibdeps: warning: 262 other similar warnings have been skipped (use -v to see them all)
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libocijdbc12.so debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libclntsh.so.12.1 debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/bin/genezi debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/liboramysql12.so debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libclntshcore.so.12.1 debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libociicus.so debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/bin/adrci were not linked against libnsl.so.1 (they use none of the library's symbols)
dpkg-shlibdeps: error: cannot continue due to the errors listed above
Note: libraries are not searched in other binary packages that do not have any shlibs or symbols file.
To help dpkg-shlibdeps find private libraries, you might need to use -l.
dh_shlibdeps: dpkg-shlibdeps -Tdebian/oracle-instantclient12.1-basiclite.substvars debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/bin/adrci debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/bin/genezi debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libclntsh.so.12.1 debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libclntshcore.so.12.1 debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libipc1.so debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libmql1.so debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libnnz12.so debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libocci.so.12.1 debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libociicus.so debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libocijdbc12.so debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/libons.so debian/oracle-instantclient12.1-basiclite/usr/lib/oracle/12.1/client64/lib/liboramysql12.so returned exit code 2
debian/rules:17: recipe for target 'binary-arch' failed
make: [binary-arch] Error 2 (ignored)
dh_gencontrol
dpkg-gencontrol: warning: Depends field of package oracle-instantclient12.1-basiclite: unknown substitution variable ${shlibs:Depends}
dpkg-gencontrol: warning: File::FcntlLock not available; using flock which is not NFS-safe
dh_md5sums
dh_builddeb
dpkg-deb: error: control directory has bad permissions 777 (must be >=0755 and <=0775)
dh_builddeb: dpkg-deb --build debian/oracle-instantclient12.1-basiclite .. returned exit code 2
debian/rules:17: recipe for target 'binary-arch' failed
make: *** [binary-arch] Error 1

@cytopia cytopia mentioned this issue Dec 24, 2018
@cytopia
Copy link
Owner

cytopia commented Dec 24, 2018

An alternative I am currently investigating (as I am running into similar legal issues with Microsoft ODBC) is to have a directory where you can add user-defined scripts that are run by the PHP container during startup. This could be for example a script installing the oracle-instantclient.

@cytopia
Copy link
Owner

cytopia commented Dec 24, 2018

@filippomanicone @science695 @9034725985
The feature for custom startup scripts is on the way. I will also provide default examples per PHP version where you (the user) will have to explicitly accept the license. First set of examples will be provided for

  • MsSQL ODBC driver
  • Oracle Instaclient

This will eliminate the current limitations due to legal issues.

Current PR for php-fpm is here: devilbox/docker-php-fpm#78

@cytopia cytopia mentioned this issue Dec 25, 2018
4 tasks
@cytopia
Copy link
Owner

cytopia commented Dec 25, 2018

Devilbox PR is open: #446

You can checkout this git branch: custom-startup-scripts to test it out.

@cytopia
Copy link
Owner

cytopia commented Dec 26, 2018

@9034725985 For now you can already install it manually via:

Install instructions (inside PHP container)

#!/bin/bash
#
# https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/
#

apt-get update -q
DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests alien

# Instantclient (basic lite)
curl -o /tmp/oracle-instantclient18.3-basiclite-18.3.0.0.0-2.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient18.3-basiclite-18.3.0.0.0-2.x86_64.rpm

# Instantclient (devel)
curl -o /tmp/oracle-instantclient18.3-devel-18.3.0.0.0-2.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient18.3-devel-18.3.0.0.0-2.x86_64.rpm

# Install RPMs
alien -i /tmp/oracle-instantclient18.3-basiclite-18.3.0.0.0-2.x86_64.rpm
alien -i /tmp/oracle-instantclient18.3-devel-18.3.0.0.0-2.x86_64.rpm

# Rempve RPMs
rm -f /tmp/oracle-instantclient18.3-basiclite-18.3.0.0.0-2.x86_64.rpm
rm -f /tmp/oracle-instantclient18.3-devel-18.3.0.0.0-2.x86_64.rpm

# Necessary symlinks
ln -s /usr/lib/oracle/18.3/client64/lib/libmql1.so /usr/lib/
ln -s /usr/lib/oracle/18.3/client64/lib/libipc1.so /usr/lib/
ln -s /usr/lib/oracle/18.3/client64/lib/libnnz18.so /usr/lib/
ln -s /usr/lib/oracle/18.3/client64/lib/libons.so /usr/lib/
ln -s /usr/lib/oracle/18.3/client64/lib/libclntshcore.so.18.1 /usr/lib/

# Build and install PHP extension
docker-php-ext-configure oci8 --with-oci8=instantclient
docker-php-ext-install oci8
docker-php-ext-enable oci8

@cytopia
Copy link
Owner

cytopia commented Dec 26, 2018

Updated version (oci and pdo_oci)

#!/bin/bash
#
# https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/
#

#curl -sS http://yum.oracle.com/RPM-GPG-KEY-oracle-ol7 2>/dev/null | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add -

# Install 'alien' to install rpm packages
apt-get update -q
DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests alien

# Instantclient (basic lite)
curl -o /tmp/oracle-instantclient18.3-basiclite-18.3.0.0.0-2.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient18.3-basiclite-18.3.0.0.0-2.x86_64.rpm

# Instantclient (devel)
curl -o /tmp/oracle-instantclient18.3-devel-18.3.0.0.0-2.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient18.3-devel-18.3.0.0.0-2.x86_64.rpm

# Install RPMs
alien -i /tmp/oracle-instantclient18.3-basiclite-18.3.0.0.0-2.x86_64.rpm
alien -i /tmp/oracle-instantclient18.3-devel-18.3.0.0.0-2.x86_64.rpm

# Rempve RPMs
rm -f /tmp/oracle-instantclient18.3-basiclite-18.3.0.0.0-2.x86_64.rpm
rm -f /tmp/oracle-instantclient18.3-devel-18.3.0.0.0-2.x86_64.rpm

# Necessary symlinks
ln -s /usr/lib/oracle/18.3/client64/lib/libmql1.so /usr/lib/
ln -s /usr/lib/oracle/18.3/client64/lib/libipc1.so /usr/lib/
ln -s /usr/lib/oracle/18.3/client64/lib/libnnz18.so /usr/lib/
ln -s /usr/lib/oracle/18.3/client64/lib/libons.so /usr/lib/
ln -s /usr/lib/oracle/18.3/client64/lib/libclntshcore.so.18.1 /usr/lib/

# Build and install PHP extension oci8
docker-php-ext-configure oci8 --with-oci8=instantclient
docker-php-ext-install oci8

# Build and install PHP extension pdo_oci
docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/usr,18.3
docker-php-ext-install pdo_oci

@cytopia
Copy link
Owner

cytopia commented Dec 26, 2018

This will currently fail due to some variable name collisions inside the container (PHP_INI_DIR gets overwritten and assigned a wrong value). The Fix is on the way: devilbox/docker-php-fpm#80

@cytopia
Copy link
Owner

cytopia commented Dec 27, 2018

@9034725985 @science695 @filippomanicone
Its merged and works for PHP 7.0, 7.1, 7.2 and 7.3. Documentation available here: https://devilbox.readthedocs.io/en/latest/advanced/custom-startup-commands.html

Let me know if this works as expected.

@cytopia
Copy link
Owner

cytopia commented Dec 29, 2018

Seems like those yum packages do not require a license to accept anymore (https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/). So I guess I will most likely ship it by default in the PHP images and there won't be any need for autostart the install. (This feature will be preserved anyway)

@cytopia
Copy link
Owner

cytopia commented Jan 2, 2019

Merged and available now. It is disabled by default in env-example. Ensure to read: https://devilbox.readthedocs.io/en/latest/configuration-files/env-file.html#php-modules-disable

@cytopia
Copy link
Owner

cytopia commented Jan 4, 2019

Announcement and follow up discussions here: https://devilbox.discourse.group/t/feature-oracle-database-support/22


mention: @9034725985 @filippomanicone @science695

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants