(十一)、memcached部署

中小型规模网站集群架构:memcached

: Ago linux运维群:https://hankbook.cn


前言:

你的用户登录信息是怎么保存的,你了解session的工作原理吗?
搭上memcached玩玩吧。

部署服务端

我放在backup服务器上
memcached下载
libevent下载
memcache客户端网址

tar xf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/usr/local/libevent
make && make install
cd ..
tar xf  memcached-1.4.36.tar.gz
cd memcached-1.4.36
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/
make && make install

vi /server/scripts/memcache_rpm.sh

#!/bin/sh
useradd -M -s /sbin/nologin/ -u 888 www
/usr/local/memcached/bin/memcached -p 11211 -u www -m 16m -c 10240 -d
echo '/usr/local/memcached/bin/memcached -p 11211 -u www -m 16m -c 10240 -d' >> /etc/rc.local

rpm制作

fpm -s dir -t rpm -n memcached -v 1.4.36  --post-install=/server/scripts/memcache_rpm.sh -f /usr/local/memcached /usr/local/libevent

memcached启动


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

参数-p 端口 -d 用守护进程启动 -m 指定内存大小 -c 并发大小 -l 监听地址 -u指定用户 -P是pid

/usr/local/memcached/bin/memcached -p 11211 -u www -m 16m -c 10240 -d

客户端安装

tar xf memcache-2.2.7.tgz
cd memcache-2.2.7
/application/php/bin/phpize 
./configure --enable-memcache --with-php-config=/application/php/bin/php-config --with-zlib-dir
make
make install

vi /application/php/lib/php.ini

extension_dir = "/application/php/lib/php/extensions/no-debug-non-zts-20121212/"
extension = memcache.so
session.save_handler = memcache
session.save_path = "tcp://172.16.1.41:11211"

剧本走一波

稍后跟上
posted @ 2017-04-06 09:04  汉克书  阅读(321)  评论(0编辑  收藏  举报