在Alpine Linux上的Oracle [英] Oracle on Alpine linux

查看:467
本文介绍了在Alpine Linux上的Oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Alpine Linux Docker环境上安装OCI8扩展.尽管有很多地方说它行不通,但也有一些地方说它确实行得通.我有一个3.4版本,由于公司原因,它现在仍然保持这种状态.

I am trying to install OCI8 extension on my Alpine Linux Docker environment. Although there are several places saying it won't work, there are some which say it actually does. I have a 3.4 version and for corporate reasons it is staying like that for now.

我已经在Docker conf中完成了此操作:

I have done this within my Docker conf:

# Install Oracle Client and build OCI8 (Oracel Command Interface 8 - PHP extension)
USER root
ENV LD_LIBRARY_PATH=/usr/local/instantclient
ENV ORACLE_HOME=/usr/local/instantclient

RUN apk update && apk upgrade
RUN apk add musl-dev libaio autoconf && apk add --update make

## Unzip Instant Client v12
RUN pecl channel-update pecl.php.net
COPY instantclient_12_2.zip /var/www/html/instantclient_12_2.zip
RUN unzip -d /usr/local/ /var/www/html/instantclient_12_2.zip
RUN ln -s /usr/local/instantclient_12_2 /${ORACLE_HOME} && \
    ln -s /${ORACLE_HOME}/libclntsh.so.* /${ORACLE_HOME}/libclntsh.so && \
    ln -s /${ORACLE_HOME}/libocci.so.* /${ORACLE_HOME}/libocci.so && \
    ln -s /${ORACLE_HOME}/lib* /usr/lib && \
    ln -s /${ORACLE_HOME}/sqlplus /usr/bin/sqlplus &&\
    ln -s /usr/lib/libnsl.so.2.0.0  /usr/lib/libnsl.so.1

RUN apk add gcc; exit 0 # This has a history of failing sometimes

RUN echo "instantclient,/usr/local/instantclient" | pecl install oci8 &&\
    echo 'extension=oci8.so' > /usr/local/etc/php/conf.d/30-oci8.ini &&\
    rm -rf /tmp/*.zip /var/cache/apk/* /tmp/pear/

现在构建通过了,看起来还可以,但是当我执行php -v时,我得到以下信息:

Now the build passes, and it looks okay, however when I do a php -v I am getting the following:

PHP警告:PHP启动:无法加载动态库 '/usr/local/lib/php/extensions/no-debug-non-zts-20160303/oci8.so'- 加载共享库libnsl.so.1时出错:没有这样的文件或目录 (由/usr/local/instantclient/libclntsh.so.12.1要求)中的未知 第0行

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20160303/oci8.so' - Error loading shared library libnsl.so.1: No such file or directory (needed by /usr/local/instantclient/libclntsh.so.12.1) in Unknown on line 0

PHP版本为7.1.12.

我尝试做的是apk add libnsl,但这会向我返回此错误:

What I've tried is doing apk add libnsl but this returns me this error:

错误:约束无法满足:so:libtirpc.so.3(丢失):

ERROR: unsatisfiable constraints: so:libtirpc.so.3 (missing):

因此,我还尝试添加apk add libtirpc-dev("plain" libtirpc无法用于我的版本或其他功能),但这并没有改变.

So I tried also adding apk add libtirpc-dev (the 'plain' libtirpc isn't available for my version or something), but that changed nothing.

有任何线索吗?

推荐答案

我建议使用Oracle支持的操作系统,这样可以避免黑客Alpine的麻烦以及在关键时刻不会崩溃的不确定性.因此,您可以放心,您的业务不会受到负面影响.尝试 https://github.com/oracle/docker-images/tree/master /OracleInstantClient

I'd recommend using an operating system supported by Oracle, thus avoiding the headache of hacking Alpine and the uncertainty that it won't fall over at a critical time. And thus giving you some confidence your business won't be negatively impacted. Try https://github.com/oracle/docker-images/tree/master/OracleInstantClient

其他评论

  • 在使用Instant Client时不要设置ORACLE_HOME.该变量是 进行完整的软件安装.
  • 使用ldconfig设置系统库路径,请参阅 Instant Client安装说明,例如此处.
  • 使用Instant Client 19,它可以连接到12.2可以使用的相同数据库版本. (19实际上是新版本控制系统中已重命名的终端12.2版本)
  • 使用Oracle Linux Docker映像的优点是它将下载并安装19 Instant Client,而无需您手动进行下载.
  • Don't set ORACLE_HOME when using Instant Client. That variable is for full software installs.
  • Use ldconfig to set the system library path, see the Instant Client installation instructions e.g. here.
  • Use Instant Client 19, which can connect to the same DB versions that 12.2 can. (19 is really the renamed terminal 12.2 release in the new versioning system)
  • Using Oracle Linux Docker images has the advantage that it will download and install the 19 Instant Client without you having to manually do the download.

请参见此博客有关其使用的苗条" Oracle Linux容器的信息.

See this blog for info about the 'slim' Oracle Linux container it uses.

这篇关于在Alpine Linux上的Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