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,936評論 0 0
  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,941評論 0 23
  • ofo開啟了周末免費騎行活動,我也興致勃勃的玩了玩。路上好多人都騎著小黃車穿梭在城市大街小巷中,不禁感慨:生的共享...
    萌萌加油站閱讀 165評論 0 0
  • 心靈自由寫作群第八期第九篇作業 小時候愛看童話故事,長大后發現童話里都是騙人的,哈哈…… 我希望是做編童話故事的人...
    書香常伴閱讀 228評論 0 0