Redis学习系列——Redis安装

Redis学习系列——Redis安装

1. 什么是Redis ?

Redis是一个开源,高级的键值存储和一个适用的解决方案,用于构建高性能,可扩展的Web应用程序。Redis有三个主要特点,使它优越于其它键值数据存储系统:

  • Redis将其数据库完全保存在内存中,仅使用磁盘进行持久化。
  • 与其它键值数据存储相比,Redis有一组相对丰富的数据类型。
  • Redis可以将数据复制到任意数量的从机中。

2. Redis 安装(Ubuntu)

2.1 在 Ubuntu 系统安装 Redis可以使用以下命令:
$sudo apt-get update
$sudo apt-get install redis-server
2.2 启动Redis:
$sudo redis-server
2.3 查看服务:
$ redis-cli
2.4 命令执行后打开终端:
redis 127.0.0.1:6379>

注:6379为Redis 默认端口。

redis 127.0.0.1:6379> ping
PONG

安装完成!

3. Redis 基本配置(ubuntu)

ubuntu 下Redis配置文件位于:/etc/redis/redis.conf

3.1 设置密码
sudo vi /etc/redis/redis.conf 

定位 requirepass

修改密码 requirepass yourpassword

################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
requirepass redis

通过一下命令行测试修改结果:

$ redis-cli                     
127.0.0.1:6379> config get requirepass
(error) NOAUTH Authentication required.

提示无权访问。

$ redis-cli -h 127.0.0.1 -p 6379 -a redispass
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "redispass"

通过密码登陆可以正确访问。

注:redispass 为你设置的密码。127.0.0.1为本机Ip地址

3.2 设置远程访问

bind 0.0.0.0这一行解除注释

# By default Redis listens for connections from all the network interfaces
# available on the server. It is possible to listen to just one or multiple
# interfaces using the "bind" configuration directive, followed by one or
# more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
bind 0.0.0.0

通过ip地址访问redis

$ redis-cli -h xxx.xxx.xxx.xxx -p 6379 -a redispass
xxx.xxx.xxx.xxx:6379>

注意:xxx.xxx.xxx.xxx为服务器IP地址。

4. Redis可视化客户端工具

下载安装 Redis Desktop Managerhttps://redisdesktop.com/download

下面是Redis Desktop Manager的配置界面:

这里写图片描述

连接成功:
这里写图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值