Installing and using Memcache on Linux server

Time:2021-3-7

The server side mainly installs the server side of Memcache, and the latest version is memcached-1.3.0.
Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, Memcache uses the library libevent for socket processing, so it also needs to install libevent. The latest version of libevent is libevent-1.3. (if you have installed libevent on your system, you don’t need to install it.)
Official website: http://www.monkey.org/~provos/libevent/
Download: http://www.monkey.org/~provos/libevent-1.3.tar.gz
Use WGet command to download these two things directly. After downloading back to the source file.
1. Install libevent first. When configuring this thing, you need to specify an installation path, that is. / configure – prefix = / usr; then make; then make install;
2. To install memcached again, you need to specify the installation path of libevent, that is. / configure – with libevent = / usr; then make; then make install;
This completes the installation of Memcache server under Linux. The detailed methods are as follows:
1. Download memcached and libevent respectively and put them in the / tmp directory

Copy code

The code is as follows:

# cd /tmp
# wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz
# wget http://www.monkey.org/~provos/libevent-1.2.tar.gz

2. Install libevent first:

Copy code

The code is as follows:

# tar zxvf libevent-1.2.tar.gz
# cd libevent-1.2
# ./configure –prefix=/usr
# make
# make install

3. Test whether libevent is installed successfully:

Copy code

The code is as follows:

# ls -al /usr/lib | grep libevent
lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent-1.2.so.1 -> libevent-1.2.so.1.0.3
-rwxr-xr-x 1 root root 263546 11?? 12 17:38 libevent-1.2.so.1.0.3
-rw-r–r– 1 root root 454156 11?? 12 17:38 libevent.a
-rwxr-xr-x 1 root root 811 11?? 12 17:38 libevent.la
lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent.so -> libevent-1.2.so.1.0.3

Not bad. It’s all installed.
4. To install memcached, you need to specify the installation location of libevent in the installation:

Copy code

The code is as follows:

# cd /tmp
# tar zxvf memcached-1.2.0.tar.gz
# cd memcached-1.2.0
# ./configure –with-libevent=/usr
# make
# make install

If an error is reported in the middle, please check the error message carefully and configure or add the corresponding library or path according to the error message.
After installation, you will put memcached in / usr / local / bin / memcached,
5. Test whether memcached is successfully installed:

Copy code

The code is as follows:

# ls -al /usr/local/bin/mem*
-rwxr-xr-x 1 root root 137986 11?? 12 17:39 /usr/local/bin/memcached
-rwxr-xr-x 1 root root 140179 11?? 12 17:39 /usr/local/bin/memcached-debug

Basic use
To view the current number of Memcache connections:

Copy code

The code is as follows:

[[email protected] ~]# netstat -n | grep :11211 | wc -l

15752

To view the number of connections allowed by default:

Copy code

The code is as follows:

[[email protected] ~]# cat /etc/rc.local

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don’t
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/usr/local/bin/memcached -d -m 15360 -u root -l 172.20.1.54 -p 11211 -c 40960 
/usr/local/bin/memcached -d -m 512 -u root -l 172.20.1.54 -p 11212 -c 10000

The default connection number of port 11211 set here is 40960

Memcache also has its own viewing tool for information on the Internet
How to view the server version of Memcache:. / memcached – H
The running state of Memcache can be easily displayed with stats command.
First, connect the Memcache with a command like telnet 127.0.0.1 11211, and then directly input stats to get the current status of the Memcache.
These states are described as follows:
20151026101919776.png (793×458)

Recommended Today

asp.net Application of regular expression

1. Balanced group / recursive matching (?’ Group ‘), which is called the corresponding content of group, and counts it on the stack;(?’- Group ‘), and count the corresponding content named group out of the stack(?!) Zero width negative look ahead assertion. Since there is no suffix expression, attempts to match always failRegular example:,{0,1}”5″:\[[^\[\]]*(((?’Open’\[)[^\[\]]*)+((?’-Open’\])[^\[\]]*)+)*(?(Open)(?!))\],{0,1} Test […]