OpenNetAdmin

Track. Automate. Configure.

Home About Features Community Develop
Download this project as a tar.gz file

connect to remote database

dahlinger

30-09-2009 05:30:58

Hi,
I want to install the php stuff on another server than the database.

Is there any documentation on how to change the connect string to teh database? Is this an configuration item (including password) or do I have to change the php code?

I am new here!

Michael

Matt

30-09-2009 14:05:16

Well the documentation on this is slim but it is an easy process.

Simply edit the file /opt/ona/www/local/config/database_settings.inc.php

You can change the host, password, database name etc etc. You can even set up a secondary database server for redundancy if you have your mysql set up to synchronize on the back end (ONS wont keep them synced). If you only use one database server, either make both entries point to the same server or comment out the secondary section.

The file format should be pretty self explanatory.

When doing the initial install you should also be able to provide the same information to point it to remote database servers. I understand that in your case however you probably started local and are now needing to move the data to another location.

Hope that helps. And for reference, here is what the database_settings file looks like:


<?php
// Define database context names
// The concept here is that we need multiple copies of the entire IP
// database to support different "contexts". For example - the current
// database scheme doesn't allow a single server to have both an
// internal and external DNS name .. or an IP address in two different
// MPLS networks. By having multiple IP Database instances we can leave
// all the code the same and simply switch the "context", or database,
// we are using.
//
// I use this array as a place to store the MySQL database info as well,
// to keep all database connection info in one place.
//
// Note: after adding a new context here you also need to add the details
// for that new context in functions_db.php as well.
// Note: the context used is determined by the value of $conf['mysql_context']
// at the time functions_db.php is included.
// Note: Available ADODB types:
// mysql, mysqlt, oracle, oci8, mssql, postgres, sybase, vfp, access, ibase and many others.
$db_context = array (


// Type: -- The type should be a transactional database to support proper data rollbacks.
'mysqlt' => array(
// Name:
'default' => array(
'description' => 'Website metadata',
'primary' => array(
'db_type' => 'mysqlt', // using mysqlt for transaction support
'db_host' => 'localhost',
'db_login' => 'ona_sys',
'db_passwd' => '',
'db_database' => 'ona',
'db_debug' => false,
),
// You can use this to connect to a secondary server that is
// syncronized on the back end.
'secondary' => array(
'db_type' => 'mysqlt',
'db_host' => 'localhost',
'db_login' => 'ona_sys',
'db_passwd' => '',
'db_database' => 'ona',
'db_debug' => false,
),
),
),
);
?>

dahlinger

01-10-2009 05:23:08

Thank you very much. Now I understand.

The problem was that I did not find the $db_context definition, because the file config/database_settings.inc.php was not yet created (did not run the run_installer, because the database was already created).

Now I can play with the connect string.

Do you see any problems running ona on an Oracle databse?

I have already migrated the database to oracle. Now there are a lot of smaller errors, but apart from the check on a mysql library in the very beginning, do you completely base your application on the AdoDB model? Or are there some dirty tricks which use some mysql features directly?

I will keep you up to date on the Oracle migration.

Michael

Matt

01-10-2009 14:41:15

ahh yes.. the installer creates that file during install. Glad you got that going.

As far as running ONA with an oracle backend. I would expect it to work. The old original version used to run on oracle. Since I re-wrote things I focused only on mysql since I do not have access to oracle anymore and am too lazy to set up a box for it. ONA is using AdoDB completely (ok, mostly) so it should have no trouble with oracle. I do expect that there will be a few issues as I may have done things that are not fully SQL generic for adodb to pass to oracle correctly? I think those can be fixed pretty easily. In general the core of ONA should be perfectly compatible with any database that adodb supports. It does however require a database with transactions to function reliably.

The installer scripts are strictly setup for mysql and would not function with other databases. but it sounds like you manually did most of what it does anyway.

Yes, please let me know how it goes with Oracle. I expect it to work fine but as I said, there may be a few things to tweak. I will help in any way I can and maybe we can get the Oracle support more directly built in.

Thanks!

dahlinger

02-10-2009 01:00:50

Hi,
I succeeded to connect to the Oracle database from the php Web-Interface.

I see a lot of small issues I will try to tackle in the next days.

Maybe you can rewrite some stuff that it will be more generic, I will send to you my corrected version if it is running.

Michael

Matt

02-10-2009 07:52:17

Good news.

Don't hesitate to post error messages etc so I can help work through them. As you find things I will definitely incorporate them back into the main code. Also, I assume you used one of the mysql to oracle sql converters? I'm just curious so that sql can be made available and maintained as part of this.

dahlinger

06-10-2009 10:42:48

Hi Matt,
I have a lot of trouble with the adodb implementation for Oracle.

a) nrows = 1 does not work with SelectLimit. I fixed the driver
b) oci8 and ocipo driver completeley behave differently, e.g. the ADODB_ASSOC_CASE feature (switching field names to lower case) si not implemneted in oci8, whereas in ocipo the function SelectLimit does not return any data,.... I try to fix this as well.
c) I used Oracle SQLDEveloper tool (free java tool) for conversion. This worked fine and created a nice Oracle database except for columns with the following name: level, number and file are not allowed as Oracle column names. I changed to number_, level_ and file_ and change the code.

I still try to get the adodb stuff running, but it is a little bit painful.

Just an intermediate status report! Michael

Matt

07-10-2009 08:58:34

hmm interesting.. I used to use the oci8 driver and didnt have problems.. that was with oracle 9i and early 10g stuff.

One thing we might try is to upgrade adodb.. I'm currently packaging v4.96a.. they are up to 5.06 or so. That might have some bug fixes in it that will help?

Also the oci8po driver might be the one to use and hopefully the other things you found can be worked around.

As far as the reserved column names, I'll see about fixing that.. it would make sense to have those be something else so it wont conflict.

Anyway.. just some thoughts.. I may need to get my own oracle instance to test with so I can try and help..