官网地址:https://redis.io/
源码地址:https://github.com/antirez/redis
从官网上可以看到最新的稳定分支,当前的稳定分支是5.0.6
用Clion查看,调试源码比较方便。本文用的就是此种方式。
如果提前已经安装过redis,先卸载吧。
1.查询并列表已经安装的redis相关软件
dpkg --get-selections | grep redis
2.按照如下方式依次删除redis相关的软件
sudo apt-get remove --purge redis-server
编译报错处理:
1. fatal error: sys/event.h: No such file or directory
#include <sys/event.h>
^~~~~~~~~~~~~
compilation terminated.
CMakeFiles/redis-server.dir/build.make:158: recipe for target 'CMakeFiles/redis-server.dir/src/ae_kqueue.c.o' failed
解决方法:
查看/src/ae_kqueue.c的源码,
/usr/include/x86_64-linux-gnu/sys/ 目录下没有event.h头文件,
通过命令
# find / -name event.h
查找此文件
此文件在 /usr/include下面。创建硬链接文件
# sudo ln /usr/include/event.h /usr/include/x86_64-linux-gnu/sys/event.h
server.c中有main函数,是redis服务的启动函数