Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Memcached usage

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The use of Memcached

1.1 install libevent

Memcached download address http://memcached.org/downloads

Libevent download address: http://libevent.org/

Install libevent before installing memcached

Tar xf libevent-2.0.21-stable.tar.gz

Cd libevent-2.0.21-stable

. / configure

Make & & make install

1.2 install memcached

Wget http://memcached.org/files/memcached-1.4.25.tar.gz

Tar-xf memcached-1.4.25.tar.gz

Cd memcached-1.4.25

. / configure

Make & & make install

Memcached-1.4.25.tar.gz "= server

Memcached-1.4.25.tgz "= client

Start memcached

First of all, configure the ld.so.conf path to prevent errors when starting memcached

[root@nosql src] # echo "/ usr/local/lib" > > / etc/ld.so.conf

[root@nosql src] # ldconfig

Centos5.8 does not have to do the above configuration.

Start starting memcached

[root@nosql src] # which memcached

/ usr/local/bin/memcached

[root@nosql src] # memcached-u root-p 11211-m 16m-c 8192-d

[root@nosql src] # lsof-I: 11211

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

Memcached 8872 root 26u IPv4 17126 0t0 TCP *: memcache (LISTEN)

Memcached 8872 root 27u IPv6 17127 0t0 TCP *: memcache (LISTEN)

View help

Memcached-h

-P listening port. Default is 11211.

-l IP address of the connection. Default is local.

-d start starts the memcached service

-d restart restarts memcached service

-d stop | shutdown shuts down the running memcached service

-d install install memcached service

-d uninstall uninstall the memcached service

-u runs as (valid only when running as root)

-m maximum memory usage, in MB. Default 64MB, the maximum is like 2G

-M returns an error when memory is exhausted instead of deleting an item

-c the maximum number of simultaneous connections. The default is 1024, which is set according to the concurrent visits to the server.

-f block size growth factor, default is 1.25

-n minimum allocated space. Key+value+flags defaults to 48.

-h display help

-P set the pid file to save memcache

If you start multiple instances, you can switch ports.

[root@nosql src] # memcached-u root-p 11212-m 16m-c 8192-d

Web cluster session shared storage settings:

The type and configuration path of session in the default php.ini:

# session.save_handler = files

# session.save_path = "/ tmp"

Modify it to the following configuration:

Session.save_handler = memcache

Session.save_path = "tcp://192.168.1.18:11211"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report