标签:
1:软件环境:
系统版本:CentOS release 6.5
redis版本:redis-cli 3.0.5
安装目录:"/usr/local/redis"
2:redis安装:
tar -xvf redis-3.0.5.tar.gz
cd redis-3.0.5
make test
通常会出现报错:
You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1
解决方法:
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
tar xzvf tcl8.6.1-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.1/unix/
./configure
make
make install
在接着安装redis软件:
make prefix=/usr/local/redis install
当安装完成后在"/usr/local/redis/bin"目录下出现以下几个文件:
redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server
3:设定redis服务:
cp /root/redis-3.0.5/utils/redis_init_script /etc/init.d/redis
4:更改redis脚本:
#!/bin/sh
#chkconfig: 2345 80 90
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
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 "Please use start or stop as first argument"
;;
esac
5:将redis配置文件拷贝到/etc/redis/${REDISPORT}.conf
cp /root/redis-3.0.5/redis.conf /etc/redis/6379.conf
默认情况下,Redis未启用认证,可以通过开启6379.conf的requirepass 指定一个验证密码;
需要修改配置文件开启认证:
#requirepass foobared
去掉行前的注释,并修改密码为所需的密码,保存文件;
6:启动redis服务
chkconfig --add redis
service redis start
7:将Redis的命令所在目录添加到系统参数PATH中
vi .bash_profile
export PATH="$PATH:/usr/local/redis/bin"
source .bash_profile
8:测试:
redis-cli
redis 127.0.0.1:6379> auth redis
OK
redis 127.0.0.1:6379> ping
PONG
redis 127.0.0.1:6379>
redis就安装成功了;
最新CentOS6.x下redis安装
标签:
原文地址:http://www.cnblogs.com/qlwang/p/5038739.html