一、首先下载redis
wget http://download.redis.io/redis-stable.tar.gz
二、解压redis
tar zvxf redis-stable.tar.gz
三、编译redis
进入redis-stable目录,运行make
此时坑就来了,由于我的机器上之前没有gcc,所以在make的时候找不到gcc还有cc命令,这时就需要给机器上安装gcc编译器
yum -y install gcc
yum -y install gcc-c++
yum install make
再进行make,发现会打印一系列的log,看的人真是眼花缭乱,不过还好是编译通过了。
四、编译测试redis
使用make test进行测试,发现又是一堆的log打印,在最后的时候不出意外的话会有如下几个坑:
错误1:
You need tcl 8.5 or newer in order to run the Redis test
解决:
yum install tcl.x86_64
错误2:
[exception]: Executing test client: NOREPLICAS Not enough good slaves to write..NOREPLICAS Not enough good slaves to write.
……
Killing still running Redis server 63439Killing still running Redis server 63486Killing still running Redis server 63519Killing still running Redis server 63546Killing still running Redis server 63574Killing still running Redis server 63591I/O error reading reply
……
解决:
vim tests/integration/replication-2.tcl
- after 1000
- after 10000
*注意:这里的减号是删掉这一行,加号是加上这一行(其实就是将1000改为10000),最初在网上查找这个错误的时候,一脸懵逼,根本不知道这里的减号、加号是什么意思。
后边的错误也有可能遇不到。*
错误3:
[err]: Slave should be able to synchronize with the master in tests/integration/replication-psync.tcl
Replication not started.
解决:
遇见过一次,重试make test就ok了。
错误4:
[err]: Test replication partial resync: ok psync (diskless: yes, reconnect: 1) in tests/integration/replication-psync.tcl
解决:
vim tests/integration/replication-psync.tcl - after 100
- after 1000