安装并测试memcached

来源:互联网 发布:论坛抢沙发软件 编辑:程序博客网 时间:2024/06/05 00:24

1.下载libevent和memcached软件包并解压

memcached依赖于libevent,需确保libevent已经装上,才能安装memcached

[root@localhost software]# tar -xzf libevent-2.1.8-stable.tar.gz   [root@localhost software]# tar -xzf memcached-1.5.3.tar.gz 

2.配置并安装libevent

-prefix 指定安装路径

[root@localhost libevent-2.1.8-stable]# ./configure -prefix=/usr/local/libevent [root@localhost libevent-2.1.8-stable]# make [root@localhost libevent-2.1.8-stable]# make install

3.配置并安装memcached

-with-libevent 指定libevent所在路径
-prefix 指定安装路径

[root@localhost libevent-2.1.8-stable]# cd ../memcached-1.5.3/[root@localhost memcached-1.5.3]# ./configure -with-libevent=/usr/local/libevent -prefix=/usr/local/memcached[root@localhost memcached-1.5.3]# make[root@localhost memcached-1.5.3]# make install


4.安装telnet

使用telnet向memcached发送命令

[root@localhost memcached-1.5.3]# yum -y install telnet

5.启动memcached
常用的启动选项包括:

-d 启动为守护进程
-m 分配给Memcache使用的内存数量,单位是MB  
-u 运行Memcache的用户
-l 监听的IP地址(如果主机有多个地址的话)
-p 监听的端口
-c 最大运行的并发连接数,默认是1024 
-P 设置保存Memcache的pid文件,例如: /tmp/memcached.pid

[root@localhost memcached-1.5.3]# cd /usr/local/memcached/bin/[root@localhost bin]# ./memcached -d -m 50m -p 11211 -u root

6.使用telnet连接并测试

[root@localhost bin]# telnet 127.0.0.1 11211 Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is '^]'.set str 0 0 11hello worldSTOREDget strVALUE str 0 11hello worldENDquitConnection closed by foreign host.[root@localhost bin]#