00.Redis入门

redis介绍

Redis(它的英文全称是Remote Dictionary Server)是一种主要基于内存存储和运行的,能快速响应的键值数据库产品。
在读写响应性能上,基于内存存储的Redis数据库最好的。相对于关系型数据库,Redis的应用范围相对较窄,但在互联网业务环境下的很多大型网站都需要它。因此,我们需要好好学习它
根据Redis官网介绍,Redis是一个开源的基于内存处理的数据结构存储系统,可以作为数据库使用,也可以用于缓存处理和消息传递处理。
它支持的数据结构包括字符串、列表、散列表、集合、带范围查询的有序集合、位图、Hyperloglog和带半径查询的地理空间索引。
Redis提供了内置复制、Lua脚本、LRU驱动事件、事务和不同级别的磁盘持久化功能,并通过哨兵和集群自动分区功能实现高可用。
Redis还提供了原子操作功能,如增加字符串内容,在散列表中增减值操作,在列表中增加一个元素成员,进行集合的交、并、差等运算,或者从有序集合获得排名最高的成员等。
Redis主要在内存中实现对各类数据的运算,以提高数据处理速度,但Redis也提供了隔一段时间转存到磁盘,或者通过命令附加到日志来持久化数据。当然为了提高效率,也可以完全禁用持久化功能。

redis安装

步骤一:打开官网
https://redis.io/download
步骤二:安装
下载,编译redis源码

wget http://download,redis.io/releases/redis-5.0.7.tar.gz
tar xzf redis-5.0.7.tar.gz
cd redis-5.0.7
make

启动:

./src/redis-server

步骤三:测试客户端连接服务器

./src/redis-cli
127.0.0.1:6379> set user1 tom
OK
127.0.0.1:6379> get user1
"tom"
127.0.0.1:6379>

步骤四:以后台进程方式启动redis
第一步:修改redis.conf文件

daemonize no 修改为 daemonize yes

第二步:指定redis.conf文件启动

./src/redis-server /data/redis-5.0.7/redis.conf

项目连接redis问题

排查ip能不能通

C:\Users\qq>ping 192.168.240.129
正在 Ping 192.168.240.129 具有 32 字节的数据:
来自 192.168.240.129 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.240.129 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.240.129 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.240.129 的回复: 字节=32 时间<1ms TTL=64
192.168.240.129 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms
C:\Users\qq>

排查redis的端口是否为通

-DENIED Redis is running in protected mode because protected mode is enabled, 
no bind address was specified, no authentication password is requested to clients. 
In this mode connections are only accepted from the loopback interface. 
If you want to connect from external computers to Redis you may adopt one of the following solutions: 
1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by 
connecting to Redis from the same host the server is running,
 however MAKE SURE Redis is not publicly accessible from internet if you do so. 
 Use CONFIG REWRITE to make this change permanent. 
2) Alternatively you can just disable the protected mode by editing the Redis configuration file, 
and setting the protected mode option to 'no', and then restarting the server.
3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 
4) Setup a bind address or an authentication password. 
NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
遗失对主机的连接。

解决方案


你可能感兴趣的:(深入浅出分布式缓存Redis,redis,数据库,缓存)