广东十一选五开奖 > 计算机网络 > 内存缓存服务器memcahe

原标题:内存缓存服务器memcahe

浏览次数:167 时间:2019-12-04

Memcache

memcached安装

在广大web应用中都将数据保存到汉兰达DBMS中,应用服务器从中读收取来并在浏览器上显得。然则随着数据量的附加、采访的集聚,就能够现身路虎极光DBMS的承负加重、数据库相应恶化、网址展现延迟等要害影响。

[root@localhost ~]# cd /usr/local/src

那时就该memcached大显神通了。Memcached是抓实质量的遍布式内部存款和储蓄器缓存服务器。日常的施用目标是,通过缓存数据库查询的结果,收缩数据库访谈的次数,以升高动态web应用的快慢、升高可扩充性。

[root@localhost src]#wget

Memcached的特征

[root@localhost memcached-1.4.34]# cd memcached-1.4.34

合计轻易

[root@localhost src]#wget

基于libevent的年月管理

[root@localhost src]# cd libevent-2.0.22

嵌入内部存款和储蓄器存款和储蓄方式

[root@localhost libevent-2.0.22]# ./configure --prefix=/usr/local/libevent

Memcached不相互通讯的分布式

[root@localhost libevent-2.0.22]# make && make install

选拔memcached提升品质

[root@localhost libevent-2.0.22]# cd /usr/local/src/memcached-1.4.34

memcached的参数

[root@localhost memcached-1.4.34]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent

-p监听端口

[root@localhost memcached-1.4.34]# make && make install

-l<ip_addr>连接的ip地址暗中同意是本机的

开启memcached

Listenon<ip_addr>;defaulttoINADDR_ANY.Thisisanimportant

[root@localhost memcached-1.4.34]# cd /usr/local/memcached

-dstart运营memcached作为叁个服务Runmemcachedasadaemon.

图片 1

Restart重启

memcached不可能用root客户去开启,那么用普通顾客开启

Stop|shutdown关闭服务

[root@localhost memcached]# ./bin/memcached -u xbl &

Install安装服务

图片 2

Uninstall卸载

ok,memcached安装成功

-u<username>以如何地位运营

pkill memcached

Assumetheidentityof<username>(onlywhenrunasroot).

启动memcached

-m<num>最大的内部存款和储蓄器使用

# /usr/local/memcached/bin/memcached -m 64 -p 11211 -u nobody -d

Use<num>MBmemorymaxtous

 

-f<factor>块大小增长因子,私下认可是1.25

-p <num> tcp port number to listen on (default: 11211) // 监听
的端口
-u <num> udp port number to listen on (default: 0, off)
-s <file> unix socket path to listen on (disables network support)
-a <mask> access mask for unix socket, in octal (default 0700)
-l <ip_addr> interface to listen on, default is indrr_any
-d start tell memcached to start
-d restart tell running memcached to do a graceful restart
-d stop|shutdown tell running memcached to shutdown
-d install install memcached service // 把 memcached 注册成服务
-d uninstall uninstall memcached service
-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 is 64
mb //分配给 memcached 的最大内部存款和储蓄器
-m return error on memory exhausted (rather than removing
items)

Use<factor>asthemultiplierforcomputingthesizesofmemory

-c <num> max simultaneous connections, default is 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) //
输出全体新闻
-h print this help and exit
-i print memcached and libevent license
-b run a managed instanced (mnemonic: buckets)
-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

-M内部存款和储蓄器消耗尽时回来的不当,并非剔除项

 

chunksthatitemsarestoredin.Alowervaluemayresultin

来个小例子(key value)

lesswastedmemorydependingonthetotalamountofmemory

[root@localhost memcached]# /usr/local/memcached/bin/memcached -m 64 -p 11211 -u nobody -d
[root@localhost memcached]# netstat -tupln|grep 11211
tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      24244/memcached     
tcp        0      0 :::11211                    :::*                        LISTEN      24244/memcached     
udp        0      0 0.0.0.0:11211               0.0.0.0:*                               24244/memcached     
udp        0      0 :::11211                    :::*                                    24244/memcached     
[root@localhost memcached]# telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
add name 0 0 5
xiong
STORED
get name
VALUE name 0 5
xiong
END

availableandthedistributionofitemsizes.Thedefaultis

