How to modify the application to implement the separation of write/read
"mqboss"<[email protected]> Fri, 12 Mar 2010 09:36:33 +0800
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Message-ID | <[email protected]> |
--__=_Part_Boundary_002_016385.010687 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Hi all, I want to test the mode of Master/Slave for mysql. Also I want to separate the write and read of sql requests, that is, I want to make Slave server of mysql to handle read requests and make Master server to handle write requests. I want to know how to modify the code of my application. Some people suggest me to use mysql-proxy to access mysql server. I checked the version of mysql-proxy, I found the latest version is just 0.8.0. Does someone have met this problem? How to implement the separation of read and write? Please give me some advice. I use java with the Connector/L jdbc driver, I checked the webpage of http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-replication-connection.html, it suggests to use "ReplicationDriver" to replace common driver. I use Hibernate to access Mysql, the connection poll is c3p0-0.9.0, can I just need to modify the configuration of JDBC URL, like "jdbc:mysql:replication://master,slave1,slave2,slave3/test" to implement the separation of write/read? After configuring JDBC URL like this, can I make the query SQL requests to access the Slave server, the update/insert/delete SQL requests to access the Master server, and if the Master server is shotdown, the driver will failover to the Slave server? I am not sure whether do I need to modify something else? Like my application code. Expect your reply. Thanks, Peter --__=_Part_Boundary_002_016385.010687--