« Distro Name for RHEL in phpsysinfo | 首 页 | 关于 PHP Session 的 Time out 和有效设置 Session 时间限制的一些小结 »

2007 年 06 月 20 日

Oracle 10g + PHP 4 在连接数据库上时的一系列问题

| 分类: 服务器技术 Server Tech. |

  • OS: Red Hat Enterprise Linux ES 3.0 + Oracle 10g

  • 前提:在同一台服务器中安装 PHP 和 Oracle 10g, 并且不用 instant client 进行连接。

  • PHP configure:
  • #! /bin/sh
    #
    # Created by configure

    './configure' \
    '--without-mysql' \
    '--with-apxs2=/usr/local/apache2/bin/apxs' \
    '--with-openssl' \
    '--enable-mbstring=all' \
    '--enable-mbregex' \
    '--with-zlib' \
    '--with-dom' \
    '--with-oci8=/opt/app/oracle/product/10.2 ' \
    '--enable-sigchild' \
    "$@"

  • 结论: 
    1)权限设置在与本地 Oracle 10g 连接时非常重要。
    2)使用 oracle 10g 和 php 4.4.x 进行编译有很大难度, 所以建议使用 oracle instantclient 10.x 和 php 4.4.x 或者 oracle 10g 和 PHP 5。

    修改后的 php 4.4.x 的 configure

    #! /bin/sh
    #
    # Created by configure

    './configure' \
    '--with-oci8-instant-client=/usr/local/kdx/instantclient10_1' \
    '--enable-sigchild' \
    '--with-apxs2=/usr/local/apache2/bin/apxs' \
    '--enable-mbstring=all' \
    '--enable-mbregex' \
    '--without-mysql' \
    '--with-zlib' \
    '--with-dom' \
    '--with-openssl' \
    "$@"


  • -------- 以下是详细纪录 -------

  • 问题:
    ORA-12546: TNS:permission denied
  • 解决方法:(参考)

    chown -R oracle:oinstall /opt
    chmod -R 775 /opt
    (注意,这是在 /opt 下只有 oracle 的情况下才可以运行。)

  • 问题:
    OCISessionBegin: ORA-01034: ORACLE not available ORA-27121: unable to determine size of shared memory segment Linux Error: 13: Permission denied in xxxx/database/connection.php on line 101
  • 解决方法:

    $ cd $ORACLE_HOME/bin
    $ chmod 6751 oracle
    -rwsr-s--x 1 oracle oinstall 93300099 Sep 14 2006 oracle

    以上方法可以用 em 来连接上 oracle 10g , 但是使用 php 连接的时候,却出现网页不能显示的问题。

    [Fri Jun 22 20:01:21 2007] [notice] child pid 32342 exit signal Segmentation fault (11)
    [Fri Jun 22 20:01:21 2007] [notice] child pid 32343 exit signal Segmentation fault (11)

    搜索了 php 的官方论坛, 发现在 CVII. Oracle 関数 中有如下关于 oracle 10g 和 php 4.4.x 连接的问题的阐述:

    We were having performance issues caused by Segmentation Faults on pages using Oracle.

    An example of the Seg faults appearing in Apache's error log is:
    *** glibc detected *** free(): invalid next size (fast): 0x0969ef30 ***
    [Mon May 08 09:41:51 2006] [notice] child pid 3065 exit signal Aborted (6)

    OR

    [Mon May 08 09:48:58 2006] [notice] child pid 4747 exit signal Segmentation fault (11)

    Our issue was due to a problem with OCI8 module in PHP (latest version 4.4.2).

    Our solution involved recompiling PHP with the latest PECL OCI8 extension which can be downloaded from:
    http://pecl.php.net/package/oci8

    All segmentation faults and performance issues stopped once PHP was recompiled with OCI8 1.2.1.

    If you are experience performance issues and/or seg faults I would recommend recompiling PHP with the latest stable OCI8 extension.

    estoreic (note from 15-May-2006 10:54) is right.

    there seems to be a problem with the oci8-api-functions in php 4.4.x.

    there are error-messages like these in the error_log:
    child pid 22297 exit signal Segmentation fault (11)
    *** glibc detected *** double free or corruption (out): 0x00000000019f4730 ***
    *** glibc detected *** double free or corruption (!prev): 0x0000000001111d90 ***
    *** glibc detected *** corrupted double-linked list: 0x0000000001111d50 ***

    using php 4.4.x with oracle 10.x is impossible, until you do the following:
    1. download latest oci8-package from http://pecl.php.net/package/oci8
    2. extract package somewhere
    3. go to php-4.4.x-source directory
    4. rm -rf ext/oci8
    5. cp extraceted oci8-1.2.x directory to/as ext/oci8
    6. make distclean
    7. ./buildconf --force
    8. ./.configure (with the options you need)
    9. make
    10. only for x86_64:
    create pear-install.ini:
    -----------------------------------------------
    [PHP]

    memory_limit = 128M ; Maximum amount of memory a script may consume (8MB)
    ------------------------------------------------

    11. edit Makefile:
    replace:
    PEAR_INSTALL_FLAGS = -n -dshort_open_tag=0 -dsafe_mode=0
    with:
    PEAR_INSTALL_FLAGS = -cpear-install.ini -dshort_open_tag=0 -dsafe_mode=0

    12. make install

    have fun!
    oracle connections will work now!

    Regarding issues with glibc "double free or corruption" or "free(): invalid next size" errors in error_log with PHP4 (PHP 4.4.7 is still afftected by this issue), and in addition to Rainer Klier´s notes below, if you´re using autoconf 2.5 (default on Redhat ES/CentOS 4.4 and 5, for example), you must delete PHP´s "configure" script before running "buildconf --force", or it will do nothing. After that, you´ll need to use PHP 5 oci8 syntax with configure: --oci8=instantclient,/path/to/instantclient

    Only after this you´ll be able to compile PHP, but it´s a guaranteed fix - and, just to enforce Rainer´s point (as opposed to what has been said in other places), no need to rise memory limit and edit Makefile on x86-32. Good luck. ;)

    但是还是有很多


    资料:

  • ORA-12546: TNS: アクセス権が拒否されました
  • 原因: 権限が不足しているため、ユーザーが要求した操作を実行できません。
    処置: 必要な権限を取得して、再試行してください。
  • OTN's Oracle & PHP installguide - for Developer CD v2 (B18183-01)
  • ORA-12546が発生する
  • RE:ORA-27121が発生してDBに接続できません
  • Re: ORA-27121: unable to determine size of shared memory segment

  • The Underground PHP and Oracle® Manual
  • (END)

    引用

    引用本文的 URL:
    http://weblog.kreny.com/cgi-bin/mt/mt-tb.cgi/257.

    发表评论

    (如果您还为在此成功留言,也许是因为需要管理员逐一审核留言内容后放可看到您的评论。请稍后并感谢您的耐心等待。)

    阅览更多文章请访问 首页过去的存档