First, I want to say that all these theory are based on Linux CentOS release 6.3 (Final)
and Redis-2.8.19(stable) you guys can check that with the command:
$ cat /etc/issue
$ /path/to/redis-cli –version
As far as I know, It won’t make too much difference, but I strongly recommend you to use
this version of Redis, because yours probably has bug to fix or not support the properties
that we’ll use later.
OK, now, let’s rock~
Please allow me to talk a little more nagging, because not all the people reading this
passage is a high level programmer.
Install Redis
download form http://download.redis.io/releases/redis-2.8.19.tar.gz
$ tar zxvf redis-2.8.19.tar.gz
$ cd redis-2.8.19
$ make PREFIX=/some/other/directory install
sure, you need to replace /some/other/directory with your own location for setup your redis.
For example, I use /opt/redis
Configure Redis
create path to store config file, data rdb file, redis log and pid file
$ mkdir -p /opt/redis/{etc,data,log,run}
copy config file into etc path
$ cp ./redis.conf /opt/redis/etc
config the redis.conf file
daemonize yes
pidfile /data/redis/run/redis_6379.pid
port 6379
logfile “/data/redis/log/redis_6379.log”
dbfilename dump_6379.rdb
dir /data/redis/data/redis_6379/ # notice we should create log folder for each db instance
create db path for each instance
mkdir /opt/redis/data/redis_6379/
Start Redis
#!/bin/sh
REDISPATH=/opt/redis/
PORT=$1
if [ -f ${REDISPATH}etc/redis_${PORT}.conf ]; then
${REDISPATH}bin/redis-server ${REDISPATH}etc/redis_${PORT}.conf
else
echo “no config match port ${PORT}”
fi
:wq 保存成 redis.sh, chmod +x redis.sh 后执行该文件, 开启 Redis.
OK, Done.