Oracle, PHP and DSN

We have set up an oracle db (oracle 10g) and have the DSN of:

    define('SQ_CONF_DB_DSN', 'oci8://matrix:matrix@10.2.200.211');
    define('SQ_CONF_DB2_DSN', 'oci8://matrix:matrix@10.2.200.211');
    define('SQ_CONF_DB3_DSN', 'oci8://matrix_secondary:matrix@10.2.200.211');
    define('SQ_CONF_DBCACHE_DSN', 'oci8://matrix:matrix@10.2.200.211');


but on step02 get:

[quote]+------------------------------------------------+
| MySource Error |
|------------------------------------------------|
| DB Error: extension not found |
+------------------------------------------------+[/quote]

PHP info reports:

[attachment=205:phpoci.jpg]


So either something is wrong with php or we can't actually get to the database for one reason or another.

:blink: any help appreciated. phpoci.jpg (15.5 KB)

PHP needs to be compiled with OCI8 support. You should check the PHP documentation on how to do that.


I just knew you'd say that...but is my DSN correct?

Not really -- it doesn't look like a valid Oracle DSN to me, but I'm not an Oracle expert. Usually, you'd have something like oci8://user:password@SID where the SID is defined in a tnsnames.ora file. Or, you could create a complete DSN by embedding the full TNS reference. Your Oracle DBAs should be able to provide a proper DSN for you.


well I'm going by the example on your install pages:

[quote]oci8://matrix:password@dbserver.example.com[/quote]

http://matrix.squiz.net/resources/installation/oracle-setup

That example requires a tnsnames.ora configured correctly to support the dbserver.example.com identifier. Setting up Matrix with Oracle requires onsite Oracle DBA support, so that they can configure Oracle appropriately. It's far more complicated than a PostgreSQL configuration.

AVI is right....you need a current TNSNAMES.ORA file that contains the reference (sid) to the oracle database you wish to use. The TNSNAMES file is used by the oracle client (installed on your application server) to connect to oracle databases. The TNSNANES.ORA file is typically installed in <oracle_client_home>/network/ADMIN.

Here is an example of an entry in the TNSNAMES.ORA......

============
TNSNAMES extract
============

MATRIX.SERVER.AU =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (COMMUNITY = TCP.server.au)(PROTOCOL = TCP)(Host = database.server.au)(Port = 1536))
)
(CONNECT_DATA =
(SID = MATRIX)
(GLOBAL_NAME = MATRIX.server.au)
)
)

=========
DSN EXAMPLE
=========

oci8://username:password@MATRIX.server.au

I would not recommend using an IP address to resolve an oracle database connection, you would only do this in a situation where an ORACLE client has not been installed (and you do not want to be in that situation)..... :lol: .....Avi is right, ORACLE installations are typically are complex and require a good working knowledge of ORACLE.....

Hope this helps,
-=A=-

You will also need to ensure that Apache has at least the following environment variables configured, or else you'll still get DB: Connect Failed errors:


ORACLE_SID

ORACLE_HOME

TNS_ADMIN

Hello, thanks for the replies.


I have php with oci8 running, I have oracle instant client and a tnsnames.ora file in place and the DSN in the correct format.



Have not got the apache bit done though - did not realise that.



:lol:


If you're using the Instant Client (and remember to use the 32-bit version, regardless of OS, as PHP only works properly against the 32-bit Instant Client), you can point ORACLE_HOME and TNS_ADMIN to the Instant Client directory and put your tnsnames.ora file in there as well. The ORACLE_SID will obviously be whatever the SID of your Oracle instance is.

[quote]You will also need to ensure that Apache has at least the following environment variables configured, or else you'll still get DB: Connect Failed errors:


ORACLE_SID

ORACLE_HOME

TNS_ADMIN[/quote]





ummm, slightly confused where these go. I've added ORACLE_HOME and TNS_ADMIN paths to my bash_profile


If you've rolled your own Apache, you should have a /path/to/apache/bin/envvars script that Apache reads when it starts up. You can set them in there. If you're using a packaged version of Apache, you'll have to find the appropriate script. On RHEL/CentOS, that's usually in /etc/sysconfig/httpd (I think -- I'm not 100% sure and I don't have a RHEL box handy to check).

Double-posting to say that (and correct me if I'm wrong) it sounds like you don't have a lot of Oracle experience, which is going to make your life very difficult. All the scripts will need to be aware of these environment variables, including the cronjobs. You also need to tweak your Oracle instances to support Matrix properly. It's way more tedious than using PostgreSQL and we only recommend it in Oracle-only shops that have fulltime Oracle DBAs to babysit the database.


Thanks Avi, you are correct I have no experience of Oracle we took on a Oracle DBA the other week though

Problem I have now is my CentOS install now has a problem on reboot of 'No Inittab Found' :blink:' /> <img src='http://forums.matrix.squiz.net/public/style_emoticons/<#EMO_DIR#>/sad.gif' class='bbc_emoticon' alt=':(

Is there a specific reason why you're going Oracle over PostgreSQL?


Corporate nonsense, I have been told "it sounds better when we say we have an oracle powered intranet" :o personally I'd go with Postgres

Well, it's usually a corporate decision. Oracle is going to cost you guys a lot more money over time than PostgreSQL.