Memcached 安装

安装Memcached

安装Memcached前要先安装 libevent库

安装环境:

[[email protected] ~]# uname -a

Linux MEM 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

[[email protected] ~]#

安装libevent库

mkdir -p /home/lvnian/tools/

cd /home/lvnian/tools/

rz -y

ls libevent-1.4.13-stable.tar.gz

tar xf libevent-1.4.13-stable.tar.gz

cd libevent-1.4.13-stable

./configure

make && make install

注意,也可以yum安装libevent库

yum install libevent* -y

#######################################################

安装Memcached

cd /home/lvnian/tools/

rz -y

tar xf Memcached-1.4.13.tar.gz

cd Memcached-1.4.13

./configure

make && make install

#安装完毕

其中Memcacheds是服务端

memcache 是客户端

#######################################################

启动Memcached服务

1、配置ld.so.conf路径防止启动Memcached时报错

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

ldconfig

如果是centos 5.8 可以不做

2.启动Memcached

which Memcached

/usr/local/bin/memcached -h

/usr/local/bin/memcached -p

/usr/local/bin/memcached -p 11211 -u root -m 32m -c 10240 -d

netstat -lnt |grep 11211

lsof -i :11211

/usr/local/bin/memcached -p 11233 -u root -m 32m -c 10240 -d

netstat -lnt |grep 11233

lsof -i :11233

##可以同时启动多个Memcached进程

===========================

-p 指定TCP的端口号,默认是11211

-U  指定TCP的端口号,默认是11211

-d 以守护进程方式启动

-m Memcached以多大内存方式启动,默认是64M

-u 指定运行Memcached的用户

-c  指定最大的并发连接数,默认是1024

-vv 以very werbose模式启动,也就是把调试信息和错误输出到控制台

-P  设置保存Memcached的pid文件

-l  指定监听的服务器IP地址

#######################

查看Memcached路径

[[email protected] ~]# which memcached

/usr/local/bin/memcached

[[email protected] ~]#

[[email protected] ~]# /usr/local/bin/memcached -h

Memcached 1.4.13

-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 <mask>     access mask for UNIX socket, in octal (default: 0700)

-l <addr>     interface to listen on (default: INADDR_ANY, all addresses)

<addr> may be specified as host:port. If you don‘t specify

a port number, the value you specified with -p or -U is

used. You may 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 when 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 that would fail, so be sure you

set the limit correctly for the user you started

the daemon with (not for -u <username> user;

under sh this is done 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

-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 will 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, then it may be 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)

-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 be grown at runtime if not big enough.

Set this based on "STAT hash_power_level" before a

restart.

[[email protected] ~]#

[[email protected] ~]# /usr/local/bin/memcached -p 11211 -u root -m 32m -c 10240 -d

[[email protected] ~]# netstat -lnt |grep 11211

tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN

tcp        0      0 :::11211                    :::*                        LISTEN

[[email protected] ~]# lsof -i :11211

COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

Memcached 10915 root   26u  IPv4  20462      0t0  TCP *:memcache (LISTEN)

Memcached 10915 root   27u  IPv6  20463      0t0  TCP *:memcache (LISTEN)

Memcached 10915 root   28u  IPv4  20466      0t0  UDP *:memcache

Memcached 10915 root   29u  IPv6  20467      0t0  UDP *:memcache

[[email protected] ~]#

[[email protected] ~]# /usr/local/bin/memcached -p 11233 -u root -m 32m -c 10240 -d

[[email protected] ~]# netstat -lnt |grep 11233

tcp        0      0 0.0.0.0:11233               0.0.0.0:*                   LISTEN

tcp        0      0 :::11233                    :::*                        LISTEN

[[email protected] ~]# lsof -i :11233

COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

Memcached 10938 root   26u  IPv4  21056      0t0  TCP *:11233 (LISTEN)

Memcached 10938 root   27u  IPv6  21057      0t0  TCP *:11233 (LISTEN)

Memcached 10938 root   28u  IPv4  21060      0t0  UDP *:11233

Memcached 10938 root   29u  IPv6  21061      0t0  UDP *:11233

[[email protected] ~]#

-p 指定TCP的端口号,默认是11211

-U  指定TCP的端口号,默认是11211

-d 以守护进程方式启动

-m Memcached以多大内存方式启动,默认是64M

-u 指定运行Memcached的用户

-c  指定最大的并发连接数,默认是1024

