Redis集群部署(docker-compose)

news2024/11/29 0:45:02

更多更新信息请关注“技术客格”公众号

 

使用3主+3从的部署方式

一、服务器规划

序号

服务器

端口

节点名称

备注

1

192.168.1.120

6179

redis-1

2

192.168.1.120

6279

redis-2

3

192.168.1.120

6379

redis-3

4

192.168.1.120

6479

redis-4

5

192.168.1.120

6579

redis-5

6

192.168.1.120

6679

redis-6

二、Redis集群部署

2.1 创建目录

mkdir redis-{1,2,3,4,5,6}mkdir confcd confmkdir redis-{1,2,3,4,5,6}

2.2 依次于conf/redis-{1,2,3,4,5,6}配置redis.conf​​​​​​​

# Redis configuration file example. ####### Main configuration start ####### #注释掉bind 127.0.0.1,使redis可以外部访问#bind 127.0.0.1 # 端口号port 6179 #设置master节点密码masterauth R4E8d8i#s6Y4Z8
#给redis设置密码requirepass R4E8d8i#s6Y4Z8 ##redis持久化  默认是noappendonly yes #开启protected-mode保护模式,需配置bind ip或者设置访问密码#关闭protected-mode模式,此时外部网络可以直接访问protected-mode yes #是否开启集群cluster-enabled yes #集群的配置文件,该文件自动生成cluster-config-file nodes.conf #集群的超时时间cluster-node-timeout 5000 #用守护线程的方式启动daemonize no    #防止出现远程主机强迫关闭了一个现有的连接的错误 默认是300tcp-keepalive 300 ####### Main configuration end ####### timeout 0 tcp-backlog 511 # Note: these supervision methods only signal "process is ready."#       They do not enable continuous liveness pings back to your supervisor.supervised no # If a pid file is specified, Redis writes it where specified at startup# and removes it at exit.## When the server runs non daemonized, no pid file is created if none is# specified in the configuration. When the server is daemonized, the pid file# is used even if not specified, defaulting to "/var/run/redis.pid".## Creating a pid file is best effort: if Redis is not able to create it# nothing bad happens, the server will start and run normally.pidfile /var/run/redis_6379.pid # Specify the server verbosity level.# This can be one of:# debug (a lot of information, useful for development/testing)# verbose (many rarely useful info, but not a mess like the debug level)# notice (moderately verbose, what you want in production probably)# warning (only very important / critical messages are logged)loglevel notice # Specify the log file name. Also the empty string can be used to force# Redis to log on the standard output. Note that if you use standard# output for logging but daemonize, logs will be sent to /dev/nulllogfile "" # To enable logging to the system logger, just set 'syslog-enabled' to yes,# and optionally update the other syslog parameters to suit your needs.# syslog-enabled no # Specify the syslog identity.# syslog-ident redis # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.# syslog-facility local0 # Set the number of databases. The default database is DB 0, you can select# a different one on a per-connection basis using SELECT <dbid> where# dbid is a number between 0 and 'databases'-1databases 16 # By default Redis shows an ASCII art logo only when started to log to the# standard output and if the standard output is a TTY. Basically this means# that normally a logo is displayed only in interactive sessions.## However it is possible to force the pre-4.0 behavior and always show a# ASCII art logo in startup logs by setting the following option to yes.always-show-logo yes ################################ SNAPSHOTTING  ################################## Save the DB on disk:##   save <seconds> <changes>##   Will save the DB if both the given number of seconds and the given#   number of write operations against the DB occurred.##   In the example below the behaviour will be to save:#   after 900 sec (15 min) if at least 1 key changed#   after 300 sec (5 min) if at least 10 keys changed#   after 60 sec if at least 10000 keys changed##   Note: you can disable saving completely by commenting out all "save" lines.##   It is also possible to remove all the previously configured save#   points by adding a save directive with a single empty string argument#   like in the following example:##   save "" save 900 1save 300 10save 60 10000 # By default Redis will stop accepting writes if RDB snapshots are enabled# (at least one save point) and the latest background save failed.# This will make the user aware (in a hard way) that data is not persisting# on disk properly, otherwise chances are that no one will notice and some# disaster will happen.## If the background saving process will start working again Redis will# automatically allow writes again.## However if you have setup your proper monitoring of the Redis server# and persistence, you may want to disable this feature so that Redis will# continue to work as usual even if there are problems with disk,# permissions, and so forth.stop-writes-on-bgsave-error yes # Compress string objects using LZF when dump .rdb databases?# For default that's set to 'yes' as it's almost always a win.# If you want to save some CPU in the saving child set it to 'no' but# the dataset will likely be bigger if you have compressible values or keys.rdbcompression yes # Since version 5 of RDB a CRC64 checksum is placed at the end of the file.# This makes the format more resistant to corruption but there is a performance# hit to pay (around 10%) when saving and loading RDB files, so you can disable it# for maximum performances.## RDB files created with checksum disabled have a checksum of zero that will# tell the loading code to skip the check.rdbchecksum yes # The filename where to dump the DBdbfilename dump.rdb # Remove RDB files used by replication in instances without persistence# enabled. By default this option is disabled, however there are environments# where for regulations or other security concerns, RDB files persisted on# disk by masters in order to feed replicas, or stored on disk by replicas# in order to load them for the initial synchronization, should be deleted# ASAP. Note that this option ONLY WORKS in instances that have both AOF# and RDB persistence disabled, otherwise is completely ignored.## An alternative (and sometimes better) way to obtain the same effect is# to use diskless replication on both master and replicas instances. However# in the case of replicas, diskless is not always an option.rdb-del-sync-files no # The working directory.## The DB will be written inside this directory, with the filename specified# above using the 'dbfilename' configuration directive.## The Append Only File will also be created inside this directory.## Note that you must specify a directory here, not a file name.dir ./  # When a replica loses its connection with the master, or when the replication# is still in progress, the replica can act in two different ways:## 1) if replica-serve-stale-data is set to 'yes' (the default) the replica will#    still reply to client requests, possibly with out of date data, or the#    data set may just be empty if this is the first synchronization.## 2) if replica-serve-stale-data is set to 'no' the replica will reply with#    an error "SYNC with master in progress" to all the kind of commands#    but to INFO, replicaOF, AUTH, PING, SHUTDOWN, REPLCONF, ROLE, CONFIG,#    SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB,#    COMMAND, POST, HOST: and LATENCY.#replica-serve-stale-data yes # You can configure a replica instance to accept writes or not. Writing against# a replica instance may be useful to store some ephemeral data (because data# written on a replica will be easily deleted after resync with the master) but# may also cause problems if clients are writing to it because of a# misconfiguration.## Since Redis 2.6 by default replicas are read-only.## Note: read only replicas are not designed to be exposed to untrusted clients# on the internet. It's just a protection layer against misuse of the instance.# Still a read only replica exports by default all the administrative commands# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve# security of read only replicas using 'rename-command' to shadow all the# administrative / dangerous commands.replica-read-only yes  # When diskless replication is used, the master waits a configurable amount of# time (in seconds) before starting the transfer in the hope that multiple#

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/843568.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

