redis-installation-under-centos

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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 2,906评论 0 0
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,797评论 0 23
  • ofo开启了周末免费骑行活动,我也兴致勃勃的玩了玩。路上好多人都骑着小黄车穿梭在城市大街小巷中,不禁感慨:生的共享...
    萌萌加油站阅读 165评论 0 0
  • 心灵自由写作群第八期第九篇作业 小时候爱看童话故事,长大后发现童话里都是骗人的,哈哈…… 我希望是做编童话故事的人...
    书香常伴阅读 225评论 0 0