PHP資料庫連接池SQL Relay安裝使用

來源:互聯網
上載者:User
來自: http://blog.csdn.net/21aspnet/article/details/50774684


SQL Relay按照其官網http://sqlrelay.sourceforge.net/index.html上所說是:A powerful database connection management solution.

翻譯為中文也就是說SQL Relay是一個開源的資料庫池串連Proxy 伺服器。

目前SQL Relay支援的資料庫很多:

SQL Relay supports Oracle, MySQL, PostgreSQL, SAP/Sybase, IBM DB2, Informix, Firebird and SQLite databases directly, using the native client API's for those databases.
Support is provided for Microsoft SQL Server via the FreeTDS API.

支援的API也是非常豐富的

Guides: C++, C, C#, Perl, PHP, Python, Ruby, Java, TCL, Erlang, node.js
References: C++, C, C#, Perl, PHP, Python, Ruby, Java, TCL, node.js,

本人講述怎麼在Linux+PHP+FreeDTS環境使用串連池,其實PHP->SQL Relay->FreeDTS->資料庫 這樣的架構。

下面說安裝使用

1.先安裝rudiments

建議盡量安裝新版,舊版可能會報錯需要解決。

# wget http://sourceforge.net/projects/rudiments/files/rudiments/0.28.2/rudiments-0.28.2.tar.gz/download
# tar xvzf rudiments-0.54.tar.gz
# cd rudiments-0.54
# ./configure --prefix=/usr/local/rudiments
# make && make install

2.再安裝sqlrelay

# wget https://sourceforge.net/projects/sqlrelay/files/sqlrelay/0.64/sqlrelay-0.64.tar.gz/download
# tar vxzf sqlrelay-0.64.tar.gz
# cd sqlrelay-0.64
# ./configure --prefix=/usr/local/sqlrelay --with-rudiments-prefix=/usr/local/rudiments --with-freetds-prefix=/usr/local/freetds --with-php-prefix=/usr/local/php


# make && make install

3.修改php設定檔

# vim /usr/local/php/lib/php.ini
增加擴充

extension ="sql_relay.so"
注意:需要確認phpinfo

4.修改freeDTS配置

關於freeDTS的安裝參考此文:http://blog.csdn.net/unix21/article/details/47449901

修改FreeTDS的設定檔freetds.conf
# vim /usr/local/freetds/etc/freetds.conf

加入以下內容

[msdetest]host = 192.168.1.1port =1433tds version = 7.0client charset = UTF-8
不然會中文亂碼,需要對應的編碼類別型GB2312等等。

5.修改SQL Relay的設定檔

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

整個配置非常好理解

 

6.啟動SQL Replay

# export PATH=$PATH:/usr/local/sqlrelay/bin
啟動:

# sqlr-start -id msde

是成功啟動,如果配置錯誤會提示資料庫連不上之類的。

SQL工具

# sqlrsh -id msde


7.php使用串連池

\n";}sqlrcur_free($cur);sqlrcon_free($con);?>

前端網頁從串連池取出資料

SQL Relay的PHP函數API

http://sqlrelay.sourceforge.net/sqlrelay/programming/php.html

參考:http://www.cnblogs.com/zhangjun516/archive/2013/03/12/2955162.html

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.