How to modify the application to implement the separation of write/read

How to modify the application to implement the separation of write/read

am 11.03.2010 11:45:07 von Peter Chen

------_=_NextPart_001_01CAC107.EA7AD76F
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi all,=20

=20

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.

=20

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?=20

Please give me some advice, thanks,

Peter


------_=_NextPart_001_01CAC107.EA7AD76F--

Re: How to modify the application to implement the separation of

am 11.03.2010 12:00:50 von Mattia Merzi

2010/3/11 Peter Chen :
[...]
> Does someone have met this problem? How to implement the separation of
> read and write?

please, write us some more details about your application!

For example, if you use java with the Connector/j jdbc driver, you can
enjoy a really
nice feature already implemented in the driver:

http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference -replication-connection.html

Greetings,

Mattia.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

RE: How to modify the application to implement the separation of write/read

am 11.03.2010 12:25:14 von Peter Chen

Hi Mattia,

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?=20

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


-----Original Message-----
From: Mattia Merzi [mailto:mattia.merzi@gmail.com]=20
Sent: 2010Äê3ÔÂ11ÈÕ 19:01
To: Peter Chen
Cc: mysql@lists.mysql.com
Subject: Re: How to modify the application to implement the separation =
of write/read

2010/3/11 Peter Chen :
[...]
> Does someone have met this problem? How to implement the separation of
> read and write?

please, write us some more details about your application!

For example, if you use java with the Connector/j jdbc driver, you can
enjoy a really
nice feature already implemented in the driver:

http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference -replication-=
connection.html

Greetings,

Mattia.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg

Re: How to modify the application to implement the separation of

am 11.03.2010 13:34:22 von Mattia Merzi

2010/3/11 Peter Chen :
[...]
> I am not sure whether do I need to modify something else? Like my application code.
as stated on the webpage you just posted here:

-------
An application signals that it wants a transaction to be read-only by calling
Connection.setReadOnly(true), this replication-aware connection will
use one of the
slave connections, which are load-balanced per-vm using a round-robin scheme
[...]
-------

So, I think you just need to set the readonly flag to "true" on the
connection objects
via the setReadOnly() method. I can't tell you how to handle this
using the hibernate stuffs,
you should probably:
- post this question on an hibernate-related mailing list
- post this question on the Connector/J mailing list (there should be
one, I think! :)
- wait until someone else answers to this mail
- try it by yourself (my suggestion).

Finally, if you look at the user comments on the very same page, you will see an
entry explicitly dedicated to Hibernate, suggesting a way to configure
the persistence.xml file.

Regarding the automatic failover, I suggest you to investigate the
"autoReconnect" and "failOverReadOnly" flags of the Connector/J:
http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference -configuration-properties.html

Greetings, and have a nice coding!

Mattia.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

RE: How to modify the application to implement the separation of write/read

am 11.03.2010 22:20:39 von Daevid Vincent

------=_NextPart_000_012E_01CAC11D.A5183580
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

"c3pO" really? as in Starwars?? ;-)

/me rolls eyes.

> -----Original Message-----
> From: Peter Chen [mailto:peter.chen@aicent.com]
> Sent: Thursday, March 11, 2010 3:25 AM
> To: Mattia Merzi
> Cc: mysql@lists.mysql.com
>
> I use Hibernate to access Mysql, the connection poll is
> c3p0-0.9.0, can I just need to modify the configuration of


------=_NextPart_000_012E_01CAC11D.A5183580--