您的位置:首页 > 数据库 > Redis

redis( 1 )redis+TCMALLOC高性能的缓存服务器的安装配置

ayanami001 2015-08-30 10:30 10 查看
安装

1准备编译环境

yum -y install gcc gcc+ gcc-c++ openssl openssl-devel pcre pcre-devel

2 下载源码包(由于google不能上所以选择从本地上传)

wget 172.60.0.172:8080/libunwind-1.1.tar.gz

wget 172.60.0.172:8080/gperftools-2.1.tar.gz

wget 172.60.0.172:8080/redis-2.8.10.tar.gz

3 编译安装

依次安装

tar xf libunwind-1.1.tar.gz

CFLAGS=-fPIC ./configure

make CFLAGS=-fPIC

make CFLAGS=-fPIC install

gperftools的安装主要是用到了TCMALLOC来提高性能所以最简化安装

tar xf gperftools-2.1.tar.gz

cd gperftools-2.1

./configure --disable-cpu-profiler --disable-heap-profiler --disable-heap-checker --disable-debugalloc --enable-minimal

make && make install

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

/sbin/ldconfig

cd /usr/local/lib

ln -sv libtcmalloc_minimal.so.4.1.2 libtcmalloc.so

redis的安装

tar xf redis-2.8.10.tar.gz

cd redis2.8.10

mkdir –p /opt/redis

make PREFIX=/opt/redis USE_TCMALLOC=yes FORCE_LIBC_MALLOC=yes install

三 配置

创建配置文件夹以及文件

mkdir -p /opt/redis/etc

mkdir -p /opt/redis/run

mkdir -p /opt/redis/data/6379

mkdir -p /opt/redis/log

cp /redis的解压路径 /redis.conf /opt/redis/etc/redis.conf

cp /opt/redis/etc/redis.conf /opt/redis/etc/redis_6379.conf

修改配置文件:

vim /opt/redis/etc/redis_6379.conf

daemonize yes

pidfile /opt/redis/run/redis_6379.pid

dir /opt/redis/data/6379

logfile /opt/redis/log/redis_6379.log

创建服务管理脚本

vim /etc/init.d/redis

#!/bin/sh

PATH="/opt/redis/bin:$PATH"

EXEC="/opt/redis/bin/redis-server"

CLIEXEC="/opt/redis/bin/redis-cli"

PIDFILE="/opt/redis/run/redis_6379.pid"

CONF="/opt/redis/etc/redis_6379.conf"

REDISPORT="6379"

case "$1" in

start)

if [ -f $$PIDFILE ]

then

echo "$PIDFILE exists, process is already running or crashed."

else

echo "Starting Redis server..."

$EXEC $CONF

fi

;;

stop)

if [ ! -f $PIDFILE ]

then

echo "$PIDFILE does not exist, process is not running."

else

PID=$(cat $PIDFILE)

echo "Stopping ..."

$CLIEXEC -p $REDISPORT shutdown

while [ -x /proc/${PID} ]

do

echo "Waiting for Redis to shutdown ..."

sleep 1

done

echo "Redis stopped."

fi

;;

*)

echo "Usage: $0 {start|stop}" >&2

exit 1

;;

esac

授权 chmod +x /etc/init.d/redis

vim /etc/sysctl.conf

在最后添加以下节点:

vm.overcommit_memory = 1

sysctl –p

启动redis

/etc/init.d/redis start

验证

ps aux | grep redis
标签: