[rt-users] Read only db for select (cluster on the cheap)
Roy El-Hames
rfh at pipex.net
Thu Oct 26 11:45:12 EDT 2006
Hi;
RT 3.6.1 and and a pair of mysql 5 servers
I 've setup my system so it talks to a replicated db pair, where the
slave for read only operations, now most of my select actions
(Mytickets, MyRequests, Results.html) uses the slave server , so normal
ticketing operations are not effected by long searches, I am putting the
changes below to you smart people to see if anyone can spot something I
missed that may cause problems down the line , I would appreciate any ideas.
I have made the following changes:
in RT_SiteConfig added the following variables:
# {{{ Read Only Database Configuration
Set($RO_DatabaseHost , 'slave db');
#The name of the database user (inside the database)
Set($RO_DatabaseUser , 'rt user');
# Password the DatabaseUser should use to access the database
Set($RO_DatabasePassword , 'rt password');
# The name of the RT's database on your database server
Set($RO_DatabaseName , 'rt3');
Changed in SearchBuilder.pm, the _Init function to :
# {{{ sub _Init
sub _Init {
my $self = shift;
$RT::Logger->err("Getting to SearchBuilder.pm");
$self->{'user'} = shift;
my $ro_db = shift;
unless(defined($self->CurrentUser)) {
use Carp;
Carp::confess("$self was created without a CurrentUser");
$RT::Logger->err("$self was created without a CurrentUser");
return(0);
}
#CHANGE => USED FOR 2nd DB FOR SEARCH ELEMENTS
if ($ro_db) {
$RT::Logger->err("Getting to SearchBuilder.pm and highlted ro_db");
my $handle = DBIx::SearchBuilder::Handle->new();
$handle->Connect( 'Driver' => "mysql",
'Database' => $RT::RO_DatabaseName,
'Host' => $RT::RO_DatabaseHost,
'User' => $RT::RO_DatabaseUser,
'Password' => $RT::RO_DatabasePassword);
$self->SUPER::_Init( 'Handle' => $handle);
# Setup al;ternate DB handle in config and use tha tisntead
} else {
$self->SUPER::_Init( 'Handle' => $RT::Handle);
}
## END CHANGE
}
# }}}
And applied changes to where ever there are read only operations (ie
MyTickets as example ) changing :
$MyTickets = new RT::Tickets ($session{'CurrentUser'});
to:
$MyTickets = RT::Tickets->new($session{'CurrentUser'},"+ro");
Roy
More information about the rt-users
mailing list