Prodution
Redis is an open source, BSD licensed, advanced key-value cache and store.
It is often referred to as a data structure server since keys can contain strings, hashes,
lists, sets, sorted sets, bitmaps and hyperloglogs.
Preparation
## check if install gcc gcc-c++ make tcl(for make test)
rpm -qa|egrep 'gcc|make|tcl'
## if not ,please install first
## yum install -y gcc gcc-c++ make tcl
Installation
# you can install one certain version or new stable version
# wget http://download.redis.io/releases/redis-2.8.13.tar.gz
wget http://download.redis.io/redis-stable.tar.gz
# untar and make
tar -zxf redis-stable.tar.gz
cd redis-stable
make
# make install
cd src && make install
# make test
make test
... ...
\o/ All tests passed without errors!
Cleanup: may take some time... OK
Configuration
# create redis home folder
mkdir /usr/local/redis/{bin,log,var,conf}
# copy binary file
cp redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof /usr/local/redis/bin
# configure
vim /usr/local/redis/conf/redis.conf
daemonize yes
port 6379
timeout 300
## database
databases 16
maxmemory 1g
## log
loglevel warning
pidfile /usr/local/redis/log/redis.pid
logfile /usr/local/redis/log/redis.log
## persistence
dir /usr/local/redis/var
save 900 1
save 300 10
save 60 10000
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
Start
# you can also add below to /etc/profile
export PATH=$PATH:/usr/local/redis/bin
redis-server /usr/local/redis/conf/redis.conf
# check if start
[root@localtest src]# ps -ef|grep redis
root 31567 1 0 17:29 ? 00:00:00 redis-server *:6379
root 31571 23704 0 17:29 pts/1 00:00:00 grep redis
# enter and test
[root@localtest src]# redis-cli
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> set name Colin
OK
127.0.0.1:6379> keys *
1) "name"
127.0.0.1:6379> get name
"Colin"
127.0.0.1:6379>
Maybe have errors
# Error 1
make[2]: cc: Command not found
fix : yum install -y gcc gcc-c++
# Error 2
zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory
fix : clean old compile files
make distclean && make
# Error 3
couldn't execute "tclsh8.5": no such file or directory
fix : yum install -y tcl