Redis学习系列——Redis安装

来源:互联网 发布:python turtle 坐标 编辑:程序博客网 时间:2024/06/05 10:04

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> pingPONG

安装完成!

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 redispass127.0.0.1:6379> config get requirepass1) "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.1bind 0.0.0.0

通过ip地址访问redis

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

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

4. Redis可视化客户端工具

下载安装 Redis Desktop Manager(https://redisdesktop.com/download)

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

这里写图片描述

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

1 0
原创粉丝点击