Deploy and use memcachefs

Source: Internet
Author: User
Tags delete cache
Introduction to the deployment and use of memcachefs: memcachefs is a FUSE-based memcached File System That mounts the Memcache service to a local machine. Allows you to view cached data, like files on a disk. All memcache operations will be converted to general file operations. Project address: memcachefs. sourcefor

Introduction to the deployment and use of memcachefs: memcachefs is a FUSE-based memcached File System That mounts the Memcache service to a local machine. Allows you to view cached data, like files on a disk. All memcache operations will be converted to general file operations. Project address: http://memcachefs.sourcefor

MemcacheFile System memcachefsDeployment and use



Introduction


Memcachefs is a FUSE-based memcached File System That mounts the memcache Service locally. Allows you to view cached data, like files on a disk. All memcache operations will be converted to general file operations.


Address: http://memcachefs.sourceforge.net/

Use Cases


Memcachefs can be used to implement cached files based on local disks, which is more efficient than disks .. For example, session files. If the previous session information exists on the local disk, you can directly Mount memcache to the current session directory without changing the program.

Install


1. Install dependencies (use root for installation)


Dependency

  • FUSE 2.5 or later

  • Libmemcached 1.4 or later

A)install fuse-2.9.3.tar.gz

cd /tmpwget http://hivelocity.dl.sourceforge.net/project/fuse/fuse-2.X/2.9.3/fuse-2.9.3.tar.gztar zxvf fuse-2.9.3.tar.gzcd fuse-2.9.3./configuremakemake install


B) mount the fuse kernel module

modprobe fuselsmod | grep "fuse"


Install libmemcache-1.4.0.rc2.tar.bz2 on csung.

cd /tmpwget http://people.freebsd.org/~seanc/libmemcache/libmemcache-1.4.0.rc2.tar.bz2tar xvf libmemcache-1.4.0.rc2.tar.bz2cd libmemcache-1.4.0.rc2./configuremake


Compilation error. The output is as follows:

memcache.c: At top level:../include/memcache/buffer.h:73: warning: inline function 'mcm_buf_remain_off' declared but never defined../include/memcache/buffer.h:72: warning: inline function 'mcm_buf_remain' declared but never defined../include/memcache/buffer.h:66: warning: inline function 'mcm_buf_len' declared but never defined../include/memcache/buffer.h:73: warning: inline function 'mcm_buf_remain_off' declared but never defined../include/memcache/buffer.h:72: warning: inline function 'mcm_buf_remain' declared but never defined../include/memcache/buffer.h:66: warning: inline function 'mcm_buf_len' declared but never defined


For solutions, refer:

Http://pietercvdmlinux.blogspot.com/2012_07_01_archive.html

wget 'http://svnweb.freebsd.org/ports/head/databases/libmemcache/files/patch-fix-inline?revision=248965&view=co' -O libcache.patchpatch -p0 < libcache.patch


Again

makemake install

2. Download and install memcachefs

mkdir /usr/local/memcachefscd /tmpwget http://jaist.dl.sourceforge.net/project/memcachefs/memcachefs/0.5/memcachefs-0.5.tar.gztar -zxvf memcachefs-0.5.tar.gzcd memcachefs-0.5./configure --prefix=/usr/local/memcachefsmakemake installcd /usr/local/memcachefs

3. Mount memcached

Mkdir/usr/local/cache./bin/memcachefs 192.168.11.52: 11211/usr/local/cache # mount the remote memcache to the local disk.


The following error is reported:

"./Bin/memcachefs: error while loading shared libraries: libmemcache. so.0: cannot open shared object file: No such file or directory"


Solution:

Add/usr/local/lib to/etc/ld. so. conf

echo "/usr/local/lib" >> /etc/ld.so.conf/sbin/ldconfig


View mounting information:

mount -l

Memcachefs on/usr/local/cache type fuse. memcachefs (rw, nosuid, nodev)

Use


1. Basic operations

Cd/usr/localecho "helloworld"> cache/test_key # Set a cache data. The file name is a key and the file content is a value. It is equivalent to the set key value operation. Cat cache/test_key # obtain cache data. It is equivalent to the get key operation. Ll cache/# list all keys. Note that the fifth column does not indicate the size, but the length of characters. The time attribute of Column 6 and column 7. Rm cache/test_key # delete cache data, which is equivalent to the delete key operation. Mv cache/username. bak # rename

2. Uninstall

# Mount # view mounting # umount/usr/local/cache # uninstall # fusermount-u/usr/local/cache # uninstall


3. Use the telnet client to test


Set a 0 10 3 #10 s expired. After 10 s, the file in the cache directory will be deleted.

Get username. bak # obtain the cache data set by memcachfs through telnet

Cat cache/a # Get key a data through memcachefs

[root@test01 local]# telnet 192.168.11.52 11211Trying 192.168.11.52...Connected to 192.168.11.52.Escape character is '^]'.set a 0 10 3aaaSTOREDget username.bakVALUE username.bak 0 6ryanxuENDquitConnection closed by foreign host.[root@test01 local]# cat cache/aaaa

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.