Memcached in Linux Installation

Source: Internet
Author: User
Tags memcached

Server side is mainly installed Memcache server side.
Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, Memcache used the libevent this library for socket processing, so you also need to install the latest version of Libevent,libevent is libevent-1.3. (If your system already has libevent installed, you can not install it)
Official website: http://www.monkey.org/~provos/libevent/
Download: http://www.monkey.org/~provos/libevent-1.3.tar.gz

Download these two items directly with the wget command. After downloading back to the source file.
1. Install Libevent first. This thing needs to be configured with an installation path, i.e../configure–prefix=/usr; then make; then make install;
2. Install the memcached again, just need to specify the installation path of libevent when configuring the./configure–with-libevent=/usr; then make; then make install;
This completes the installation of Linux under the Memcache server side. The detailed methods are as follows:

1. Download the memcached and libevent separately and put them in the/tmp directory:
# 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:
# tar ZXVF libevent-1.2.tar.gz
# CD libevent-1.2
#./CONFIGURE–PREFIX=/USR
# make
# make Install

3. test whether the libevent is installed successfully:
# Ls-al/usr/lib | grep libevent
lrwxrwxrwx 1 root root 21 11?? 17:38 Libevent-1.2.so.1-libevent-1.2.so.1.0.3
-rwxr-xr-x 1 root root 263546 11?? 17:38 libevent-1.2.so.1.0.3
-rw-r–r–1 root root 454156 11?? 17:38 LIBEVENT.A
-rwxr-xr-x 1 root root 811 11?? 17:38 libevent.la
lrwxrwxrwx 1 root root 21 11?? 17:38 libevent.so-libevent-1.2.so.1.0.3
Good, all installed.

4. Install the memcached and require the installation location of the specified libevent in the installation:
# cd/tmp
# tar ZXVF memcached-1.2.0.tar.gz
# CD memcached-1.2.0
#./CONFIGURE–WITH-LIBEVENT=/USR
# make
# make Install
If there is an error in the middle, please carefully check the errors, follow the error message to configure or add the appropriate library or path.
When the installation is complete, the memcached will be put into/usr/local/bin/memcached,

5. Test whether the memcached is installed successfully:
# ls-al/usr/local/bin/mem*
-rwxr-xr-x 1 root root 137986 11?? 17:39/usr/local/bin/memcached
-rwxr-xr-x 1 root root 140179 11?? 17:39/usr/local/bin/memcached-debug

To start the memcached service :
1. Start the server side of the memcache:
#/usr/local/bin/memcached-d-M 10-u root-l 192.168.141.64-p 12000-c 256-p/tmp/memcached.pid

The-D option is to start a daemon,
-M is the amount of memory allocated to Memcache, in megabytes, I'm 10MB,
-U is the user running memcache, I am root here,
-L is the server IP address of the listener, if there are multiple addresses, I specify the server IP address 192.168.0.200,
-P is the port that sets Memcache listening, I set here 12000, preferably more than 1024 ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set the 256 here, according to the load of your server to set,
-P is set to save memcache PID file, I am here to save in/tmp/memcached.pid,

2. If you want to end the memcache process, execute:

# Kill ' Cat/tmp/memcached.pid '

You can also start multiple daemons, but the ports cannot be duplicated.

Test memcached:

[[Email protected]/]# Telnet 192.168.141.64 12000
Trying 192.168.141.64 ...
Connected to 192.168.141.64 (192.168.141.64).
Escape character is ' ^] '.
Set Key1 0 60 4
Zhou
STORED
Get Key1
VALUE Key1 0 4
Zhou
END


This memcached installation is successful!

Problems:

1. If you encounter a memcached service when you start the

/usr/local/bin/memcached:error while loading shared libraries:libevent-1.2.so.1:cannot open shared object File:no such file or directory;

Solution:

[Email protected] bin]# ld_debug=libs memcached-v #查看memcached需要加载那些lib.

[email protected] bin]# ln-s/usr/lib/libevent-1.2.so.1/usr/lib64/libevent-1.2.so.1
[Email protected] bin]#/usr/local/bin/memcached-d-M 100-u root-p 12000-c 1000-p/tmp/memcached.pid
[Email protected] bin]# Ps-aux

You can see the memcached service started.

Way Two

Copy the libevent-1.3c.so.1 to any of the listed Lib .
or soft links
Ln-s/data/libevent/lib/libevent-1.3b.so.1/usr/lib/libevent-1.3c.so.1
or modify the Vi/etc/profile file.
Export library_path=:/usr/local/lib: "/usr/local/berkeleydb.4.3/lib":/usr/local/lib:/opt/ice-3.1/lib:/usr/lib:/ Home/mahaibo/install/lib

