_php tutorial on configuring Memcache methods in Drupal7

Source: Internet
Author: User
Tags drupal
This article to give you a detailed introduction of the DRUPAL7 in the configuration of Memcache method in detail, I hope this method to your classmates help oh.

Memcache configuration is not much to say, Drupal due to the number of modules, database calls frequently, so memcache is the necessary configuration of the Drupal site, this article about the DRUPAL7 in the configuration of Memcache, in order to facilitate access to everyone.

1. Install the Memcache service and start the memcached.

2. Install the Drupal memcache module. (Http://drupal.org/project/memcache)

3. Configure settings.php

The code is as follows Copy Code
$conf [' cache_backends '] [] = ' sites/all/modules/memcache/memcache.inc ';
The ' cache_form ' bin must be assigned no non-volatile storage.
$conf [' cache_class_cache_form '] = ' drupaldatabasecache ';
$conf [' cache_default_class '] = ' memcachedrupal ';
$conf [' memcache_key_prefix '] = ' something_unique ';

Note that the Memcache.inc file path needs to be written correctly, as mentioned in the Drupal module Catalog organization Summary, we generally place the Memcache module under the Contrib folder, so the path may be sites/all/modules/ Contrib/memcache/memcache.inc.
In addition Memcache_key_prefix the best set up a bit.

4. Multiple MEMCACHD services.
By default, if you do not configure Memcache_servers and Memcache_bins, Drupal will assume that there is only one server, 127.0.0.1:11211, and if you have more than one memcache instance, you need to add the following configuration.

The code is as follows Copy Code
$conf [' memcache_servers '] = Array (
' 10.1.1.1:11211 ' = ' default ',
' 10.1.1.1:11212 ' = ' default ',
' 10.1.1.2:11211 ' = ' default ',
' 10.1.1.3:11211 ' = ' cluster2 ',
' 10.1.1.4:11211 ' = ' cluster2 '
);
$conf [' memcache_bins '] = Array (
' Cache ' = ' default ',
' Cache_filter ' = ' cluster2 ',
' Cache_menu ' = ' cluster2 '
);

Everything is ready.

Finally, the paper explains how to configure multiple Memcache instances of a single machine, that is, the Memcache cluster construction of a single machine.
We need to modify 2 files, one is the startup script/etc/init.d/memcached-multi, the other is the configuration file/etc/sysconfig/memcached.

The code is as follows Copy Code
/etc/sysconfig/memcached

is used to configure the size of multiple memcache instances

The code is as follows Copy Code
Port= "11211"
User= "Memcached"
maxconn= "1024"
Cachesize= "512"
Options= ""
Multibucket= "2"
cachesizearray[1]= "1024"
cachesizearray[2]= "/etc/init.d/memcached-multi"

is used to start the Memcache cluster. (Start, stop, restart)

The code is as follows Copy Code
#! /bin/sh
#
# Chkconfig:-55 45
# description:the memcached Daemon is a network memory cache service.
# processname:memcached
# config:/etc/sysconfig/memcached
# Pidfile:/var/run/memcached/memcached.pid

# Standard LSB functions
#. /lib/lsb/init-functions

# Source function library.
. /etc/init.d/functions

port=11211
User=memcached
maxconn=1024
Cachesize=64
Options= ""
Multibucket= ""

if [-f/etc/sysconfig/memcached];then
. /etc/sysconfig/memcached
Fi

[-Z "$MULTIBUCKET"] && multibucket=1

# Check that networking are up.
. /etc/sysconfig/network

If ["$NETWORKING" = "No"]
Then
Exit 0
Fi

Retval=0
Prog= "Memcached"

Start () {
Echo-n $ "Starting $prog:"
# Insure that/var/run/memcached has proper permissions
If ["' Stat-c%u/var/run/memcached '"! = "$USER"]; Then
Chown $USER/var/run/memcached
Fi

For i in '/usr/bin/seq 1 $MULTIBUCKET '; Do
Thiscachesize= $CACHESIZE
[${#CACHESIZEARRAY [*]}-gt 0-a ${cachesizearray[$i]:-0}-gt 0] && thiscachesize=${cachesizearray[$i]}
Daemon--pidfile/var/run/memcached/memcached.pid memcached-d-P $PORT-u $USER-M $THISCACHESIZE-C $MAXCONN-P/var/run /memcached/memcached-$i. PID $OPTIONS
Let retval= $RETVAL +$?
Let port= $PORT +1
Done
Echo
[$RETVAL-eq 0] && touch/var/lock/subsys/memcached
}
Stop () {
Echo-n $ "Stopping $prog:"
For i in '/usr/bin/seq 1 $MULTIBUCKET '; Do
Killproc-p/var/run/memcached/memcached-$i. pid/usr/bin/memcached
Let retval= $RETVAL +$?
Done
Echo
If [$RETVAL-eq 0]; Then
Rm-f/var/lock/subsys/memcached
Rm-f/var/run/memcached.pid
Fi
}

Restart () {
Stop
Start
}

# See how we were called.
Case "$" in
Start
Start
;;
Stop
Stop
;;
Status
echo "Warning:this status check is laughable. Inspect netstat or PS output manually. "
Status memcached
;;
Restart|reload|force-reload)
Restart
;;
Condrestart)
[-f/var/lock/subsys/memcached] && Restart | | :
;;
*)
echo $ "Usage: $ {Start|stop|status|restart|reload|force-reload|condrestart}"
Exit 1
Esac

Exit $RETVAL

At this point some are ready.

http://www.bkjia.com/PHPjc/631492.html www.bkjia.com true http://www.bkjia.com/PHPjc/631492.html techarticle This article to give you a detailed introduction of the DRUPAL7 in the configuration of Memcache method in detail, I hope this method to your classmates help oh. Memcache configuration is not much to say, Drupal due to mold ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.