多线程的创建,复习匿名内部类,Thread的一些方法,以及lambda的变量捕捉,join用法

一、&#x1f49b; Java的Thread类表示线程 1.创建类&#xff0c;继承Thread重写run方法 2.创建类&#xff0c;实现Runnable重写run方法 3.可以继承Thread重写run基于匿名内部类 4.实现Runnable重写run基于匿名内部类 5.lamdba表达式表示run方法的内容&#xff08;推荐&#x…

一、安全世界观

文章目录 1、 Web安全简史1.1 中国黑客简史1.2 黑客技术的发展历程1.3 web安全的兴起 2、黑帽子、白帽子3、安全的本质4、安全三要素5、如何实施安全评估5.1 资产等级划分5.2 威胁分析5.3 风险分析5.4 设计安全方案 6、白帽子兵法6.1 Secure By Default6.2 纵深防御原则6.3 数据…

在Raspberry Pi 4上安装Ubuntu 20.04 + ROS noetic(不带显示器)

在Raspberry Pi 4上安装Ubuntu 20.04 ROS noetic&#xff08;不带显示器&#xff09; 1. 所需设备 所需设备&#xff1a; 树莓派 4 B 型 wifi microSD 卡&#xff1a;最小 32GB MicroSD 转 SD 适配器 &#xff08;可选&#xff09;显示器&#xff0c;鼠标等 2. 树莓派…

积累常见的有针对性的python面试题---python面试题001

1.考点列表的.remove方法的参数是传入的对应的元素的值,而不是下标 然后再看remove这里,注意这个是,删除写的那个值,比如这里写3,就是删除3, 而不是下标. remove不是下标删除,而是内容删除. 2.元组操作,元组不支持修改,某个下标的内容 可以问他如何修改元组的某个元素 3.…

Git Submodule 更新子库失败 fatal: Unable to fetch in submodule path

编辑本地目录 .git/config 文件 在 [submodule “Assets/CommonModule”] 项下 加入 fetch refs/heads/:refs/remotes/origin/

sigmoid ReLU 等激活函数总结

sigmoid ReLU sigoid和ReLU对比 1.sigmoid有梯度消失问题&#xff1a;当sigmoid的输出非常接近0或者1时&#xff0c;区域的梯度几乎为0&#xff0c;而ReLU在正区间的梯度总为1。如果Sigmoid没有正确初始化&#xff0c;它可能在正区间得到几乎为0的梯度。使模型无法有效训练。 …

如何让子组件,router-view,呈现左右分布格局

1.用浮动进行浮动布局&#xff0c;定义一个大盒子&#xff0c;把浮动的样式写在公共样式里&#xff08;这里在main.js里定义一下全局布局&#xff09;。 2、能够在右边显示了

