On Thursday, September 25, 2014 12:22:02 PM UTC+8, Jeremy Evans wrote:
>
> On Wednesday, September 24, 2014 9:02:47 PM UTC-7, henry beh wrote:
>>
>> Hi Jeremy Evans, 
>> Thank for quick response. 
>>
>> This is my setting, where can i configure my another master database?
>> DB=Sequel.connect(:adapter=>'mysql2', :host=>'127.0.0.1',
>>  :database=>'databaseName', :user=>'root', :password=>'password',
>>  :max_connections => 30,
>>  :logger => Logger.new('sequel-log.txt'),
>>  :servers=>{ :default=>proc{|db| {:host=>db.get_master_host}}
>>   })
>>
>> def DB.get_master_host
>>   @current_master_host ||= -1
>>   "master_server#{(@current_master_host+=1)%4}"
>> end
>>
>>
> First, just so you understand, you should only be using the sharding 
> support if all servers you are connecting to have the same schema (i.e. 
> master/slave or partitioned setups only).  If these are two separate 
> databases with different tables, then you want to create two separate 
> Sequel::Database objects (i.e. call Sequel.connect twice).
>
> Assuming you did want to use sharding, what you have looks OK, in that 
> Sequel will rotate connection to the four separate master servers. 
>  However, this assumes you have a multi-master database configuration for 
> MySQL, is that the case?
>
> Jeremy
>



My database is in different schema,   


previously i did like this, so the first connection is default, when i want 
to retrieve the data from database2, it always get it form default database 
, so it cause table not found error
$database1 = Sequel.connect(:adapter=>'mysql2', :host=>'127.0.0.1',
 :database=>'database1 ', :user=>'root', :password=>'1234',
 :max_connections => 30,
 :logger => Logger.new('sequel-log.txt'))

$database2= Sequel.connect(:adapter=>'mysql2', :host=>'127.0.0.1',
 :database=>'database2', :user=>'root', :password=>'1234',
 :max_connections => 30,
 :logger => Logger.new('sequel-log.txt'))

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to