magento 结合 memcached

来源:互联网 发布:centos6配置国内yum源 编辑:程序博客网 时间:2024/05/16 19:14

安装memcached

yum -y install libevent-devel gcc-c++ php-pecl-memcached php-pecl-memcache memcached

service httpd restart 

编辑php.ini增加

extension=json.so
extension=memcached.so
memcached.sess_consistent_hash=On

 

注释掉/etc/php.d/json.ini 和 memcached.ini 中内容

 

配置local.xml

<?xml version="1.0"?>
<!--
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Mage
 * @package    Mage_Core
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
-->
<config>
    <global>
        <install>
            <date><![CDATA[Thu, 15 Aug 2013 08:44:22 +0000]]></date>
        </install>
        <crypt>
            <key><![CDATA[e97d8b5b49b88b4ee4c8a3ccd5964b38]]></key>
        </crypt>
        <disable_local_modules>false</disable_local_modules>
        <resources>
            <db>
                <table_prefix><![CDATA[]]></table_prefix>
            </db>
            <default_setup>
                <connection>      
                    <host><![CDATA[192.168.1.146:3310]]></host>
                    <username><![CDATA[test]]></username>
                    <password><![CDATA[test]]></password>
                    <dbname><![CDATA[test]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type>
                    <pdoType><![CDATA[]]></pdoType>
                    <active>1</active>
                </connection>
            </default_setup>
        </resources>
        <session_save><![CDATA[memcache]]></session_save> <!-- db / memcache / empty=files -->
        <session_save_path><![CDATA[tcp://192.168.1.144:11211?persistent=1&timeout=10&retry_interval=10,tcp://192.168.1.144:11211?persistent=1&timeout=10&retry_interval=10]]></session_save_path><!-- e.g. for memcache session save handler tcp://10.0.0.1:11211?persistent=1&weight=2&timeout=10&retry_interval=10 -->
        <session_cache_limiter><![CDATA[]]></session_cache_limiter><!-- see http://php.net/manual/en/function.session-cache-limiter.php#82174 for possible values -->
        <cache>
            <backend>Zend_Cache_Backend_Memcached</backend><!-- apc / memcached / xcache / empty=file -->
            <backend_options>
               <servers><!-- any number of server nodes can be included -->
                     <server>
                        <host><![CDATA[192.168.1.144]]></host>
                        <port><![CDATA[11211]]></port>
                        <weight><![CDATA[5]]></weight>
                    </server>
                    <server>
                           <host><![CDATA[127.0.0.1]]></host>
                           <port><![CDATA[11211]]></port>
                           <weight><![CDATA[5]]></weight>
                     </server>
                </servers>
            </backend_options>
        </cache>
        <full_page_cache>
                <backend>Zend_Cache_Backend_Memcached</backend><!-- apc / memcached / xcache / empty=file -->
            <backend_options>
               <servers><!-- any number of server nodes can be included -->
                     <server>
                        <host><![CDATA[127.0.0.1]]></host>
                        <port><![CDATA[11211]]></port>
                        <weight><![CDATA[5]]></weight>
                    </server>
                    <server>
                          <host><![CDATA[192.168.1.144]]></host>
                          <port><![CDATA[11211]]></port>
                          <weight><![CDATA[5]]></weight>
                     </server>
                </servers>
            </backend_options>
          </full_page_cache>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
        <frontend>
            <events>
                <controller_action_predispatch>
                    <observers><log><type>disabled</type></log></observers>
                </controller_action_predispatch>
                <controller_action_postdispatch>
                    <observers><log><type>disabled</type></log></observers>
                </controller_action_postdispatch>
                <customer_login>
                    <observers><log><type>disabled</type></log></observers>
                </customer_login>
                <customer_logout>
                    <observers><log><type>disabled</type></log></observers>
                </customer_logout>
                <sales_quote_save_after>
                    <observers><log><type>disabled</type></log></observers>
                </sales_quote_save_after>
                <checkout_quote_destroy>
                    <observers><log><type>disabled</type></log></observers>
                </checkout_quote_destroy>
            </events>
        </frontend>
</config>

重启memcached和apache

service httpd restart

 

查看memcached命中率

telnet  memcached主机地址 11211

stats

STAT pid 7528
STAT uptime 1406
STAT time 1390888223
STAT version 1.4.4
STAT pointer_size 64
STAT rusage_user 0.014997
STAT rusage_system 0.053991
STAT curr_connections 10
STAT total_connections 23
STAT connection_structures 11
STAT cmd_get 1481
STAT cmd_set 57
STAT cmd_flush 0
STAT get_hits 1040
STAT get_misses 441
STAT delete_misses 3
STAT delete_hits 1
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 534262
STAT bytes_written 3608837
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 461335
STAT curr_items 56
STAT total_items 57
STAT evictions 0
END

命中率= get_hits/cmd_get

0 0
原创粉丝点击