当前位置:网站首页 > R语言数据分析 > 正文

连接redis命令(redis连接数配置)



Redis的默认配置文件:

相对于很多大型存储系统,Redis的配置不是很多,到了Redis3.0之后有60多个

①单机模式下的配置参数

总体配置:下图是Redis的一些总体配置,例如端口、日志、数据库等

RDB相关配置:

那么为什么需要配置这么多条规则呢?

所以这里就是根据自身Redis写入情况来进行合理配置。

这个配置也是非常重要的一项配置,这是当备份进程出错时,主进程就停止接受新的写入操作,是为了保护持久化的数据一致性问题。

rdbcompression yes :

当然如果你想要禁用RDB配置,也是非常容易的,只需要在save的最后一行写上:save ""

慢查询配置

数据结构优化配置:

下图是Redis数据结构优化的相关配置 :

主从复制相关配置:

实现Redis的主从复制配置比较简单,而且容易明白。

下图是要配置的主从复制结构图:

1.说明

Redis主从复制中一个主服务可以有多个从服务,一个从服务可以有多个从服务。

配置比较简单,只需要更改redis.conf文件中的slaveof参数配置即可。

slaveof参数的格式如:slaveof <masterip> <masterport>

如果master服务器设置有密码则需要配置masterauth参数。

masterauth参数格式如:masterauth <master-password>

2.配置主从服务器

如上图可见master和slave1,slave2,slave3的服务器的端口的IP。

需要注意的是如果服务器中为设置requirepass参数,则从服务中不需要设置masterauth参数。

②Sentinel配置说明和分析

Redis的主从模式下,主节点一旦发生故障不能提供服务,需要人 工干预,将从节点晋升为主节点,同时还需要修改客户端配置。 对于很多应用场景这种方式无法接受。

Redis从 2.8发布了一个稳定版本的Redis Sentinel 。当前版本的 Sentinel称为Sentinel 2。它是使用更强大和更简单的预测算法来重 写初始Sentinel实现。(Redis2.6版本提供Sentinel 1版本,但是有 一些问题)

Sentinel(哨兵)架构解决了redis主从人工干预的问题。

Redis Sentinel是redis的高可用实现方案,在实际生产环境中,对 提高整个系统可用性是非常有帮助的。

Redis Sentinel是一个分布式系统,Redis Sentinel为Redis提供高可用性。可以在没有人为干预的情况下 阻止某种类型的故障。

可以在一个架构中运行多个 Sentinel 进程(progress), 这些进程使用流言协议(gossip protocols)来 接收关于主服务器是否下线的信息, 并使用投票协议(agreement protocols)来决定是否执行自动故 障迁移, 以及选择哪个从服务器作为新的主服务器。

Redis 的 Sentinel 系统用于管理多个 Redis 服务器(instance) 该系统执行以下三个任务:

监控(Monitoring): Sentinel 会不断地定期检查你的主服务器和从服务器是否运作正常。

提醒(Notification): 当被监控的某个 Redis 服务器出现问题时, Sentinel 可以通过 API 向管理员或者其他应用程序发送通知。

自动故障迁移(Automaticfailover): 当一个主服务器不能正常工作时, Sentinel 会开始一次自动故障迁移操作, 它会将失效主服务器的其中 一个从服务器升级为新的主服务器, 并让失效主服务器的其他从服务器改为复制新的主服务器; 当客 户端试图连接失效的主服务器时, 集群也会向客户端返回新主服务器的地址, 使得集群可以使用新主 服务器代替失效服务器

③Cluster配置说明和分析

CONFIG SET、CONFIG GET命令

requirepass配置参数

演示案例

多线程相关的配置参数

bind配置参数

protected-mode配置参数

①默认配置启动

②运行配置启动

③指定配置文件启动

shutdown命令

①交互式连接

②命令方式连接

bind 0.0.0.0 # Protected mode is a layer of security protection, in order to avoid that # Redis instances left open on the internet are accessed and exploited. # # When protected mode is on and if: # # 1) The server is not binding explicitly to a set of addresses using the # "bind" directive. # 2) No password is configured. # # The server only accepts connections from clients connecting from the # IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain # sockets. # # By default protected mode is enabled. You should disable it only if # you are sure you want clients from other hosts to connect to Redis # even if no authentication is configured, nor a specific set of interfaces # are explicitly listed using the "bind" directive. protected-mode no

到此这篇连接redis命令(redis连接数配置)的文章就介绍到这了,更多相关内容请继续浏览下面的相关推荐文章,希望大家都能在编程的领域有一番成就!

版权声明


相关文章:

  • swagger2配置(swagger2配置文件)2025-06-10 10:18:09
  • store软件下载(store软件下载教程)2025-06-10 10:18:09
  • redhat挂载u盘命令(redhat7挂载本地yum)2025-06-10 10:18:09
  • Gmocker 下载(gmarket中文版下载)2025-06-10 10:18:09
  • latex如何转为word(latex怎么转word)2025-06-10 10:18:09
  • ortec怎么读(oritental怎么读)2025-06-10 10:18:09
  • githubusercontent镜像(githubusercontent镜像加速)2025-06-10 10:18:09
  • 上一章设置下一章(word怎么让上一章节和下一页的页眉不同)2025-06-10 10:18:09
  • airplus02是什么牌子耳机(airplus是什么牌子蓝牙耳机)2025-06-10 10:18:09
  • docker模块(dockerfile模块)2025-06-10 10:18:09
  • 全屏图片