SQL relay open-source database pool connection Proxy Server

Source: Internet
Author: User
Tags ibm db2 sybase

I. What is SQL relay?

SQL relay is an open source database pool connected to the Proxy Server


Ii. What databases does SQL relay support?

* Oracle
* MySQL
* mSQL
* PostgreSQL
* Sybase
* MS SQL Server
* IBM DB2
* Interbase
* Sybase
* SQLite
* Lago
* ODBC
* MS Access


3. installation and configuration;

Don't talk nonsense, start to Install SQL relay, to the http://sqlrelay.sourceforge.net/to download the corresponding software
To Install SQL relay, you need to install rudiments first, which can be found in the http://sqlrelay.sourceforge.net/download.html


1. Install rudiments:

# tar vxzf rudiments-0.28.2.tar.gz
# cd rudiments-0.28.2
# ./configure --prefix=/usr/local/rudiments
# make
# make install

Now, rudiments installation is complete.


2. Install SQL relay:

# Tar vxzf sqlrelay-0.36.4.tar.gz
# Cd sqlrelay-0.36.4
#. /Configure -- prefix =/usr/local/sqlrelay -- With-rudiments-Prefix =/usr/local/rudiments -- With-mysql-Prefix = MySQL installation path -- With-freetds-Prefix = freetds installation path -- With-Oracle-home = Oracle installation path -- With-PHP-Prefix = PHP installation path
# Make
# Make install

After the installation is complete, the above compilation parameters are set based on individual needs. Because I need Oracle sqlserver MySQL at the same time, so many parameters are added.

3. Set PHP:

Modify PHP. ini

extension_dir = "./"

Modify the preceding content:

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20050922"

It is modified according to the PHP installation path. Not every version of PHP uses this path.
Add the following content to PhP. ini:

extension=sql_relay.so

Next, we will introduce how SQL relay connects to SQL Server.
Modify the configuration file freetds. conf of freetds.
Add the following content:

[msde]
host = 172.16.20.203
port =1433
tds version = 8.0
client charset = GB2312

Modify as needed


4. Modify the SQL relay configuration file

# cd /usr/local/sqlrelay/etc
# cp sqlrelay.conf.example sqlrelay.conf

Change the content of sqlrelay. conf:

<?xml version="1.0"?>
< !DOCTYPE instances SYSTEM "sqlrelay.dtd">
< instances>
< instance id="msdetest" port="9000" socket="/tmp/msdetest.socket" dbase="freetds" connections="5" maxconnections="10" maxqueuelength="0" growby="1" ttl="60" endofsession="commit" sessiontimeout="5" runasuser="nobody" runasgroup="nobody" cursors="5" authtier="listener" handoff="pass">
< users>
< user user="sa" password="sa"/>
< /users>
< connections>
< connection connectionid="msdetest" string="server=msde;db=pubs;user=sa;password=sa;" metric="1"/>
< /connections>
< /instance>
< /instances>


4. Start SQL relay and test it;


1. Start SQL Relay

# export PATH=$PATH:/usr/local/sqlrelay/bin
# sqlr-start -id msdetest


2. Use SQL tools:

# sqlrsh -id msdetest

You can enter SQL statements directly.

Stop SQL relay:

# sqlr-stop msdetest


3. Test PHP:

Write a PHP file with the following content:

<?
$con=sqlrcon_alloc("msdetest",9000,"/tmp/msdetest.socket","sa","sa",0,1);
$cur=sqlrcur_alloc($con);
sqlrcur_sendQuery($cur,"select * from t_gifts");
for ($row=0; $row<sqlrcur_rowCount($cur); $row++) {
for ($col=0; $col<sqlrcur_colCount($cur); $col++) {
echo sqlrcur_getField($cur,$row,$col);
echo ",";
}
echo "<br>\n";
}
sqlrcur_free($cur);
sqlrcon_free($con);
?>

Run the PHP file to check whether data exists.
End of full text ~~

 

Reference: http://hi.baidu.com/mrvsumbeujeinxe/item/8ba0c60888cf47c490571896

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.