Linux下 Memcache安装
Linux下的Memcache安装 准备安装程序memcached-1.4.20.tar.gz memcache服务器端libevent的最新版本是libevent-2.0.21libevent官网:http://libevent.org/下载地址:https://github.com/downloads/libevent/libevent/libeven
·
Linux下的Memcache安装
准备安装程序
memcached-1.4.20.tar.gz memcache服务器端
libevent的最新版本是libevent-2.0.21
libevent
官网:http://libevent.org/
下载地址:https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
memcache
官网:http://www.memcached.org/
下载地址:http://memcached.org/latest
安装Memcached步骤:
1.编译安装Libevent
# wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# tar -zxvf libevent-2.0.21-stable.tar.gz
# cd libevent-2.0.21-stable
# ./configure -prefix=/usr/local/libevent && make && make test && sudo make install
如果提示如下错误:
configure: error: in `/opt/memcached/libevent-2.0.21-stable':
configure: error: no acceptable C compiler found in $PATH
因为是centos linux,默认可以采用yum方式安装,则采用如下命令安装gcc编译器即可:
# yum -y install gcc
测试是否安装成功
# ls -alR /usr/local/libevent | grep libevent
2.编译安装Memcache
# wget http://www.memcached.org/files/memcached-1.4.21.tar.gz
# tar -zxvf memcached-1.4.21.tar.gz
# cd memcached-1.4.21
# ./configure --with-libevent=/usr/local/libevent 或者指定目录安装./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
# make && make test && sudo make install
测试是否成功安装memcached:
# ls -al /usr/local/bin/mem*
-rwxr-xr-x 1 root root 249785 05-10 18:09 /usr/local/bin/memcached
7.memcached的基本设置:
1.启动Memcached的服务器端:
/usr/local/bin/memcached -d -m 100 -u root -l 192.168.0.111 -p 12000 -c 512 -P /MEMPID/ memcached.pid
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量(缺省:64MB),单位是MB,我这里是10MB,
-u是运行Memcache的用户,我这里是root,
-l监听服务器IP地址,如果有多个地址的话,这里指定了服务器IP地址192.168.70.178
-p是设置Memcache监听的端口(缺省:11211),我这里设置了12000,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,此次512,按照服务器的负载量来设定,
-P是设置保存Memcache的pid文件,我这里是保存在 / MEMPID/ memcached.pid
2.检查是否运行成功
ps -ef|grep memcached 或者 ps aux|grep memcached
3.连接到 memcached:
telnet ip 端口,如telnet 192.168.0.111 12000
(没有安装telnet可以参考如下页面操作:http://jingyan.baidu.com/album/9f63fb91ac7ebcc8400f0e94.html?picindex=1)
stats查看状态,flush_all:清楚缓存
4.停止memcached
kill -9 pid (-9表示强制杀死,pid 为进程的进程标识符)
kill ‘cat MEMPID/ memcached.pid’
killall memcached #杀死所有memcache进程
到这里 memcached就已经安装好了。
增加到开机启动
# vi /etc/rc.local
增加:
/usr/local/bin/memcached -d -m 100 -u root -l 192.168.0.111 -p 12000 -c 512 -P /MEMPID/ memcached.pid
准备安装程序
memcached-1.4.20.tar.gz memcache服务器端
libevent的最新版本是libevent-2.0.21
libevent
官网:http://libevent.org/
下载地址:https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
memcache
官网:http://www.memcached.org/
下载地址:http://memcached.org/latest
安装Memcached步骤:
1.编译安装Libevent
# wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# tar -zxvf libevent-2.0.21-stable.tar.gz
# cd libevent-2.0.21-stable
# ./configure -prefix=/usr/local/libevent && make && make test && sudo make install
如果提示如下错误:
configure: error: in `/opt/memcached/libevent-2.0.21-stable':
configure: error: no acceptable C compiler found in $PATH
因为是centos linux,默认可以采用yum方式安装,则采用如下命令安装gcc编译器即可:
# yum -y install gcc
测试是否安装成功
# ls -alR /usr/local/libevent | grep libevent
2.编译安装Memcache
# wget http://www.memcached.org/files/memcached-1.4.21.tar.gz
# tar -zxvf memcached-1.4.21.tar.gz
# cd memcached-1.4.21
# ./configure --with-libevent=/usr/local/libevent 或者指定目录安装./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
# make && make test && sudo make install
测试是否成功安装memcached:
# ls -al /usr/local/bin/mem*
-rwxr-xr-x 1 root root 249785 05-10 18:09 /usr/local/bin/memcached
7.memcached的基本设置:
1.启动Memcached的服务器端:
/usr/local/bin/memcached -d -m 100 -u root -l 192.168.0.111 -p 12000 -c 512 -P /MEMPID/ memcached.pid
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量(缺省:64MB),单位是MB,我这里是10MB,
-u是运行Memcache的用户,我这里是root,
-l监听服务器IP地址,如果有多个地址的话,这里指定了服务器IP地址192.168.70.178
-p是设置Memcache监听的端口(缺省:11211),我这里设置了12000,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,此次512,按照服务器的负载量来设定,
-P是设置保存Memcache的pid文件,我这里是保存在 / MEMPID/ memcached.pid
2.检查是否运行成功
ps -ef|grep memcached 或者 ps aux|grep memcached
3.连接到 memcached:
telnet ip 端口,如telnet 192.168.0.111 12000
(没有安装telnet可以参考如下页面操作:http://jingyan.baidu.com/album/9f63fb91ac7ebcc8400f0e94.html?picindex=1)
stats查看状态,flush_all:清楚缓存
4.停止memcached
kill -9 pid (-9表示强制杀死,pid 为进程的进程标识符)
kill ‘cat MEMPID/ memcached.pid’
killall memcached #杀死所有memcache进程
到这里 memcached就已经安装好了。
增加到开机启动
# vi /etc/rc.local
增加:
/usr/local/bin/memcached -d -m 100 -u root -l 192.168.0.111 -p 12000 -c 512 -P /MEMPID/ memcached.pid
更多推荐
已为社区贡献2条内容
所有评论(0)