centos6.5搭建memcache
来源:互联网 发布:ipowerl魔术软件 编辑:程序博客网 时间:2024/06/06 06:50
一.环境
- centos6.5
- memcached-1.4.25
- libevent-2.0.22
- centos服务器ip:192.168.85.128
二.安装
- libevent
# tar xzvf libevent-2.0.22-stable.tar.gz# cd libevent-2.0.22-stable# ./configure --prefix=/usr/local/libevent2.0.22# make && make install
- memcache
# tar xzvf memcached-1.4.25.tar.gz# cd memcached-1.4.25# ./configure --prefix=/usr/local/memcache --with-libevent=/usr/local/libevent2.0.22# make && make install
三.启动
/usr/local/memcache/bin/memcached -d -m 1024 -u root -l 192.168.85.128 -p 12000 -c 1024 –P /var/run/memcached.pid#说明:-p后面是memcache的监听端口最好在10000以上
- 检测memcache启动情况
#ps aux|grep memcached
出现192.168.85.128 -p 12000就算启动了
四.配置防火墙
一般搭建memcache服务器需要给特定服务器id配置防火墙端口规则
我们在这里为了测试memcache运行情况,在这里就不详细配置防火墙,直接关闭防火
#chkconfig iptables off 永久直接关闭防火墙 #service iptables stop 暂时关闭防火墙,重启不生效
五.PHP连接测试
- 安装memcache拓展 并且在php.ini开启memcache拓展
- php代码(memcache与mysql交互一般情况)
<?php//获取用户信息//实例化 memcache 对象$memObj = new Memcache();//连接memcache服务器 参数 地址,端口(memcache端口为 12000)$memObj->connect('192.168.85.128', 12000);//获取某个变量的值 如果存在在返回变量的值 否则返回false$userinfo = $memObj->get('userinfo');//判断缓存是否存在,不存在则连接数据库获取变量并保存到memcache服务器if(!$userinfo){ //连接数据库... 查询数据信息 例如返回值为 'userinfo....'; $var = 'userinfo....'; $memObj->set('userinfo', $var); echo '缓存不存在.....';}echo $var;
阅读全文
1 0
- centos6.5搭建memcache
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建vpn
- CentOS6.5搭建LNMP
- centos6.5 vpn 搭建
- Centos6.5搭建bugzilla
- centOS6.5搭建openvpn
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5 搭建LNMP
- CentOS6.5搭建LNMP
- js脚本页面自动刷新
- SQL 数据类型 归纳
- 1002. 等价二叉树
- Pedestrian Identification (2) ——研究现状总结
- 人人都应该掌握的9种数据分析方法
- centos6.5搭建memcache
- Java代码使用工程中的图片
- springboot整合mybatis实现多数据库的切换
- JavaWeb项目中使用LOG4J
- 在Unity菜单栏上添加自定义菜单
- springmvc返回json数据
- POI操作 http://www.cnblogs.com/dayuruozhi/p/6490793.html
- HashMap和HashSet的区别
- C++入门知识点(1)