2. Load the memcached service into the Linux startup item. In case the machine loses power, the system restarts. Then memcached will start automatically.

If the server-side command to start Memcache is:
#/usr/local/bin/memcached-d-M 10-u root-l 192.168.141.64-p 12000-c 256-p/tmp/memcached.pid capacity from 17jquery

If you want to start the boot automatically, just add a line in the/etc/rc.d/rc.local, the following command
/usr/local/bin/memcached-d-M 10-p 12000-u apache-c 256
There are some things to refer to: That is, IP is not specified when the default is the local, users: the best choice is: apache/deamon/nobody

This is the service that belongs to which user and which user starts it.

Other:

[Email protected] ~]# memcached-h
Memcached 1.4.24
-P <num> TCP port number to listen on (default:11211)
-U <num> UDP port number to listen on (default:11211, 0 is off)
-S <file> UNIX socket path to listen on (disables network support)
-A enable ASCII "shutdown" command
-A <mask> access mask for UNIX sockets, in octal (default:0700)
-L <addr> interface to listen in (Default:inaddr_any, all addresses)
<addr> may specified as Host:port. If you don ' t specify
A port number, the value of specified With-p or-u is
Used. Specify multiple addresses separated by comma
or by using-l multiple times
-D Run as a daemon
-R Maximize Core file limit
-U <username> assume identity of <username> (only if run as root)
-M <num> max memory to use for items in megabytes (default:64 MB)
-M return error on memory exhausted (rather than removing items)
-C <num> Max simultaneous connections (default:1024)
-K Lock down all paged memory. Note that there is a
Limit on how much memory you may lock. Trying to
Allocate more than this would fail, so is sure you
Set the limit correctly for the user started
The daemon with (not for-u <username> user;
Under SH This is do with ' ulimit-s-l num_kb ').
-V Verbose (print errors/warnings while in event loop)
-VV very verbose (also print client commands/reponses)
-VVV extremely verbose (also print internal state transitions)
-H Print this help and exit
-I print memcached and libevent license
-V print version and exit
-P <file> Save PID in <file>, only used with-d option
-F <factor> Chunk size growth factor (default:1.25)
-N <bytes> minimum space allocated for key+value+flags (default:48)
-L Try to use large memory pages (if available). Increasing
The memory page size could reduce the number of TLB misses
and improve the performance. In order to get large pages
From the OS, memcached'll allocate the total Item-cache
In one large chunk.
-D <char> use <char> as the delimiter between key prefixes and IDs.
This is used for Per-prefix stats reporting. The default is
":" (colon). If This option is specified, stats collection
is turned on automatically; If not and then it is turned on
By sending the ' Stats detail on ' command to the server.
-T <num> number of threads to use (Default:4)
-R Maximum Number of requests per event, limits the number of
Requests process for a given connection to prevent
Starvation (DEFAULT:20)
-c Disable use of CAS
-B Set The backlog queue limit (default:1024)
-B Binding Protocol-one of ASCII, binary, or auto (default)
-I Override the size of each slab page. Adjusts max item size
(DEFAULT:1MB, min:1k, max:128m)
-F Disable flush_all command
-O Comma separated list of extended or experimental options
-(experimental) maxconns_fast:immediately close new
Connections if over Maxconns limit
-Hashpower:an integer multiplier for how large the hash
Table should be. Can is grown at runtime if not big enough.
Set this based on "STAT Hash_power_level" before a
Restart.
-Tail_repair_time:time in seconds so indicates how long to wait before
Forcefully taking over the LRU tail item whose refcount have leaked.
Disabled by default; Dangerous option.
-Hash_algorithm:the Hash Table algorithm
Default is Jenkins hash. Options:jenkins, MURMUR3
-lru_crawler:enable LRU crawler Background thread
-Lru_crawler_sleep:microseconds to sleep between items
Default is 100.
-Lru_crawler_tocrawl:max items to crawl per slab per run
Default is 0 (unlimited)
-Lru_maintainer:enable New LRU system + background thread
-Hot_lru_pct:pct of slab memory to reserve for hot LRU.
(Requires Lru_maintainer)
-Warm_lru_pct:pct of slab memory to the reserve for warm LRU.
(Requires Lru_maintainer)
-Expirezero_does_not_evict:items set to not expire, would not evict.
(Requires Lru_maintainer)

Memcached in Linux Installation

Related Article

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.