ubuntu 18.04安装与配置 Redis

1. 安装Redis

wget http://download.redis.io/releases/redis-5.0.5.tar.gz
tar -zxvf redis-5.0.5.tar.gz
cd redis-5.0.5/

然后编译:

sudo make
sudo make install

然后就可以使用redis了,脚本位置在:/usr/local/bin

2. 前端测试启动 Redis

前端启动:

src/redis-server

得到的结果:

41897:C 18 Jul 2021 20:42:55.497 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
41897:C 18 Jul 2021 20:42:55.498 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=41897, just started
41897:C 18 Jul 2021 20:42:55.498 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
41897:M 18 Jul 2021 20:42:55.499 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 5.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 41897
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

3. 后端启动 Redis

vim redis.conf

然后修改文件:

  • 第56行解除注释,改为:bind 127.0.0.1 ::1
  • 第136行修改为yes,改为:daemonize yes
  • 第171行添加日志文件,默认会到/dev/null,可以修改为:logfile "/home/xq/Desktop/redis-5.0.5/redis.log"

如果是测试连接,需要修改:

  • 第56行注释,改为: # bind 127.0.0.1 ::1
  • 第69行注释,改为:# bind 127.0.0.1
  • 第88行,改为:protected-mode no

然后启动:

src/redis-server redis.conf

这里可以查看一下:

ps -ef | grep redis

显示如下内容说明被启动了:

xq        43151      1  0 20:56 ?        00:00:00 src/redis-server 127.0.0.1:6379
xq        43164  37297  0 20:57 pts/1    00:00:00 grep --color=auto redis

4. 使用客户端操作Redis

src/redis-cli

然后就可以操作redis了

5. 关闭 Redis

在客户端中运行:

SHUTDOWN
QUIT

或是使用:

src/redis-cli shutdown
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

呆萌的代Ma

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值