Install memcached under Mac

Source: Internet
Author: User
Tags memcached apache tomcat

For more memcached information, refer to http://www.ibm.com/developerworks/cn/java/j-memcached1/

Memcached is a general-purpose distributed memory caching system developed by Danga Interactive and using BSD licensing.

The purpose of the Danga Interactive development memcached is to create a memory cache system to handle the huge traffic on its website livejournal.com. More than 20 million page visits per day put a huge strain on LiveJournal's database, so Danga's Brad Fitzpatrick started designing memcached. Memcached not only reduces the load on the Web site database, but also becomes the caching solution used by most high-traffic websites in the world today.

How to incorporate memcached into your environment. Although memcached can be used anywhere, I find that memcached often works best when several recurring queries need to be executed in the database layer. I often set up a series of memcached instances between the database and the application server and use a simple pattern to read and write to these servers.


Sample application Architecture using memcached




The architecture is fairly easy to understand. I've built a Web tier that includes some Apache instances. The next layer is the application itself. This layer typically runs on Apache Tomcat or other open source application servers. The next layer is where the memcached instance is configured-that is, between the application server and the database server. When you use this configuration, you need to perform read and write operations on the database in a slightly different way.
Read

The order in which I perform the read operation is to fetch the request from the Web tier (which requires a database query) and examine the results of the query that was previously stored in the cache. If I find the value I want, I'll return it. If it is not found, the query is executed and the results are stored in the cache before the results are returned to the Web tier.
Write

When you write data to a database, you first need to perform a database write operation, and then set any previously cached results that are affected by this write operation to be invalid. This process helps prevent data inconsistencies between the cache and the database.

Libevent is the only prerequisite for installing memcached. It is the asynchronous event notification library that memcached relies on. You can find the source file on monkey.org on the libevent.

Libeven installation Package http://libevent.org/

Memcached installation Package http://memcached.org/

Libeven is currently a newer version of libevent-2.0.21-stable.tar.gz

Memcached is currently a newer version of memcached-1.4.17.tar.gz

Installing Libeven

Unzip the downloaded installation package libevent-2.0.21-stable.tar.gz get the directory libevent-2.0.21-stable

Java code
    1. CD libevent-2.0. 21-stable
    2. sudo./configure--prefix=/usr/local/libevent-2.0. +
    3. sudo make
    4. sudo make install

Installing memcached

Unzip the downloaded installation package memcached-1.4.17.tar.gz get the directory memcached-1.4.17

Ruby Code
    1. CD memcached-1.4.17
    2. sudo./configure--prefix=/usr/local/memcached-1.4.17--with-libevent=/usr/local/libevent-2.0.21
    3. sudo make
    4. sudo make install

Run memcached

-VV parameter mode

Ruby Code
    1. sudo./memcached-p 11211-m 64-u ROOT-VV



-D Daemon Mode

Ruby Code
    1. sudo./memcached-p 11211-m 64-u root-d



Excerpt from the content of the Netizen article:

#/usr/local/bin/memcached-d-M 200-u root-l 192.168.1.91-p 12301-c 1000-p/tmp/memcached.pid
The relevant explanations are as follows:
The-D option is to start a daemon,
-M is the amount of memory allocated to Memcache, in megabytes, 200MB
-U is the user running memcache, and if it is currently root, you need to specify the user with this parameter.
-L is the server IP address of the listener, if there are multiple addresses, I specify the IP address of the server 192.168.1.91
-P is the port that sets Memcache listening, I set here 12301, preferably more than 1024 ports
The-c option is the maximum number of concurrent connections to run, which defaults to 1024, which is set to 256
-P is set to save memcache PID file, I am here to save in/tmp/memcached.pid
To stop the memcache process:
# Kill ' Cat/tmp/memcached.pid '
You can also start multiple daemons, but the ports cannot be duplicated

-------------------------------

The first "-D" parameter needs further explanation.

-D Install installation memcached

-D Uninstall Uninstall memcached

-D Start memcached service

-D Restart Restart memcached service

-D Stop Stop memcached service

-D Shutdown Stop memcached service

-------------------------------

Additional Features:

1. Check the Memcache service for startup:

Netstat-lp | grep memcached

2, check the process number of memcache (according to the process number, you can end the Memcache service: "kill-9 process number")

Ps-ef | grep memcached

Install memcached under Mac

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.