1. 从Redis官网下载源码文件
wget https://download.redis.io/redis-stable.tar.gz
2. 安装一些必要的依赖
sudo apt-get install -y build-essential pkg-config tcl
3. 编译和安装Redis
tar -xzvf redis-stable.tar.gz
cd redis-stable
make && sudo make install
make test
4. 运行redis-server服务后出现的一些提示问题解决
“WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328.”
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl -p
“Increased maximum number of open files to 10032 (it was originally set to 1024).”
vi /etc/security/limits.conf
# 将以下内容追加到 /etc/security/limits.conf 文件中,其中 root 表示的是运行该Redis服务的用户名
root soft nofile 65535
root hard nofile 65535