Linux安装Redis
安装Redis
# 安装epel
yum -y install epel-release
# 安装remi 使用清华源镜像
yum -y install https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm
# 安装remi 使用阿里云镜像 清华源镜像阿里云镜像选择一个安装即可
# yum -y install https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm
# 安装最新版Redis
yum --enablerepo=remi install -y redis
# 启动Redis并设置为开机自启
systemctl start redis && systemctl enable redis
优化
sed -i "/noproc/d" /etc/security/limits.conf
echo "fs.file-max = 65535" >> /etc/sysctl.conf
echo "* soft nofile 65535" >> /etc/security/limits.conf
echo "* hard nofile 65535" >> /etc/security/limits.conf
echo "* soft nproc 65535" >> /etc/security/limits.conf
echo "* hard nproc 65535" >> /etc/security/limits.conf
echo "ulimit -n 65535" >> /etc/profile
echo "vm.swappiness = 0" >> /etc/sysctl.conf
echo "net.ipv4.tcp_syncookies = 1" >> /etc/sysctl.conf
source /etc/profile
配置Redis配置文件
/etc/redis.conf
bind 0.0.0.0 #配置所有IP均可访问 生产服务器请根据需要开启
daemonize yes #守护进程运行,默认情况下Redis不作为守护进程运行
requirepass Pwd0654321 #设置密码
maxmemory 5368709120 #设置一个内存使用限制到指定的字节数 这里是5个G
maxmemory-policy volatile-lru #配置内存淘汰策略 这里是加入键的时候如果过限,首先从设置了过期时间的键集合中驱逐最久没有使用的键
本文来自博客园,作者:Micky233,转载请注明原文链接:https://www.cnblogs.com/geek233/p/16419963.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~