Configuration of the Mecacheq

Source: Internet
Author: User
Tags message queue

When dealing with business logic, it is possible to encounter high concurrency issues, such as mall seconds, Weibo reviews, and so on. How do you solve this problem if you don't do anything that could cause the server to crash in the high-instantaneous moment? The queue is a good choice. The queue, also known as first in, FIFO, is a good way to handle data transfer and storage asynchronously using Message Queuing, and when you write data to a database, you can take Message Queuing to insert asynchronously. As long as there are concurrency restrictions where the basic can be used to solve the queue. Here, let's focus on Memcacheq.

Persistent Message Queuing Memcacheq is a lightweight message queue. Dependent on Berkeley DB and Libevent. Berkeley db is used to persist data in the storage queue to avoid data loss in the case of MEMCACHEQ problems. Next look at the installation process, first download libevent-1.4x***, BerkeleyDB5.0, memcacheq-0.2.0,:

http://monkey.org/~provos/libevent/

Http://download.oracle.com/berkeley-db/db-5.0.21.tar.gz

Http://code.google.com/p/memcacheq/downloads/list

Installation steps:

Tar zxvf libevent-1.4.14b-stable.tar.gz
CD libevent-1.4.14b-stable
./configure
Make
Make install
Ln-s/usr/local/lib/libevent-1.4.so.2/usr/lib/libevent-1.4.so.2
Cd..
Tar zxvf db-5.0.21.tar.gz
CD db-5.0.21/build_unix/
.. /dist/configure
Make
Make install
Vi/etc/ld.so.conf
Add the following two lines
/usr/local/lib
/usr/local/berkeleydb.5.0/lib
Perform
Ldconfig
Cd.. /.. /
Tar zxvf memcacheq-0.2.0.tar.gz
CD memcacheq-0.2.0
./configure--with-bdb=/usr/local/berkeleydb.5.0--with-libevent=/usr/local/lib--enable-threads
Make
Make install
Before you start, determine if the log directory exists if it does not exist and you need to manually create
memcacheq-d-r-uroot-p22201-h/data0/memcacheq-n-v-l 1024-b 1024x768 >/data0/mq_error.log 2>&1
Parameter description:
-D: Future service mode operation
-L: Set the listening address and port (the default port is 22201)
-A: Data page size
-H: Data Save directory must exist
-B: Maximum length per piece of data in a queue (bytes)
-N: Use memory buffering to save data to disk for extreme performance. Without this parameter, performance will be poor
-R: Automatic cleanup of expired logs-U: Set Memcacheq process account

PHP code example:

1 $memcache _obj New Memcache; 2 3 $memcache _obj->connect (' 192.168.1.106 ', 22201); 4 $memcache _obj->set (' A ',time (), 0,0); // into the stack 5 6 Echo $memcache _obj->get (' a ');      // out of the stack

Configuration of Mecacheq

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.