1.25.

-n<size>最小分配空间

lamp+memcached--->lammp

1.安装libevent

2.memcached服务器,memcached基于libevent的事件处理机制,所以要指明libevent的安装路线

./configure--with-libevent=/usr/local/libevent/

make&&makeinstall

开启以nobody的身份memcached服务

memcached-unobody-dstart

翻开memcached的进程及监听端口

图片 3

手工业编制memcached服务调整脚本

#chkconfig:23458999

#description:httpdservice

lockfile=/var/lock/subsys/memcached

prog=/usr/local/memcache/bin/memcached

./etc/init.d/functions

start(){

[-f$lockfile]&&echo"memcachedisstarted"&&exit

echo-n"memcachedisstarting....."

sleep1

$prog-unobody-dstart&&echo"ok"&&touch$lockfile||echo"failed"

}

stop(){

[!-f$lockfile]&&echo"memcachedisstoped"&&exit

echo-n"memcachedisstoping....."

sleep1

killprocmemcached&&echo"ok"&&rm-rf$lockfile||echo"failed"

}

case"$1"in

start)

Start

;;

stop)

stop

;;

restart)

stop

start

;;

*)

echo"usage:(start|stop|restart)"

;;

Esac

重启memcached服务

Servicememcachedrestart

[[email protected]]#netstat-tupln|grepmemcached

tcp000.0.0.0:112110.0.0.0:*LISTEN16174/memcached

tcp00:::11211:::*LISTEN16174/memcached

udp000.0.0.0:112110.0.0.0:*16174/memcached

udp00:::11211:::*16174/memcached

把memcached调整脚本参与到chkconfig,在345等级下开机自动运营memcached服务

Chkconfig--addmemcached

Chkconfig--list|grepmemcached

[[email protected]]#chkconfig--list|grepmemcached

memcached0:off1:off2:on3:on4:on5:on6:off

Telnet192.168.20.20011211

Stats查看memcached的状态

STATpid19681memcached的进程id

STATuptime1858

STATtime1378208617劳务开启的岁月

STATversion1.4.13memcached的版本

STATlibevent2.0.16-stable

STATpointer_size32

STATrusage_user0.002999

STATrusage_system0.005999

STATcurr_connections10

STATtotal_connections11

STATconnection_structures11

STATreserved_fds20

STATcmd_get0

STATcmd_set0

STATcmd_flush0

STATcmd_touch0

STATget_hits0get下载键值的剧情

STATget_misses0

STATdelete_misses0

STATdelete_hits0删除键值

STATincr_misses0

STATincr_hits0

STATdecr_misses0

STATdecr_hits0

STATcas_misses0

STATcas_hits0

STATcas_badval0

STATtouch_hits0

STATtouch_misses0

STATauth_cmds0

STATauth_errors0

STATbytes_read15

STATbytes_written14

STATlimit_maxbytes67108864

STATaccepting_conns1

STATlisten_disabled_num0

STATthreads4

STATconn_yields0

STAThash_power_level16

STAThash_bytes262144

STAThash_is_expanding0

STATexpired_unfetched0

STATevicted_unfetched0

STATbytes0

STATcurr_items0

STATtotal_items0

STATevictions0

STATreclaimed0

END

addnewkey0605add增多键值

12345键值的剧情

STORED

getnewkey下载键值

VALUEnewkey05

12345

END

3.为php加多memchace增加,安装php的memcache顾客端,指明php的陈设文件所在的门道

推行/usr/local/php/bin/phpize发生memcache的安装配备文件

./configure--enable-cache--with-php-config=/usr/local/php/bin/php-config

在/usr/local/php/lib/php/extensions/no-debug-zts-二零零六0626/目录下产生memcache的模块

开采php的发轫化文件/etc/php.ini,增加一条语句指明memcache模块所在的岗位

Extension=/usr/local/php/lib/php/extensions/no-debug-zts-20090626/

在不少 web 应用中都将数据保存到 MuranoDBMS 中,应用服务器从当中读抽取来并在浏览器上彰显。不过随着数据量的叠合、访谈的汇总,就能...

本文由广东十一选五开奖发布于计算机网络,转载请注明出处:内存缓存服务器memcahe

关键词:

上一篇:客户端连接RMS服务,报:服务暂时不可用,请确

下一篇:没有了