Memcacheq service installation and principle overview

  
 

memcacheQ is a pure distributed message queue service. Its installation depends on BerkeleyDB and libevent, so install BerkeleyDB and libevent first:


1, BerkeleyDB

  1. Download the package, http://Download.oracle.com/berkeley-db/db-5.0.21.tar.gz
  2. Unzipped, cd build_unix
  3. ../dist/configure
  4. make
  5. sudo make install

    Second, libevent (requires 1.4.x or higher)

    1. Download package: http://monkey.org /~provos/libevent/
    2. Unzip and configure & make & make install

      three, memcacheQ

      1. Download package: http: //code.google.com/p/memcacheq/downloads/list
      2. Unzip, cd into directory
      3. ./configure –with-bdb=/usr/local/BerkeleyDB.5.0 –with-libevent=/usr/local/lib –enable-threads
      4. make
      5. sudo make install

        four, start memcacheQ
        < Ol>

      6. Use the command memcacheq -h to view command line options
      7. Start memcacheq:memcacheq -d -r -H /data1/memcacheq -N -R - v -L 1024 -B 1024 > /data1/mq_error.log 2>&1

        V, use

        Use the above command to start mq, (note the above - The B parameter indicates that the body length of messag cannot exceed 1024 bytes. When using mq, only two commands are required: set and get:

        set <queue name> <flags> 0 <message_len>\\ r\ <put your message body here>\
        \ STORED\
        \ 
        get <queue name>\
        \ VALUE <queue name> <flags> <message_len>\
        \ <your Message body will come here>\
        \ END\
        \ 

        It can be seen that it is basically the same as the memcache protocol, except that the key name is replaced by the queue name, and the parameters of expire_time are ignored in the set command. After all, mq's data storage is stored in berkeleyDB, made persistent storage, no memory expiration time.

        When the set command is used, a new message is written to the specified message queue, that is, a new data is inserted into BerkeleyDB. When the get command is used, one is taken from the specified queue. The new message, which is to delete a piece of data to BerkeleyDB. When you use stats to view a specific queue, you can see how many messages the queue has received and how many of them have been fetched.

        Example:
        fengbo@onlinegame-10-121:~$ telnet 127.0.0.1 22202Trying 127.0.0.1…Connected to 127.0.0.1.Escape character is ‘^]’.set q4 0 0 5helloSTOREDset q4 0 0 5worldSTOREDstats queueSTAT q4 2/0ENDget q4VALUE q4 0 5helloENDstats queueSTAT q4 2/1END

        The above two commands are executed. When using stats queue, you can see that there are 2 messages in the queue of q4. 0 has been removed; when using get to take the first one, then use stats queue to view, there are 2 messages in q4, of which 1 has been taken.

Copyright © Windows knowledge All Rights Reserved