linux上安装redis

本文介绍如何下载并安装Redis 3.2.3版本,包括使用wget下载、解压及安装过程中的常见错误处理方法,并演示如何启动Redis服务及验证安装是否成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.下载


wget http://download.redis.io/releases/redis-3.2.3.tar.gz

2.剪切到要安装redis的目录
cp redis-3.2.3.tar.gz /usr/cg/redis-3.2.3.tar.gz

错误提示
[cg@localhost soft]cpredis3.2.3.tar.gz/usr/cg/redis3.2.3.tar.gzcp:/usr/cg/redis3.2.3.tar.gz:[cg@localhostsoft] sudo cp redis-3.2.3.tar.gz /usr/cg/redis-3.2.3.tar.gz
[sudo] password for cg:
cg 不在 sudoers 文件中。此事将被报告。
[cg@localhost soft]$ su root

2.切换到redis安装目录,解压
tar xzvf redis-3.2.3.tar.gz

错误提示
redis-3.2.3/utils/whatisdoing.sh
tar: redis-3.2.3:无法 mkdir: 权限不够
tar: redis-3.2.3/utils/whatisdoing.sh:无法 open: 没有那个文件或目录
tar: 由于前次错误,将以上次的错误状态退出

切换到root后,再解压

4.安装
cd redis-3.2.3
make

5.启动
./src/redis-server redis.conf

通过启动参数告诉redis使用指定配置文件

出现启动信息:

3322:M 18 Sep 10:01:17.596 * Increased maximum number of open files to 10032 (it was originally set to 1024).
.
_.-__ ''-._
_.-
.. ”-. Redis 3.2.3 (00000000/0) 64 bit
.-.-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.
-._|’_.-'| Port: 6379
|
-._ ._ / _.-' | PID: 3322
-._ -._-./ .-’ .-’
|-._-._ -.__.-' _.-'_.-'|
|
-._-._ _.-'_.-' | http://redis.io
-._ -._-._.-‘.-’ _.-’
|-._-._ -.__.-' _.-'_.-'|
|
-._-._ _.-'_.-' |
-._ -._-._.-‘.-’ _.-’
-._-._.-’ .-’
-._ _.-'
-.__.-’

3322:M 18 Sep 10:01:17.597 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3322:M 18 Sep 10:01:17.597 # Server started, Redis version 3.2.3
3322:M 18 Sep 10:01:17.597 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1’ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1’ for this to take effect.
3322:M 18 Sep 10:01:17.613 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command ‘echo never > /sys/kernel/mm/transparent_hugepage/enabled’ as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
3322:M 18 Sep 10:01:17.613 * The server is now ready to accept connections on port 6379

6.检测redis是否成功启动
A.重新打开一个shell终端窗口,启动客户端
./src/redis-cli
输入命令
ping
打印信息
127.0.0.1:6379> ping
PONG
证明redis已经安装并且启动成功了

有时间再补充sudo root出错的解决办法。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值