-vv 以very werbose模式启动,也就是把调试信息和错误输出到控制台

-P  设置保存Memcached的pid文件

-l  指定监听的服务器IP地址

#######################################################

把Memcached服务设置开机自启动

echo "#######Memcached starting" >> /etc/rc.local

echo "/usr/local/bin/memcached -p 11233 -u root -m 32m -c 10240 -d" >> /etc/rc.local

时间: 2024-10-13 16:01:08

Memcached 安装的相关文章

RHEL6.5x64下memcached安装和使用

RHEL6.5x64下memcached安装和使用 从网上下载libevent-2.0.21-stable.tar.gz 和memcached-1.4.5.tar.gz,然后运行 第一步:安装gcc编译器 [[email protected] ~]#yum -y isnatll gcc 第二步:安装libevent和memcached [[email protected] srv]# tar zxvf libevent-2.0.21-stable.tar.gz [[email protected

Linux CentOS 7下Memcached 安装与配置

前言 本篇文章记录一下Linux CentOS 7中关于Memcached的安装与配置. 安装 安装memcached之前首先需要安装libevent,我这里用的版本是: ?libevent-2.0.22 ?memcached-1.4.25 首先将这两个安装文件上传至Linux服务器,在解压安装之前最好先检查一下是否已安装,从libevent开始: rpm -q libevent 发现系统已经安装了一个版本的libevent: 这里写图片描述 既然已经安装了一个版本的libevent,那么我们就

ubuntu14中 memcached安装与使用

第一步,先安装lib-event 下载lib-event  的包http://libevent.org/ 下载完之后,解压安装 ./configure –prefix=/usr (或 ./configure --program-prefix=/usr) make make install 第二步,安装memcached 下载memcached的包http://www.memcached.org/downloads 下载完之后.解压安装 1../configure 2.make 3.make in

Linux下memcached安装与连接

前几天技术总监要我在项目中加一个memcached,以前也从来没有配置过,所以就去网上找教程,最终折腾成功.比较坑的就是sasl协议那里. 由于memcached依赖libevents,所以要下载两个软件. 1,memcached.2,libevent. 首先检查是否有安装过. rpm -qa|grep libevent rpm -qa|grep memcached 官网下载:http://libevent.org/ 官网下载:http://memcached.org/latest 首先解压li

linux下memcached安装以及启动

1. 准备安装文件 下载memcached与libevent的安装文件 http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz(memcached下载地址) https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz(libevent下载地址) 2. 具体安装步骤 1.由于memcached依赖于libevent,因此需要安装libev

Windows和Linux环境下Memcached安装与配置(转)

一.memcached安装配置 windows平台安装 1.memcached-1.2.6-win32-bin.zip下载地址: http://code.jellycan.com/memcached/,执行memcached.exe -d install 安装. 2.守护进程方式启动:memcached.exe -m 512 -d start-d为守护进程启动,不能指定端口 默认端口11211-m为指定内存大小 3.指定端口启动:memcached.exe –p 33000 -m 512可以启动

java + memcached安装使用

一:安装 (暂时先拿上手的windows做实验) 1.下载memcached.exe , 放在F:\memcached\ 下 2.在CMD下输入 "F:\memcached\memcached.exe -d install" 安装. 3.再输入:"F:\memcached\memcached.exe -d start" 启动.以后memcached将作为windows的一个服务每次开机时自动启动.这样服务器端已经安装完毕了. 二:java引包 以下的包都是网上找的,

memcached 安装和测试

1.memcached 的工作原理(通过保持的KEY值,查询value值,在内存中操作) memcached是怎么工作的? Memcached的神奇来自两阶段哈希(two-stage hash).Memcached就像一个巨大的.存储了很多<key,value>对的哈希表.通过key,可以存储或查询任意的数据. 客 户端可以把数据存储在多台memcached上.当查询数据时,客户端首先参考节点列表计算出key的哈希值(阶段一哈希),进而选中一个节点:客户端将 请求发送给选中的节点,然后memc

Memcached 安装及配置

下载Memcached.exe 保存到c:\memcached 运行command: 输入 c:\memcached\memcached.exe -d install 回车,安装memcached server 输入 c:\memcached\memcached.exe -d start 回车, 这个也可以自行到服务管理器中启动 memcached server 默认监听端口 11211 , 且默认可执行命令只是 -d runservice , 所以在command中修改 -p -m 等是无效的