MySQL

Hi there,

Could you please help me to find some documentation about using Ruby and
several MySQL servers with one way replication there.

Main idea is to use Masters server for inserting/changing data and Slave
server for selecting data from DB.

Thanks a lot.

ActiveRecord – the part of Rails responsible for talking to the
database – does not support the configuration of multiple data
sources for the purposes of segmenting reads and writes and directing
them to different mysql servers on that basis, at this time, as far as
I know.

There is a submitted but to-date-not-accepted patch to do this. Its
author considered it “alpha” code at the time. I’ve tested it a bit.
It does function. If you are interested in pursuing it, I can provide
patched base.rb and connection_adapter.rb files for ActiveRecord that
work circa Rails 1.1.5. The original is here:
http://wrath.rubyonrails.org/pipermail/rails-core/2006-July/002019.html

Alternatively, you could use multi-master replication. If you go this
route you’ll need to address issues pertaining to auto_increment
collisions. This is fairly easy with MySQL 5 as it has global
variables for auto_increment_increment and auto_increment_offset.

In a multi-master setup you can load balance the connections coming
from Rails to MySQL in at least three different ways: 1. a hardware
load balancer, 2. soft load balancing configuration utilizing the
IP_VS kernel support in Linux (built in, if you have a fairly recent
distribution), or 3. by manipulating the relevant Rails application
startup config (database.yml) on a per-rails-server-instance (or per-
application-deployment-instance) basis.


benjamin

On Mar 12, 4:24 am, Max M. [email protected]

Here’s an alternative–SQLRelay:
http://sqlrelay.sourceforge.net/sqlrelay/dropin/mysql.html

It leaves the connection pooling and segmenting reads vs. writes to
the driver (which in turn delegates to the real driver). I haven’t
used it, but this is the direction I was planning on going after
talking it over with a few people (and considering such an AR patch).

Let us know how it works out for you if you give it a shot.

seth

ActiveRecord – the part of Rails responsible for talking to the
database – does not support the configuration of multiple data
sources for the purposes of segmenting reads and writes and directing
them to different mysql servers on that basis, at this time, as far as
I know.

[skip]

Alternatively, you could use multi-master replication. If you go this
route you’ll need to address issues pertaining to auto_increment
collisions. This is fairly easy with MySQL 5 as it has global
variables for auto_increment_increment and auto_increment_offset.

[skip]


benjamin

Hi,

Thanks for this guide light. I will think about patch.

As About two-way replication then I thought about it.
Unfortunately I do not have experience with it. I am only using one-way
(old approved method).
Could please you share your experience if you have used MySQL with
two-way replication and give me your feedback how it works.

Thanks again.

Has anyone tried the beta MySQL-HA (High Availability) stuff with
Rails?

We currently have a Dual Master MySQL setup but are basically just
pointing everything to one of the servers right now…

MySQL-HA project site - http://sourceforge.net/projects/mysql-ha/
MySQL-HA home page - http://www.seriema-systems.com/mysql-ha/
MySQL-HA blog - http://gnuserland.blogspot.com/

On Mar 12, 5:24 am, Max M. [email protected]

benjamin wrote:

ActiveRecord – the part of Rails responsible for talking to the
database – does not support the configuration of multiple data
sources for the purposes of segmenting reads and writes and directing
them to different mysql servers on that basis, at this time, as far as
I know.

There is a submitted but to-date-not-accepted patch to do this. Its
author considered it “alpha” code at the time. I’ve tested it a bit.
It does function. If you are interested in pursuing it, I can provide
patched base.rb and connection_adapter.rb files for ActiveRecord that
work circa Rails 1.1.5. The original is here:
http://wrath.rubyonrails.org/pipermail/rails-core/2006-July/002019.html

Hello Benjamin,

I have started to implementing this solution and faced with problem :frowning:

First of all I am not able to apply patch you provided.
(I am using Rails 1.1.6). So patch should be rather different. I will
very appreciate if you can guide me where can I find additional
documentation about it, also may be you can provide me base and
connection_adapter files for Rails 1.1.5.
Thanks a lot.

Seth Fitzsimmons wrote:

Here’s an alternative–SQLRelay:
http://sqlrelay.sourceforge.net/sqlrelay/dropin/mysql.html

It leaves the connection pooling and segmenting reads vs. writes to
the driver (which in turn delegates to the real driver). I haven’t
used it, but this is the direction I was planning on going after
talking it over with a few people (and considering such an AR patch).

Let us know how it works out for you if you give it a shot.

seth

Hi,

Thanks you for this solution too. :slight_smile: If I will use it of course I get
my feedback to you.

Max M. wrote:

Hi,

Thanks for this guide light. I will think about patch.

As About two-way replication then I thought about it.
Unfortunately I do not have experience with it. I am only using one-way
(old approved method).
Could please you share your experience if you have used MySQL with
two-way replication and give me your feedback how it works.

Thanks again.

Forgot to tell you my feedback.

We have remade source code to use MySQL master for write and MySQL slave
to reed data. :frowning:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs