Magento with MySQL Master/Slave Replication

piaoling  2011-11-11 11:35:22
Magento with MySQL Master/Slave Replication
 
lingrlongr
Jr. Member
 
Total Posts:  18
Joined:  2009-06-07
 

I searched this forum and found posts, but no answers (nor replies, for that matter).

I set up my local.xml file to enable the default_setup and default_read database connections.  It seems that no read requests ever hit the slave server during a read.  To test, I stopped MySQL on the slave.  The frontend continued to work.  Not sure if there’s a built-in fall back in case the default_read server fails.

We are using the Community edition of Magento.  Does this functionality only exists for the Enterprise version or something? 

Keith

 
Magento Community Magento Community
Magento Community
Magento Community
 
David Smart
Jr. Member
 
Total Posts:  12
Joined:  2010-06-29
 

Did you ever get this issue solved?

I’m currently experiencing the same problem

 
Magento Community Magento Community
Magento Community
Magento Community
 
lingrlongr
Jr. Member
 
Total Posts:  18
Joined:  2009-06-07
 
David Smart - 09 March 2011 05:32 AM

Did you ever get this issue solved? 

I’m currently experiencing the same problem

Hi David,

Yes.  I did get this working after searching this forum a bit.  I’ll show you my config.  I have reverted since then though because we found weird behaviors with it.  For example, when searching the store, the first search would fail.  But if you clicked search again, it would work.  Unfortunately, I didn’t see that much of a performance increase using the master/slave setup.

1.  Disable Cache Managment

2.  Update <magento_install_dir>/app/etc/local.xml

<default_setup>
    <
connection>
        <
host><![CDATA[192.168.1.100]]></host>
        <
username><![CDATA[magento_user]]></username>
        <
password><![CDATA[magento_pass]]></password>
        <
dbname><![CDATA[magento]]></dbname>
        <
active>1</active>
    </
connection>
</
default_setup>
<
default_read>
    <
connection>
        <use/>
        <
host><![CDATA[192.168.1.101]]></host>
        <
username><![CDATA[magento_user]]></username>
        <
password><![CDATA[magento_pass]]></password>
        <
dbname><![CDATA[magento]]></dbname>
        <
type>pdo_mysql</type>
        <
model>mysql4</model>
        <
initStatements>SET NAMES utf8</initStatements>
        <
active>1</active>
    </
connection>
</
default_read>

Just replace host, username, password, and dbname.

3.  Enable Cache Management.

Hope that helps.

Keith

 
Magento Community Magento Community
Magento Community
Magento Community
 
David Smart
Jr. Member
 
Total Posts:  12
Joined:  2010-06-29
 

Hi Keith,

I’ve tried that with no luck, thanks for the help though!

 
Magento Community Magento Community
Magento Community
Magento Community
 
David Smart
Jr. Member
 
Total Posts:  12
Joined:  2010-06-29
 

Actually, it did, I missed

<use/>
thank you!
 
Magento Community Magento Community
Magento Community
Magento Community
 
lingrlongr
Jr. Member
 
Total Posts:  18
Joined:  2009-06-07
 
David Smart - 09 March 2011 06:09 AM

Actually, it did, I missed

<use/>
thank you!

Yay!  Yea, that was something I found that magically made it work.  Apparently, that “clears” the already declared <connection> tag, I think.  I found that information here: http://www.magentocommerce.com/boards/viewthread/7397/

Glad it worked.

Keith

 
Magento Community Magento Community
Magento Community
Magento Community
 
David Smart
Jr. Member
 
Total Posts:  12
Joined:  2010-06-29
 

Hmm,

I can see an increase in performance, but I’m seeing that search issue as well, have to investigate further

thanks 
Dave

 
Magento Community Magento Community
Magento Community
Magento Community
 
David Smart
Jr. Member
 
Total Posts:  12
Joined:  2010-06-29
 

I managed to ‘fix’ the search:

in app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php I changed both instances of : 

$this->_getReadAdapter()
to 
$this->_getWriteAdapter()

Bit of a hack, but at least it’s searching correctly! I should probably move it to the local folder to prevent overwriting.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lingrlongr
Jr. Member
 
Total Posts:  18
Joined:  2009-06-07
 
David Smart - 09 March 2011 07:37 AM

I managed to ‘fix’ the search: 

in app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php I changed both instances of : 

$this->_getReadAdapter()
to 
$this->_getWriteAdapter()

Bit of a hack, but at least it’s searching correctly! I should probably move it to the local folder to prevent overwriting.

Nice!  I’ll have to give that a try.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top

 

类别 :  magento(258)  |  浏览(6089)  |  评论(0)
发表评论(评论将通过邮件发给作者):

Email: