Memcached编译安装环境
L:Linux(centos 7.6)
R: Memcached(1.5.12)http://www.memcached.org/files/memcached-1.5.12.tar.gz
主机信息:
部署规划:
172.24.77.241(sr1.dj.com):运行Memcached
172.24.77.242(sr2.dj.com):运行Memcached
下载安装包
cd /usr/local/src/
wget http://www.memcached.org/files/memcached-1.5.12.tar.gz
安装依赖包
yum install libevent libevent-devel –y
编译安装 Memcached
tar xvf memcached-1.5.12.tar.gz
cd memcached-1.5.12
./configure --prefix=/usr/local/memcache
make && make install
添加启动用户
groupadd -g 1001 memcached && useradd -u 1001 -g 1000 memcached -s /sbin/nologin
启动 memcached
/usr/local/memcache/bin/memcached -u memcached -p 11211 -m 2048 -c 65536 &
部署repcached
tar xvf memcached-1.2.8-repcached-2.2.1.tar.gz
cd memcached-1.2.8-repcached-2.2.1
./configure --prefix=/usr/local/repcached --enable-replication
修改memcached配置文件
cp memcached.c memcached.c.bak
vim memcached.c +56
/ FreeBSD 4.x doesn‘t have IOV_MAX exposed. /
ifndef IOV_MAX
define IOV_MAX 1024
endif
make
make install
验证是否可执行
/usr/local/repcached/bin/memcached -h
启动 memcache
通过 repcached 安装的 memcached 命令启动 memcache 服务并实现 memcache 主备结构,其中-x 为对方即主 memcache 的 IP, -X 为本地启动的用数据同步的端口:
server 1 相关操作:
/usr/local/repcached/bin/memcached -d -m 2048 -p 11211 -u root -c 2048 -x 172.24.77.243 -X 16000
server 2 相关操作:
/usr/local/repcached/bin/memcached -d -m 2048 -p 11211 -u root -c 2048 -x 172.24.77.241 -X 16000
连接到 memcache 验证数据
yum install telnet -y
telnet 172.24.77.243 11211
set name 0 4
test
quit
telnet 172.24.77.241 11211