Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
How do I make Magento use two MySQL Servers
 
WildWire
Jr. Member
 
Total Posts:  15
Joined:  2008-03-31
 

I setup a replicated mysql server in magento.. following this blog post: http://www.magentocommerce.com/blog/comments/performance-is-key-notes-on-magentos-performance/

I added this into my /app/etc/local.xml

<default_setup>
                <
connection>
                    <
host><![CDATA[hostname1]]></host>
                    <
username><![CDATA[user]]></username>
                    <
password><![CDATA[pass]]></password>
                    <
dbname><![CDATA[magento]]></dbname>
                    <
active>1</active>
                </
connection>
            </
default_setup>
        <
default_read>
                <
connection>
                    <
host><![CDATA[hostname2]]></host>
                    <
username><![CDATA[user]]></username>
                    <
password><![CDATA[pass]]></password>
                    <
dbname><![CDATA[magento]]></dbname>
                    <
active>2</active>
                </
connection>
            </
default_read>

After watching load on the secondary mysql server.. I can see no queries are sent to it.  Caching is off.  What am I missing?

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1771
Joined:  2007-08-07
Los Angeles
 

Try this:

<default_setup>
                <
connection>
                    <
host><![CDATA[hostname1]]></host>
                    <
username><![CDATA[user]]></username>
                    <
password><![CDATA[pass]]></password>
                    <
dbname><![CDATA[magento]]></dbname>
                    <
active>1</active>
                </
connection>
            </
default_setup>
        <
default_read>
                <
connection>
                    <use /> <!-- 
to clear already declared tag -->
                    <
host><![CDATA[hostname2]]></host>
                    <
username><![CDATA[user]]></username>
                    <
password><![CDATA[pass]]></password>
                    <
dbname><![CDATA[magento]]></dbname>
                    <
active>1</active> <!-- not 2its just a flag -->
                </
connection>
            </
default_read>

 Signature 

- I would love to change the world, but they won’t give me the source code -

 
Magento Community Magento Community
Magento Community
Magento Community
 
WildWire
Jr. Member
 
Total Posts:  15
Joined:  2008-03-31
 

Thanks for the quick reply Moshe.  Oh and setting the active flag to ‘2’ was just to see what kind of cool errors I could summon wink

Adding <use /> created this error for me.
Fatal error: Class name must be a valid object or a string in C:\wlanmaul\app\code\core\Mage\Core\Model\Resource.php on line 99

So I added <type>pdo_mysql</type>

Now I get

PDOException Object
(
[message:protected] => SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘core_resource’ already exists

...etc (long error)

(and this down the bottom)…
Fatal error: Uncaught exception ‘Mage_Core_Model_Store_Exception’ in C:\wlanmaul\app\code\core\Mage\Core\Model\App.php:1056 Stack trace: #0 C:\wlanmaul\app\code\core\Mage\Core\Model\App.php(545): Mage_Core_Model_App->throwStoreException() #1 C:\wlanmaul\app\Mage.php(577): Mage_Core_Model_App->getStore() #2 C:\wlanmaul\app\Mage.php(439): Mage::printException(Object(Mage_Core_Exception)) #3 C:\wlanmaul\index.php(40): Mage::run() #4 {main} thrown in C:\wlanmaul\app\code\core\Mage\Core\Model\App.php on line 1056

If I rename the table ‘core_resource’ on my default_read I still get the error, but if I rename it on my default_setup it creates ‘core_resource’ on default_setup and then complains about ‘core_website’ ..  Like its going down the list trying to create these tables.
I’m assuming it thinks its a fresh install.. tried defining a default_write instead of default_setup, but that didn’t work.. any more ideas?  I’m going to wipe my default_setup db server and see if it will go all the way through… Thanks !

<default_read>
            <
connection>
                    <use />
                    <
host><![CDATA[otherhost]]></host>
                    <
username><![CDATA[user]]></username>
                    <
password><![CDATA[pass]]></password>
                    <
dbname><![CDATA[magento]]></dbname>
                    <
active>1</active>
                    <
type>pdo_mysql</type>
                </
connection>
            </
default_read>

EDIT:
I deleted all tables and just had my magento schema and it goes through creation, but still errors out eventually.. similar database duplicate error.. just this time it was a column instead of a table.

 
Magento Community Magento Community
Magento Community
Magento Community
 
WildWire
Jr. Member
 
Total Posts:  15
Joined:  2008-03-31
 

bump ; )

 
Magento Community Magento Community
Magento Community
Magento Community
 
WildWire
Jr. Member
 
Total Posts:  15
Joined:  2008-03-31
 

Last Bump :/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
53191 users|727 users currently online|107221 forum posts