小研究 - MySQL 分区分表的设计及实(一)

随着信息技术的快速发展&#xff0c;数据量越来越大&#xff0c;海量的表查询操作需要消耗大量的时间&#xff0c;成为影响数据库访问性能提高的主要因素。为了提升数据库操作的查询效率和用户体验&#xff0c;在关系型数据库管理系统(MySQL)中通过 range 分区和 Merge 存储&am…

因果推断(三)双重差分法(DID)

因果推断&#xff08;三&#xff09;双重差分法&#xff08;DID&#xff09; 双重差分法是很简单的群体效应估计方法&#xff0c;只需要将样本数据随机分成两组&#xff0c;对其中一组进行干预。在一定程度上减轻了选择偏差带来的影响。 因果效应计算&#xff1a;对照组y在干预…

【kafka消息查询】kafka消费不到数据,写入端伙伴说他写入了,而且没有报错,如何来切割是写入的问题还是消费的问题

文章目录 前言情景再现如何确定是否写入了为什么出现不能写入总结 前言 kafka消费不到消息&#xff0c;如何查询界定是生产端的问题还是消费端的问题&#xff0c;特别是场景上下文已经丢失了的时候。 情景再现 使用命令&#xff1a; bin/kafka-console-consumer.sh --bootstr…

前端js用正则写一个车牌号验证

var car_number2 (rule, value, callback) > {var plateNumber /^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏…

simpleNet

文章目录 simpleNet0. 背景1. 主要贡献2. 网络3. 方法细节3.1 Feature Extractor 特征提取器3.2 Features Adaptor特征适配器3.3 Anomalous Feature Generator 异常特征生成器3.4 Discriminator 鉴别器3.5 Loss function and Training 损失方程和训练3.6 Inference and Scoring…

网信办制定个人信息保护新规,企业应采取哪些举措实现身份审计合规

近日&#xff0c;国家互联网信息办公室就《个人信息保护合规审计管理办法&#xff08;征求意见稿&#xff09;》面向社会公开征求意见。征求意见稿指出&#xff0c;办法根据《中华人民共和国个人信息保护法》等法律法规制定&#xff0c;旨在指导、规范个人信息保护合规审计活动…

K8s的高可用搭建

高可用技术搭建 在master节点上需要部署&#xff1a;keepalived、haproxy

记一款开源免费的终端工具Tabby

经常需要在Windows电脑上远程操作Linux&#xff0c;常用的终端工具有Xshell、SecureCRT、Putty。其中Xshell和SecureCRT功能强大&#xff0c;但是要收费&#xff0c;Putty虽然免费&#xff0c;但是功能上略显单薄。今天给大家介绍的这款终端工具非常强大&#xff0c;他不仅界面…

怎么样通过Bootstrap已经编译好(压缩好)的源码去查看符合阅读习惯的源码【通过Source Map(源映射)文件实现】

阅读本篇博文前&#xff0c;建议大家先看看下面这篇博文&#xff1a; https://blog.csdn.net/wenhao_ir/article/details/132089650 Bootstrap经编译(压缩)后的源码百度网盘下载地址&#xff1a; https://pan.baidu.com/s/14BM9gpC3K-LKxhyLGh4J9Q?pwdm02m Bootstrap未经编译…

【Spring专题】Spring底层核心原理解析

前言 Spring啊&#xff0c;可以说是我们大部分Java玩家【最熟悉的陌生人】了吧。八个字形容&#xff1a;似懂非懂&#xff0c;会也不会 你说简单应用&#xff0c;我们大家都会&#xff0c;那真要展开说两句的话&#xff0c;那只能来这么两句&#xff1a;这是第一句&#xff0…

C高级 作业 day4 8/7

1.整理思维导图 2.写一个函数&#xff0c;获取用户的uid和gid并使用变量接收 3.整理冒泡排序、选择排序和快速排序的代码 冒泡排序 //冒泡排序 void bubble_sort(int a[],int len) {int count0;for(int i1;i<len;i) //控制轮数{for(int j0;j<len-i;j) //控制每一轮交换…

opencv基础-29 Otsu 处理(图像分割)

Otsu 处理 Otsu 处理是一种用于图像分割的方法&#xff0c;旨在自动找到一个阈值&#xff0c;将图像分成两个类别&#xff1a;前景和背景。这种方法最初由日本学者大津展之&#xff08;Nobuyuki Otsu&#xff09;在 1979 年提出 在 Otsu 处理中&#xff0c;我们通过最小化类别内…

代码随想录—力扣算法题:977有序数组的平方.Java版(示例代码与导图详解)

版本说明 当前版本号[20230807]。 版本修改说明20230807初版 文章目录 版本说明977.有序数组的平方思路暴力排序双指针法 两种方法的区别 总结 977.有序数组的平方 力扣题目链接 更多内容可点击此处跳转到代码随想录&#xff0c;看原版文件 给你一个按 非递减顺序 排序的整…