CentOS7 通过源码安装 Redis

Shell脚本安装

复制代码
wget http://download.redis.io/releases/redis-5.0.5.tar.gz

tar -xzvf redis-5.0.5.tar.gz

cd redis-5.0.5

make

make PREFIX=/usr/local/redis install

cp redis.conf /usr/local/redis/

系统配置

复制代码
#
# @see https://redis.io/docs/latest/operate/oss_and_stack/management/admin/
#

vim /etc/sysctl.conf

# vm.overcommit_memory = 1
# net.core.somaxconn = 1024

echo never > /sys/kernel/mm/transparent_hugepage/enabled

ulimit配置

复制代码
ulimit -n

vim /etc/security/limits.conf

# * 代表用户名,* 表示所有用户
* soft nofile 1000000
* hard nofile 1000000

/etc/systemd/system.conf

DefaultLimitNOFILE=65535
DefaultLimitNPROC=65535

redis.conf 配置

复制代码
#
# @see https://redis.io/docs/latest/operate/oss_and_stack/management/config/
#
vim /usr/local/redis/redis.conf

# 注释掉
#bind 127.0.0.1

# pasword
requirepass Abc@dfdfdfdf

# 对外端口
port 6380

# systemd
daemonize yes

# use systemd
supervised systemd

systemd service 文件

复制代码
vim /lib/systemd/system/redis.service

[Unit]
Description=Redis In-Memory Data Store
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf
ExecStop=/usr/local/redis/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

防火墙

复制代码
# 开启端口(permanent永久)
firewall-cmd --zone=public --add-port=6380/tcp --permanent

# 重启firewall生效
firewall-cmd --reload

启动命令

复制代码
# 开机启动
systemctl enable redis

# 启动
systemctl start redis

# 停止
systemctl stop redis

benchmark 测试

复制代码
cd /usr/local/redis

./bin/redis-benchmark -h localhost -p 6380 -a Abc@dfdfdfdf  -c 100 -n 100000
相关推荐
小七-七牛开发者15 小时前
TokenPilot:让 LLM Agent 长会话成本降 60%+ 的上下文管理
缓存·agent·token·context·上下文·推理成本
ClouGence20 小时前
Oracle 数据同步为什么会出现数据不一致?长事务是常被忽略的原因
数据库·后端·oracle
飞将1 天前
从零实现数据库(2)——HashIndex + IndexManager
数据库
Nturmoils2 天前
订单列表慢查询,先看 WHERE、ORDER BY 和 LIMIT
数据库
渣波2 天前
拒绝 SQL 焦虑!手把手带你用 NestJS + Prisma + DTO 写出“防弹”级后端代码
javascript·数据库·后端
倔强的石头_3 天前
KingbaseES 新版MySQL 兼容版体验:旧版迁移 + 功能实测
数据库
用户3169353811836 天前
Java连接Redis
redis
倔强的石头_6 天前
《Kingbase护城河》——数据库存储空间全景探测与精细化瘦身实战
数据库
冬奇Lab6 天前
每日一个开源项目(第134篇):Zvec - 阿里开源的嵌入式向量数据库,向量搜索界的 SQLite
数据库·人工智能·llm
ClouGence7 天前
Oracle CDC 架构优化:从主库直连到 DataGuard 备库同步
数据库·后端·oracle